diff --git a/.ci/requirements.txt b/.ci/requirements.txt index 05fb773d1..ba70c63ee 100644 --- a/.ci/requirements.txt +++ b/.ci/requirements.txt @@ -81,7 +81,7 @@ ninja==1.11.1.3 \ # via -r requirements.in # The following packages are considered to be unsafe in a requirements file: -setuptools==75.8.2 \ - --hash=sha256:4880473a969e5f23f2a2be3646b2dfd84af9028716d398e46192f84bc36900d2 \ - --hash=sha256:558e47c15f1811c1fa7adbd0096669bf76c1d3f433f58324df69f3f5ecac4e8f +setuptools==76.0.0 \ + --hash=sha256:199466a166ff664970d0ee145839f5582cb9bca7a0a3a2e795b6a9cb2308e9c6 \ + --hash=sha256:43b4ee60e10b0d0ee98ad11918e114c70701bc6051662a9a675a0496c1a158f4 # via -r requirements.in diff --git a/.github/workflows/fontations.yml b/.github/workflows/fontations.yml index ba8ff9aa3..371265b2d 100644 --- a/.github/workflows/fontations.yml +++ b/.github/workflows/fontations.yml @@ -56,7 +56,6 @@ jobs: -Dchafa=disabled \ -Dgraphite=enabled \ -Doptimization=2 \ - -Ddoc_tests=true \ -Dfontations=enabled - name: Build run: meson compile -Cbuild diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 3b0aa261e..eb0ceca04 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -59,6 +59,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10 + uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11 with: sarif_file: results.sarif diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 5eb940ee8..5a5cccc19 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -114,6 +114,9 @@ hb_glyph_position_t hb_buffer_content_type_t hb_buffer_flags_t hb_buffer_cluster_level_t +HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS +HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES +HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE hb_segment_properties_t hb_buffer_serialize_format_t hb_buffer_serialize_flags_t @@ -181,6 +184,10 @@ uint8_t HB_EXTERN HB_DEPRECATED HB_DEPRECATED_FOR +hb_malloc +hb_calloc +hb_realloc +hb_free HB_H_IN HB_OT_H_IN @@ -344,6 +351,7 @@ HB_CORETEXT_TAG_MORT HB_CORETEXT_TAG_MORX hb_coretext_face_create hb_coretext_face_create_from_file_or_fail +hb_coretext_face_create_from_blob_or_fail hb_coretext_font_create hb_coretext_face_get_cg_font hb_coretext_font_get_ct_font @@ -364,6 +372,7 @@ hb_face_count hb_face_t hb_face_create hb_face_create_or_fail +hb_face_create_or_fail_using hb_face_create_from_file_or_fail hb_face_create_from_file_or_fail_using hb_face_list_loaders @@ -533,6 +542,7 @@ hb_ft_face_create hb_ft_face_create_cached hb_ft_face_create_referenced hb_ft_face_create_from_file_or_fail +hb_ft_face_create_from_blob_or_fail hb_ft_font_create hb_ft_font_create_referenced hb_ft_font_changed diff --git a/meson.build b/meson.build index ec9773ec9..21e89d2ac 100644 --- a/meson.build +++ b/meson.build @@ -315,7 +315,7 @@ endif gdi_uniscribe_deps = [] # GDI (Uniscribe) (Windows) if host_machine.system() == 'windows' and not get_option('gdi').disabled() - if (get_option('directwrite').enabled() and + if (get_option('gdi').enabled() and not (cpp.has_header('usp10.h') and cpp.has_header('windows.h'))) error('GDI/Uniscribe was enabled explicitly, but required headers are missing.') endif @@ -335,10 +335,9 @@ endif # DirectWrite (Windows) if host_machine.system() == 'windows' and not get_option('directwrite').disabled() - if get_option('directwrite').enabled() and not cpp.has_header('dwrite_1.h') + if get_option('directwrite').enabled() and not cpp.has_header('dwrite_3.h') error('DirectWrite was enabled explicitly, but required header is missing.') endif - conf.set('HAVE_DIRECTWRITE', 1) endif diff --git a/src/fontations/lib.rs b/src/fontations/lib.rs index 702a33022..06025d931 100644 --- a/src/fontations/lib.rs +++ b/src/fontations/lib.rs @@ -2,10 +2,12 @@ #![allow(non_upper_case_globals)] include!(concat!(env!("OUT_DIR"), "/hb.rs")); +use std::alloc::{GlobalAlloc, Layout}; use std::mem::transmute; use std::os::raw::c_void; use std::ptr::null_mut; use std::sync::atomic::{AtomicPtr, Ordering}; +use std::sync::Mutex; use read_fonts::tables::cpal::ColorRecord; use read_fonts::TableProvider; @@ -22,19 +24,51 @@ use skrifa::outline::DrawSettings; use skrifa::OutlineGlyphCollection; use skrifa::{GlyphId, MetadataProvider}; +struct MyAllocator; + +unsafe impl GlobalAlloc for MyAllocator { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + assert!(layout.align() <= 2 * std::mem::size_of::<*mut u8>()); + hb_malloc(layout.size()) as *mut u8 + } + + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + assert!(layout.align() <= 2 * std::mem::size_of::<*mut u8>()); + hb_calloc(layout.size(), 1) as *mut u8 + } + + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + assert!(layout.align() <= 2 * std::mem::size_of::<*mut u8>()); + hb_realloc(ptr as *mut c_void, new_size) as *mut u8 + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + assert!(layout.align() <= 2 * std::mem::size_of::<*mut u8>()); + hb_free(ptr as *mut c_void); + } +} + +#[global_allocator] +static GLOBAL: MyAllocator = MyAllocator; + // A struct for storing your “fontations” data #[repr(C)] struct FontationsData<'a> { face_blob: *mut hb_blob_t, + font: *mut hb_font_t, font_ref: FontRef<'a>, char_map: Charmap<'a>, + outline_glyphs: OutlineGlyphCollection<'a>, + color_glyphs: ColorGlyphCollection<'a>, + + // Mutex for the below + mutex: Mutex<()>, + serial: u32, x_size: Size, y_size: Size, location: Location, x_glyph_metrics: Option>, y_glyph_metrics: Option>, - outline_glyphs: OutlineGlyphCollection<'a>, - color_glyphs: ColorGlyphCollection<'a>, } impl FontationsData<'_> { @@ -49,14 +83,47 @@ impl FontationsData<'_> { let char_map = Charmap::new(&font_ref); + let outline_glyphs = font_ref.outline_glyphs(); + + let color_glyphs = font_ref.color_glyphs(); + + let mut data = FontationsData { + face_blob, + font, + font_ref, + char_map, + outline_glyphs, + color_glyphs, + mutex: Mutex::new(()), + serial: u32::MAX, + x_size: Size::new(0.0), + y_size: Size::new(0.0), + location: Location::default(), + x_glyph_metrics: None, + y_glyph_metrics: None, + }; + + data.check_for_updates(); + + data + } + + unsafe fn _check_for_updates(&mut self) { + let font_serial = hb_font_get_serial(self.font); + if self.serial == font_serial { + return; + } + + let _lock = self.mutex.lock().unwrap(); + let mut x_scale: i32 = 0; let mut y_scale: i32 = 0; - hb_font_get_scale(font, &mut x_scale, &mut y_scale); - let x_size = Size::new(x_scale as f32); - let y_size = Size::new(y_scale as f32); + hb_font_get_scale(self.font, &mut x_scale, &mut y_scale); + self.x_size = Size::new(x_scale as f32); + self.y_size = Size::new(y_scale as f32); let mut num_coords: u32 = 0; - let coords = hb_font_get_var_coords_normalized(font, &mut num_coords); + let coords = hb_font_get_var_coords_normalized(self.font, &mut num_coords); let coords = if coords.is_null() { &[] } else { @@ -67,7 +134,7 @@ impl FontationsData<'_> { // otherwise, use the provided coords. // This currently doesn't seem to have a perf effect on fontations, but it's a good idea to // check if the coords are all zeros before creating a Location. - let location = if all_zeros { + self.location = if all_zeros { Location::default() } else { let mut location = Location::new(num_coords as usize); @@ -79,29 +146,15 @@ impl FontationsData<'_> { location }; - let outline_glyphs = font_ref.outline_glyphs(); + let location = transmute::<&Location, &Location>(&self.location); + self.x_glyph_metrics = Some(self.font_ref.glyph_metrics(self.x_size, location)); + let location = transmute::<&Location, &Location>(&self.location); + self.y_glyph_metrics = Some(self.font_ref.glyph_metrics(self.y_size, location)); - let color_glyphs = font_ref.color_glyphs(); - - let mut data = FontationsData { - face_blob, - font_ref, - char_map, - x_size, - y_size, - location, - x_glyph_metrics: None, - y_glyph_metrics: None, - outline_glyphs, - color_glyphs, - }; - // transmute location - let location = transmute::<&Location, &Location>(&data.location); - data.x_glyph_metrics = Some(data.font_ref.glyph_metrics(data.x_size, location)); - let location = transmute::<&Location, &Location>(&data.location); - data.y_glyph_metrics = Some(data.font_ref.glyph_metrics(data.y_size, location)); - - data + self.serial = font_serial; + } + fn check_for_updates(&mut self) { + unsafe { self._check_for_updates() } } } @@ -175,7 +228,9 @@ extern "C" fn _hb_fontations_get_glyph_h_advances( advance_stride: ::std::os::raw::c_uint, _user_data: *mut ::std::os::raw::c_void, ) { - let data = unsafe { &*(font_data as *const FontationsData) }; + let data = unsafe { &mut *(font_data as *mut FontationsData) }; + data.check_for_updates(); + let glyph_metrics = &data.y_glyph_metrics.as_ref().unwrap(); for i in 0..count { @@ -195,7 +250,9 @@ extern "C" fn _hb_fontations_get_glyph_extents( extents: *mut hb_glyph_extents_t, _user_data: *mut ::std::os::raw::c_void, ) -> hb_bool_t { - let data = unsafe { &*(font_data as *const FontationsData) }; + let data = unsafe { &mut *(font_data as *mut FontationsData) }; + data.check_for_updates(); + let x_size = &data.x_size; let y_size = &data.y_size; let x_glyph_metrics = &data.x_glyph_metrics.as_ref().unwrap(); @@ -230,7 +287,9 @@ extern "C" fn _hb_fontations_get_font_h_extents( extents: *mut hb_font_extents_t, _user_data: *mut ::std::os::raw::c_void, ) -> hb_bool_t { - let data = unsafe { &*(font_data as *const FontationsData) }; + let data = unsafe { &mut *(font_data as *mut FontationsData) }; + data.check_for_updates(); + let font_ref = &data.font_ref; let size = &data.y_size; let location = &data.location; @@ -305,7 +364,9 @@ extern "C" fn _hb_fontations_draw_glyph( draw_data: *mut ::std::os::raw::c_void, _user_data: *mut ::std::os::raw::c_void, ) { - let data = unsafe { &*(font_data as *const FontationsData) }; + let data = unsafe { &mut *(font_data as *mut FontationsData) }; + data.check_for_updates(); + let x_size = &data.x_size; let location = &data.location; let outline_glyphs = &data.outline_glyphs; @@ -688,7 +749,9 @@ extern "C" fn _hb_fontations_paint_glyph( foreground: hb_color_t, _user_data: *mut ::std::os::raw::c_void, ) { - let data = unsafe { &*(font_data as *const FontationsData) }; + let data = unsafe { &mut *(font_data as *mut FontationsData) }; + data.check_for_updates(); + let font_ref = &data.font_ref; let location = &data.location; let color_glyphs = &data.color_glyphs; diff --git a/src/fontations/meson.build b/src/fontations/meson.build index d21b9af4c..7f26f3570 100644 --- a/src/fontations/meson.build +++ b/src/fontations/meson.build @@ -50,7 +50,7 @@ harfbuzz_fontations = custom_target( ) harfbuzz_fontations_dep = declare_dependency( - link_whole: harfbuzz_fontations, + link_with: harfbuzz_fontations, ) clippy_fix = run_target( diff --git a/src/gen-ragel-artifacts.py b/src/gen-ragel-artifacts.py index 8bbb375bf..84bd7b22e 100755 --- a/src/gen-ragel-artifacts.py +++ b/src/gen-ragel-artifacts.py @@ -19,7 +19,9 @@ outdir = os.path.dirname (OUTPUT) shutil.copy (INPUT, outdir) rl = os.path.basename (INPUT) hh = rl.replace ('.rl', '.hh') -subprocess.Popen (ragel.split() + ['-e', '-F1', '-o', hh, rl], cwd=outdir).wait () +ret = subprocess.Popen (ragel.split() + ['-e', '-F1', '-o', hh, rl], cwd=outdir).wait () +if ret: + sys.exit (ret) # copy it also to src/ shutil.copyfile (os.path.join (outdir, hh), os.path.join (CURRENT_SOURCE_DIR, hh)) diff --git a/src/harfbuzz.cc b/src/harfbuzz.cc index 1d31a2ddc..e6b5f378c 100644 --- a/src/harfbuzz.cc +++ b/src/harfbuzz.cc @@ -9,6 +9,7 @@ #include "hb-common.cc" #include "hb-coretext-font.cc" #include "hb-coretext-shape.cc" +#include "hb-coretext.cc" #include "hb-directwrite.cc" #include "hb-draw.cc" #include "hb-face-builder.cc" diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index e2ac53f6f..fa34afaa7 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -119,10 +119,7 @@ struct hb_aat_apply_context_t : for (unsigned int i = 0; i < count; i++) { if (glyphs[i] == DELETED_GLYPH) - { - buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES; - _hb_glyph_info_set_default_ignorable (&buffer->cur()); - } + _hb_glyph_info_set_aat_deleted (&buffer->cur()); else { buffer_glyph_set.add (glyphs[i]); @@ -153,8 +150,7 @@ struct hb_aat_apply_context_t : HB_NODISCARD bool delete_glyph () { - buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES; - _hb_glyph_info_set_default_ignorable (&buffer->cur()); + _hb_glyph_info_set_aat_deleted (&buffer->cur()); return buffer->replace_glyph (DELETED_GLYPH); } diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index c984da447..16076c6f5 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -324,8 +324,7 @@ hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan, static bool is_deleted_glyph (const hb_glyph_info_t *info) { - return info->codepoint == AAT::DELETED_GLYPH && - _hb_glyph_info_is_default_ignorable (info); + return _hb_glyph_info_is_aat_deleted (info); } void diff --git a/src/hb-buffer-deserialize-json.hh b/src/hb-buffer-deserialize-json.hh index 471bbb93f..aed094ac3 100644 --- a/src/hb-buffer-deserialize-json.hh +++ b/src/hb-buffer-deserialize-json.hh @@ -32,44 +32,81 @@ #include "hb.hh" -#line 36 "hb-buffer-deserialize-json.hh" +#line 33 "hb-buffer-deserialize-json.hh" static const unsigned char _deserialize_json_trans_keys[] = { - 0u, 0u, 9u, 123u, 9u, 123u, 9u, 34u, 97u, 117u, 120u, 121u, 34u, 34u, 9u, 58u, - 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, - 48u, 57u, 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, - 9u, 125u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, - 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, - 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 34u, 92u, - 9u, 125u, 34u, 92u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, - 9u, 93u, 9u, 123u, 0u, 0u, 0 + 0u, 0u, 9u, 34u, 97u, 117u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, + 9u, 125u, 9u, 125u, 9u, 93u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, + 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u, + 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, + 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, + 9u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 34u, 92u, 9u, 125u, + 34u, 92u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 123u, + 9u, 123u, 9u, 123u, 0 }; static const char _deserialize_json_key_spans[] = { - 0, 115, 115, 26, 21, 2, 1, 50, - 49, 10, 117, 117, 117, 1, 50, 49, - 10, 117, 117, 1, 1, 50, 49, 117, - 117, 2, 1, 50, 49, 10, 117, 117, - 1, 50, 49, 10, 117, 117, 1, 1, - 50, 49, 117, 117, 1, 50, 49, 59, - 117, 59, 117, 117, 1, 50, 49, 117, - 85, 115, 0 + 0, 26, 21, 2, 1, 50, 49, 10, + 117, 117, 85, 117, 1, 50, 49, 10, + 117, 117, 1, 1, 50, 49, 117, 117, + 2, 1, 50, 49, 10, 117, 117, 1, + 50, 49, 10, 117, 117, 1, 1, 50, + 49, 117, 117, 1, 50, 49, 59, 117, + 59, 117, 117, 1, 50, 49, 117, 115, + 115, 115 }; static const short _deserialize_json_index_offsets[] = { - 0, 0, 116, 232, 259, 281, 284, 286, - 337, 387, 398, 516, 634, 752, 754, 805, - 855, 866, 984, 1102, 1104, 1106, 1157, 1207, - 1325, 1443, 1446, 1448, 1499, 1549, 1560, 1678, - 1796, 1798, 1849, 1899, 1910, 2028, 2146, 2148, - 2150, 2201, 2251, 2369, 2487, 2489, 2540, 2590, - 2650, 2768, 2828, 2946, 3064, 3066, 3117, 3167, - 3285, 3371, 3487 + 0, 0, 27, 49, 52, 54, 105, 155, + 166, 284, 402, 488, 606, 608, 659, 709, + 720, 838, 956, 958, 960, 1011, 1061, 1179, + 1297, 1300, 1302, 1353, 1403, 1414, 1532, 1650, + 1652, 1703, 1753, 1764, 1882, 2000, 2002, 2004, + 2055, 2105, 2223, 2341, 2343, 2394, 2444, 2504, + 2622, 2682, 2800, 2918, 2920, 2971, 3021, 3139, + 3255, 3371 }; static const char _deserialize_json_indicies[] = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 2, 1, 3, 1, 4, 5, + 1, 6, 7, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 8, 1, 9, 10, 1, 11, 1, 11, + 11, 11, 11, 11, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 11, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 12, 1, 12, 12, 12, 12, 12, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 12, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 13, 1, + 1, 14, 15, 15, 15, 15, 15, 15, + 15, 15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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 27, 1, 27, 27, - 27, 27, 27, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 27, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 28, 1, 1, 29, 30, 30, - 30, 30, 30, 30, 30, 30, 30, 1, - 31, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 1, 33, 33, 33, 33, 33, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 33, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 34, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 20, 1, 24, + 1, 24, 24, 24, 24, 24, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 24, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 25, 1, 25, 25, 25, 25, + 25, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 25, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 26, 1, 1, 27, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 1, 29, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 1, 31, 31, 31, 31, 31, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 31, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -189,14 +171,13 @@ static const char _deserialize_json_indicies[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 35, - 1, 33, 33, 33, 33, 33, 1, 1, + 1, 1, 1, 1, 1, 33, 1, 31, + 31, 31, 31, 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 31, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 33, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 34, 1, 1, 1, - 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 1, 1, 1, 1, 1, 1, + 1, 1, 32, 1, 1, 1, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -204,25 +185,26 @@ static const char _deserialize_json_indicies[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 35, 1, 36, - 1, 37, 1, 37, 37, 37, 37, 37, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 33, 1, 34, 1, 35, + 1, 35, 35, 35, 35, 35, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 37, 1, 1, 1, 1, 1, + 35, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 38, 1, 38, 38, - 38, 38, 38, 1, 1, 1, 1, 1, + 1, 1, 36, 1, 36, 36, 36, 36, + 36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 38, 1, 1, + 1, 1, 1, 36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 39, 40, 40, - 40, 40, 40, 40, 40, 40, 40, 1, - 41, 41, 41, 41, 41, 1, 1, 1, + 1, 1, 1, 37, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 1, 39, 39, + 39, 39, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 41, + 1, 1, 1, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 42, 1, 1, 1, 1, + 1, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -232,13 +214,13 @@ static const char _deserialize_json_indicies[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 43, 1, 41, 41, - 41, 41, 41, 1, 1, 1, 1, 1, + 1, 1, 41, 1, 39, 39, 39, 39, + 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 41, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 42, 1, 1, 1, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 1, + 1, 1, 1, 39, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 40, + 1, 1, 1, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -247,229 +229,201 @@ static const char _deserialize_json_indicies[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 43, 1, 45, 46, 1, 47, - 1, 47, 47, 47, 47, 47, 1, 1, + 41, 1, 43, 44, 1, 45, 1, 45, + 45, 45, 45, 45, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 47, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 46, 1, 46, 46, 46, 46, 46, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 48, 1, 48, 48, 48, 48, - 48, 1, 1, 1, 1, 1, 1, 1, + 1, 46, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 47, 1, + 1, 48, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 1, 50, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 1, 52, + 52, 52, 52, 52, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 48, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 52, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 49, 1, 1, 50, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 1, 52, 53, - 53, 53, 53, 53, 53, 53, 53, 53, - 1, 54, 54, 54, 54, 54, 1, 1, + 1, 1, 53, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 54, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 54, 1, 52, 52, 52, + 52, 52, 1, 1, 1, 1, 1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 55, 1, 1, 1, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 64, 1, 62, 62, 62, 62, 62, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 62, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 63, 1, + 1, 1, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 56, 1, 57, 1, 57, - 57, 57, 57, 57, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 57, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 58, 1, 58, 58, 58, 58, 58, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 64, + 1, 65, 1, 66, 1, 66, 66, 66, + 66, 66, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 58, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 59, 1, - 1, 60, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 1, 62, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 1, 64, - 64, 64, 64, 64, 1, 1, 1, 1, + 1, 1, 1, 1, 66, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 64, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 65, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 67, 1, + 67, 67, 67, 67, 67, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 74, 1, + 74, 74, 74, 74, 74, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 69, 1, 69, 69, 69, 69, 69, 1, + 1, 1, 1, 1, 1, 1, 1, 74, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 69, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 70, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 1, 72, 72, 72, 72, - 72, 1, 1, 1, 1, 1, 1, 1, + 1, 75, 1, 75, 75, 75, 75, 75, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 72, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 73, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 75, 1, 76, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 77, 78, 78, 78, 78, 78, + 78, 78, 78, 78, 1, 80, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 81, + 79, 82, 82, 82, 82, 82, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 82, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 83, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 74, 1, 72, 72, 72, 72, 72, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 72, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 73, 1, 1, - 1, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 84, 1, 79, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 74, 1, - 76, 1, 76, 76, 76, 76, 76, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 79, 1, 85, 85, 85, 85, 85, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 76, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 85, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 86, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 77, 1, 77, 77, 77, - 77, 77, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 77, 1, 78, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 79, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 1, 82, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, - 81, 83, 81, 84, 84, 84, 84, 84, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 84, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 85, 1, 1, 1, 1, 1, 1, 1, 1, 1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 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 89, - 1, 91, 1, 91, 91, 91, 91, 91, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 91, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 92, 1, 92, 92, - 92, 92, 92, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 92, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 93, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 1, - 87, 87, 87, 87, 87, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 87, + 1, 85, 85, 85, 85, 85, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 88, 1, 1, 1, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 85, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 86, 1, 1, 1, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -477,21 +431,52 @@ static const char _deserialize_json_indicies[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 89, 1, 96, 96, - 96, 96, 96, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 87, 1, 89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, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 95, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 96, 1, + 95, 95, 95, 95, 95, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 95, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -502,47 +487,62 @@ static const char _deserialize_json_indicies[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, - 1, 0 + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 96, 1, 23, 23, 23, 23, + 23, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 23, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 96, 1, + 0 }; static const char _deserialize_json_trans_targs[] = { - 1, 0, 2, 3, 3, 4, 5, 19, - 25, 38, 44, 52, 6, 13, 7, 8, - 9, 10, 12, 10, 12, 11, 3, 56, - 11, 56, 14, 15, 16, 17, 18, 17, - 18, 11, 3, 56, 20, 21, 22, 23, - 24, 11, 3, 56, 24, 26, 32, 27, - 28, 29, 30, 31, 30, 31, 11, 3, - 56, 33, 34, 35, 36, 37, 36, 37, - 11, 3, 56, 39, 40, 41, 42, 43, - 11, 3, 56, 43, 45, 46, 47, 50, - 51, 47, 48, 49, 11, 3, 56, 11, - 3, 56, 51, 53, 54, 50, 55, 55, - 56, 57, 58 + 1, 0, 2, 3, 18, 24, 37, 43, + 51, 4, 12, 5, 6, 7, 8, 11, + 8, 11, 9, 1, 10, 9, 10, 57, + 13, 14, 15, 16, 17, 16, 17, 9, + 1, 10, 19, 20, 21, 22, 23, 9, + 1, 10, 23, 25, 31, 26, 27, 28, + 29, 30, 29, 30, 9, 1, 10, 32, + 33, 34, 35, 36, 35, 36, 9, 1, + 10, 38, 39, 40, 41, 42, 9, 1, + 10, 42, 44, 45, 46, 49, 50, 46, + 47, 48, 9, 1, 10, 9, 1, 10, + 50, 52, 53, 49, 54, 54, 55, 56, + 1 }; static const char _deserialize_json_trans_actions[] = { - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 0, 0, 3, 3, 4, - 0, 5, 0, 0, 2, 2, 2, 0, - 0, 6, 6, 7, 0, 0, 0, 2, - 2, 8, 8, 9, 0, 0, 0, 0, - 0, 2, 2, 2, 0, 0, 10, 10, - 11, 0, 0, 2, 2, 2, 0, 0, - 12, 12, 13, 0, 0, 0, 2, 2, - 14, 14, 15, 0, 0, 0, 2, 16, - 16, 0, 17, 0, 18, 18, 19, 20, - 20, 21, 17, 0, 0, 22, 22, 23, - 0, 0, 0 + 0, 0, 0, 0, 0, 1, 1, 1, + 0, 0, 2, 2, 2, 0, 0, 3, + 0, 0, 1, 1, 1, 0, 0, 4, + 4, 4, 0, 0, 0, 1, 1, 5, + 5, 5, 0, 0, 0, 0, 0, 1, + 1, 1, 0, 0, 6, 6, 6, 0, + 0, 1, 1, 1, 0, 0, 7, 7, + 7, 0, 0, 0, 1, 1, 8, 8, + 8, 0, 0, 0, 1, 9, 9, 0, + 10, 0, 11, 11, 11, 12, 12, 12, + 10, 0, 0, 13, 13, 14, 0, 0, + 15 }; -static const int deserialize_json_start = 1; -static const int deserialize_json_first_final = 56; +static const int deserialize_json_start = 55; +static const int deserialize_json_first_final = 55; static const int deserialize_json_error = 0; -static const int deserialize_json_en_main = 1; +static const int deserialize_json_en_main = 55; #line 111 "hb-buffer-deserialize-json.rl" @@ -565,12 +565,12 @@ _hb_buffer_deserialize_json (hb_buffer_t *buffer, hb_glyph_info_t info = {0}; hb_glyph_position_t pos = {0}; -#line 569 "hb-buffer-deserialize-json.hh" +#line 562 "hb-buffer-deserialize-json.hh" { cs = deserialize_json_start; } -#line 574 "hb-buffer-deserialize-json.hh" +#line 565 "hb-buffer-deserialize-json.hh" { int _slen; int _trans; @@ -595,14 +595,14 @@ _resume: goto _again; switch ( _deserialize_json_trans_actions[_trans] ) { - case 1: + case 15: #line 38 "hb-buffer-deserialize-json.rl" { hb_memset (&info, 0, sizeof (info)); hb_memset (&pos , 0, sizeof (pos )); } break; - case 5: + case 3: #line 43 "hb-buffer-deserialize-json.rl" { buffer->add_info (info); @@ -612,75 +612,21 @@ _resume: *end_ptr = p; } break; - case 2: + case 1: #line 51 "hb-buffer-deserialize-json.rl" { tok = p; } - break; - case 17: -#line 55 "hb-buffer-deserialize-json.rl" - { if (unlikely (!buffer->ensure_glyphs ())) return false; } - break; - case 23: -#line 56 "hb-buffer-deserialize-json.rl" - { if (unlikely (!buffer->ensure_unicode ())) return false; } - break; - case 18: -#line 58 "hb-buffer-deserialize-json.rl" - { - /* TODO Unescape \" and \\ if found. */ - if (!hb_font_glyph_from_string (font, - tok+1, p - tok - 2, /* Skip "" */ - &info.codepoint)) - return false; -} - break; - case 20: -#line 66 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.codepoint)) return false; } - break; - case 8: -#line 67 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } break; case 10: -#line 68 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_offset )) return false; } - break; - case 12: -#line 69 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } - break; - case 3: -#line 70 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } - break; - case 6: -#line 71 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } - break; - case 14: -#line 72 "hb-buffer-deserialize-json.rl" - { if (!parse_uint (tok, p, &info.mask )) return false; } - break; - case 16: -#line 51 "hb-buffer-deserialize-json.rl" - { - tok = p; -} #line 55 "hb-buffer-deserialize-json.rl" { if (unlikely (!buffer->ensure_glyphs ())) return false; } break; - case 22: -#line 51 "hb-buffer-deserialize-json.rl" - { - tok = p; -} + case 14: #line 56 "hb-buffer-deserialize-json.rl" { if (unlikely (!buffer->ensure_unicode ())) return false; } break; - case 19: + case 11: #line 58 "hb-buffer-deserialize-json.rl" { /* TODO Unescape \" and \\ if found. */ @@ -688,101 +634,53 @@ _resume: tok+1, p - tok - 2, /* Skip "" */ &info.codepoint)) return false; -} -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; } break; - case 21: + case 12: #line 66 "hb-buffer-deserialize-json.rl" { if (!parse_uint (tok, p, &info.codepoint)) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} break; - case 9: + case 5: #line 67 "hb-buffer-deserialize-json.rl" { if (!parse_uint (tok, p, &info.cluster )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} break; - case 11: + case 6: #line 68 "hb-buffer-deserialize-json.rl" { if (!parse_int (tok, p, &pos.x_offset )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 13: -#line 69 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 4: -#line 70 "hb-buffer-deserialize-json.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} break; case 7: +#line 69 "hb-buffer-deserialize-json.rl" + { if (!parse_int (tok, p, &pos.y_offset )) return false; } + break; + case 2: +#line 70 "hb-buffer-deserialize-json.rl" + { if (!parse_int (tok, p, &pos.x_advance)) return false; } + break; + case 4: #line 71 "hb-buffer-deserialize-json.rl" { if (!parse_int (tok, p, &pos.y_advance)) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} break; - case 15: + case 8: #line 72 "hb-buffer-deserialize-json.rl" { if (!parse_uint (tok, p, &info.mask )) return false; } -#line 43 "hb-buffer-deserialize-json.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} break; -#line 786 "hb-buffer-deserialize-json.hh" + case 9: +#line 51 "hb-buffer-deserialize-json.rl" + { + tok = p; +} +#line 55 "hb-buffer-deserialize-json.rl" + { if (unlikely (!buffer->ensure_glyphs ())) return false; } + break; + case 13: +#line 51 "hb-buffer-deserialize-json.rl" + { + tok = p; +} +#line 56 "hb-buffer-deserialize-json.rl" + { if (unlikely (!buffer->ensure_unicode ())) return false; } + break; +#line 657 "hb-buffer-deserialize-json.hh" } _again: @@ -799,7 +697,7 @@ _again: *end_ptr = p; - return p == pe && *(p-1) != ']'; + return p == pe; } #endif /* HB_BUFFER_DESERIALIZE_JSON_HH */ diff --git a/src/hb-buffer-deserialize-json.rl b/src/hb-buffer-deserialize-json.rl index 2f1ad9118..eb092bfe9 100644 --- a/src/hb-buffer-deserialize-json.rl +++ b/src/hb-buffer-deserialize-json.rl @@ -101,12 +101,12 @@ element = glyph @ensure_glyphs | yadvance | glyphflags; item = - ( '{' space* element (comma element)* space* '}') + ( '{' space* element (comma element)* space* '}' space* (','|']') space* ) >clear_item @add_item ; -main := space* '['? space* item (comma item)* space* (','|']')?; +main := space* '['? space* item*; }%% @@ -133,7 +133,7 @@ _hb_buffer_deserialize_json (hb_buffer_t *buffer, *end_ptr = p; - return p == pe && *(p-1) != ']'; + return p == pe; } #endif /* HB_BUFFER_DESERIALIZE_JSON_HH */ diff --git a/src/hb-buffer-deserialize-text-glyphs.hh b/src/hb-buffer-deserialize-text-glyphs.hh index ea81273b3..a268def5d 100644 --- a/src/hb-buffer-deserialize-text-glyphs.hh +++ b/src/hb-buffer-deserialize-text-glyphs.hh @@ -32,287 +32,249 @@ #include "hb.hh" -#line 36 "hb-buffer-deserialize-text-glyphs.hh" +#line 33 "hb-buffer-deserialize-text-glyphs.hh" static const unsigned char _deserialize_text_glyphs_trans_keys[] = { - 0u, 0u, 48u, 57u, 45u, 57u, 48u, 57u, 45u, 57u, 48u, 57u, 48u, 57u, 45u, 57u, - 48u, 57u, 44u, 44u, 45u, 57u, 48u, 57u, 44u, 57u, 43u, 124u, 9u, 124u, 9u, 124u, - 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, 9u, 124u, - 9u, 124u, 9u, 124u, 9u, 124u, 0 + 0u, 0u, 35u, 124u, 48u, 57u, 93u, 124u, 45u, 57u, 48u, 57u, 35u, 124u, 45u, 57u, + 48u, 57u, 35u, 124u, 35u, 124u, 35u, 124u, 48u, 57u, 35u, 124u, 45u, 57u, 48u, 57u, + 44u, 44u, 45u, 57u, 48u, 57u, 35u, 124u, 35u, 124u, 44u, 57u, 35u, 124u, 43u, 124u, + 48u, 124u, 35u, 124u, 35u, 124u, 35u, 124u, 0 }; static const char _deserialize_text_glyphs_key_spans[] = { - 0, 10, 13, 10, 13, 10, 10, 13, - 10, 1, 13, 10, 14, 82, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116 + 0, 90, 10, 32, 13, 10, 90, 13, + 10, 90, 90, 90, 10, 90, 13, 10, + 1, 13, 10, 90, 90, 14, 90, 82, + 77, 90, 90, 90 }; static const short _deserialize_text_glyphs_index_offsets[] = { - 0, 0, 11, 25, 36, 50, 61, 72, - 86, 97, 99, 113, 124, 139, 222, 339, - 456, 573, 690, 807, 924, 1041, 1158, 1275, - 1392, 1509, 1626 + 0, 0, 91, 102, 135, 149, 160, 251, + 265, 276, 367, 458, 549, 560, 651, 665, + 676, 678, 692, 703, 794, 885, 900, 991, + 1074, 1152, 1243, 1334 }; static const char _deserialize_text_glyphs_indicies[] = { - 0, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 1, 3, 1, 1, 4, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 1, 6, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 1, 8, 1, 1, - 9, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 1, 11, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 1, 13, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 1, 15, 1, 1, 16, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 1, 18, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 1, 20, 1, 21, 1, 1, 22, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 1, 24, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 1, 20, 1, 1, - 1, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 1, 26, 26, 1, 1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 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 18, 3, 19, 3, 3, 20, + 21, 21, 21, 21, 21, 21, 21, 21, + 21, 3, 22, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 3, 24, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 25, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 25, 3, + 24, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 25, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 25, 3, 16, 3, 3, 3, 3, + 3, 3, 3, 3, 17, 3, 3, 3, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 18, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 18, 3, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 28, 27, - 27, 29, 27, 27, 27, 27, 27, 27, - 27, 30, 1, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 31, 27, 27, 32, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 33, 1, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 28, 27, 34, 34, 34, 34, - 34, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 34, 26, 26, 35, 26, - 26, 26, 26, 26, 26, 26, 36, 1, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 37, 26, 26, 38, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 39, - 1, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 40, - 26, 41, 41, 41, 41, 41, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 41, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 42, 1, 43, 43,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 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 61, 1, 53, 53, 53, 53, 53, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 53, 1, 1, 54, 1, 1, - 1, 1, 1, 1, 1, 55, 1, 1, - 1, 1, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 1, 1, 1, 1, - 1, 1, 56, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 57, 1, - 0 + 3, 28, 3, 3, 3, 3, 3, 3, + 3, 29, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 30, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 31, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 31, 3, 32, 3, 3, 33, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 3, 35, 36, 36, 36, 36, 36, + 36, 36, 36, 36, 3, 37, 3, 38, + 3, 3, 39, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 3, 41, 42, 42, + 42, 42, 42, 42, 42, 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 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 0, 0, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 0, 3, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 10, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 10, + 3, 49, 48, 48, 48, 48, 48, 48, + 48, 50, 3, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 51, 48, 48, 52, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 53, 54, 55, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 55, 48, 57, 56, 56, 56, + 56, 56, 56, 56, 58, 3, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 59, 56, + 56, 60, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 61, 62, 56, + 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 62, 56, 63, + 48, 48, 48, 48, 48, 48, 48, 64, + 3, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 65, 48, 48, 66, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 54, 67, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 67, 48, 0 }; static const char _deserialize_text_glyphs_trans_targs[] = { - 16, 0, 18, 3, 19, 22, 19, 22, - 5, 20, 21, 20, 21, 23, 26, 8, - 9, 12, 9, 12, 10, 11, 24, 25, - 24, 25, 15, 15, 14, 1, 2, 6, - 7, 13, 15, 1, 2, 6, 7, 13, - 14, 17, 14, 17, 14, 18, 17, 1, - 4, 14, 17, 1, 14, 17, 1, 2, - 7, 14, 17, 1, 2, 14, 26 + 1, 2, 4, 0, 12, 14, 23, 26, + 3, 24, 26, 5, 6, 11, 6, 11, + 2, 7, 26, 8, 9, 10, 9, 10, + 2, 26, 13, 22, 2, 4, 14, 26, + 15, 16, 21, 16, 21, 17, 18, 19, + 20, 19, 20, 2, 4, 26, 22, 24, + 1, 2, 4, 12, 14, 27, 23, 26, + 1, 2, 4, 12, 14, 23, 26, 2, + 4, 12, 14, 26 }; static const char _deserialize_text_glyphs_trans_actions[] = { - 1, 0, 1, 1, 1, 1, 0, 0, - 1, 1, 1, 0, 0, 1, 1, 1, - 1, 1, 0, 0, 2, 1, 1, 1, - 0, 0, 0, 4, 3, 5, 5, 5, - 5, 4, 6, 7, 7, 7, 7, 0, - 6, 8, 8, 0, 0, 0, 9, 10, - 10, 9, 11, 12, 11, 13, 14, 14, - 14, 13, 15, 16, 16, 15, 0 + 0, 1, 1, 0, 1, 1, 0, 1, + 2, 2, 3, 2, 2, 2, 0, 0, + 4, 4, 4, 2, 2, 2, 0, 0, + 5, 5, 2, 2, 6, 6, 6, 6, + 2, 2, 2, 0, 0, 7, 2, 2, + 2, 0, 0, 8, 8, 8, 0, 0, + 9, 10, 10, 10, 10, 9, 9, 10, + 12, 13, 13, 13, 13, 12, 13, 14, + 14, 14, 14, 14 }; static const char _deserialize_text_glyphs_eof_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 6, - 8, 0, 8, 9, 11, 11, 9, 13, - 15, 15, 13 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 11, 0 }; -static const int deserialize_text_glyphs_start = 14; -static const int deserialize_text_glyphs_first_final = 14; +static const int deserialize_text_glyphs_start = 25; +static const int deserialize_text_glyphs_first_final = 25; static const int deserialize_text_glyphs_error = 0; -static const int deserialize_text_glyphs_en_main = 14; +static const int deserialize_text_glyphs_en_main = 25; -#line 98 "hb-buffer-deserialize-text-glyphs.rl" +#line 99 "hb-buffer-deserialize-text-glyphs.rl" static hb_bool_t @@ -322,39 +284,22 @@ _hb_buffer_deserialize_text_glyphs (hb_buffer_t *buffer, const char **end_ptr, hb_font_t *font) { - const char *p = buf, *pe = buf + buf_len, *eof = pe, *orig_pe = pe; + const char *p = buf, *pe = buf + buf_len, *eof = pe; /* Ensure we have positions. */ (void) hb_buffer_get_glyph_positions (buffer, nullptr); - while (p < pe && ISSPACE (*p)) - p++; - if (p < pe && *p == (buffer->len ? '|' : '[')) - *end_ptr = ++p; - - const char *end = strchr ((char *) p, ']'); - if (end) - pe = eof = end; - else - { - end = strrchr ((char *) p, '|'); - if (end) - pe = eof = end; - else - pe = eof = p; - } - const char *tok = nullptr; int cs; hb_glyph_info_t info = {0}; hb_glyph_position_t pos = {0}; -#line 353 "hb-buffer-deserialize-text-glyphs.hh" +#line 291 "hb-buffer-deserialize-text-glyphs.hh" { cs = deserialize_text_glyphs_start; } -#line 358 "hb-buffer-deserialize-text-glyphs.hh" +#line 294 "hb-buffer-deserialize-text-glyphs.hh" { int _slen; int _trans; @@ -379,13 +324,13 @@ _resume: goto _again; switch ( _deserialize_text_glyphs_trans_actions[_trans] ) { - case 1: + case 2: #line 51 "hb-buffer-deserialize-text-glyphs.rl" { tok = p; } break; - case 7: + case 1: #line 55 "hb-buffer-deserialize-text-glyphs.rl" { /* TODO Unescape delimiters. */ @@ -393,40 +338,53 @@ _resume: tok, p - tok, &info.codepoint)) return false; -} - break; - case 14: -#line 63 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } - break; - case 2: -#line 64 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.x_offset )) return false; } - break; - case 16: -#line 65 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } - break; - case 10: -#line 66 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } - break; - case 12: -#line 67 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } - break; - case 4: -#line 38 "hb-buffer-deserialize-text-glyphs.rl" - { - hb_memset (&info, 0, sizeof (info)); - hb_memset (&pos , 0, sizeof (pos )); -} -#line 51 "hb-buffer-deserialize-text-glyphs.rl" - { - tok = p; } break; case 6: +#line 63 "hb-buffer-deserialize-text-glyphs.rl" + { if (!parse_uint (tok, p, &info.cluster )) return false; } + break; + case 7: +#line 64 "hb-buffer-deserialize-text-glyphs.rl" + { if (!parse_int (tok, p, &pos.x_offset )) return false; } + break; + case 8: +#line 65 "hb-buffer-deserialize-text-glyphs.rl" + { if (!parse_int (tok, p, &pos.y_offset )) return false; } + break; + case 4: +#line 66 "hb-buffer-deserialize-text-glyphs.rl" + { if (!parse_int (tok, p, &pos.x_advance)) return false; } + break; + case 5: +#line 67 "hb-buffer-deserialize-text-glyphs.rl" + { if (!parse_int (tok, p, &pos.y_advance)) return false; } + break; + case 3: +#line 68 "hb-buffer-deserialize-text-glyphs.rl" + { if (!parse_uint (tok, p, &info.mask )) return false; } + break; + case 9: +#line 38 "hb-buffer-deserialize-text-glyphs.rl" + { + hb_memset (&info, 0, sizeof (info)); + hb_memset (&pos , 0, sizeof (pos )); +} +#line 51 "hb-buffer-deserialize-text-glyphs.rl" + { + tok = p; +} + break; + case 10: +#line 38 "hb-buffer-deserialize-text-glyphs.rl" + { + hb_memset (&info, 0, sizeof (info)); + hb_memset (&pos , 0, sizeof (pos )); +} +#line 51 "hb-buffer-deserialize-text-glyphs.rl" + { + tok = p; +} #line 55 "hb-buffer-deserialize-text-glyphs.rl" { /* TODO Unescape delimiters. */ @@ -435,6 +393,8 @@ _resume: &info.codepoint)) return false; } + break; + case 12: #line 43 "hb-buffer-deserialize-text-glyphs.rl" { buffer->add_info (info); @@ -442,11 +402,37 @@ _resume: return false; buffer->pos[buffer->len - 1] = pos; *end_ptr = p; +} +#line 38 "hb-buffer-deserialize-text-glyphs.rl" + { + hb_memset (&info, 0, sizeof (info)); + hb_memset (&pos , 0, sizeof (pos )); +} +#line 51 "hb-buffer-deserialize-text-glyphs.rl" + { + tok = p; +} + break; + case 14: +#line 55 "hb-buffer-deserialize-text-glyphs.rl" + { + /* TODO Unescape delimiters. */ + if (!hb_font_glyph_from_string (font, + tok, p - tok, + &info.codepoint)) + return false; +} +#line 38 "hb-buffer-deserialize-text-glyphs.rl" + { + hb_memset (&info, 0, sizeof (info)); + hb_memset (&pos , 0, sizeof (pos )); +} +#line 51 "hb-buffer-deserialize-text-glyphs.rl" + { + tok = p; } break; case 13: -#line 63 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } #line 43 "hb-buffer-deserialize-text-glyphs.rl" { buffer->add_info (info); @@ -455,56 +441,6 @@ _resume: buffer->pos[buffer->len - 1] = pos; *end_ptr = p; } - break; - case 15: -#line 65 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 9: -#line 66 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 11: -#line 67 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 8: -#line 68 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_uint (tok, p, &info.mask )) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 5: #line 38 "hb-buffer-deserialize-text-glyphs.rl" { hb_memset (&info, 0, sizeof (info)); @@ -523,34 +459,7 @@ _resume: return false; } break; - case 3: -#line 38 "hb-buffer-deserialize-text-glyphs.rl" - { - hb_memset (&info, 0, sizeof (info)); - hb_memset (&pos , 0, sizeof (pos )); -} -#line 51 "hb-buffer-deserialize-text-glyphs.rl" - { - tok = p; -} -#line 55 "hb-buffer-deserialize-text-glyphs.rl" - { - /* TODO Unescape delimiters. */ - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; -#line 554 "hb-buffer-deserialize-text-glyphs.hh" +#line 430 "hb-buffer-deserialize-text-glyphs.hh" } _again: @@ -562,63 +471,7 @@ _again: if ( p == eof ) { switch ( _deserialize_text_glyphs_eof_actions[cs] ) { - case 6: -#line 55 "hb-buffer-deserialize-text-glyphs.rl" - { - /* TODO Unescape delimiters. */ - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 13: -#line 63 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 15: -#line 65 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.y_offset )) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 9: -#line 66 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.x_advance)) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; case 11: -#line 67 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_int (tok, p, &pos.y_advance)) return false; } #line 43 "hb-buffer-deserialize-text-glyphs.rl" { buffer->add_info (info); @@ -628,62 +481,16 @@ _again: *end_ptr = p; } break; - case 8: -#line 68 "hb-buffer-deserialize-text-glyphs.rl" - { if (!parse_uint (tok, p, &info.mask )) return false; } -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 3: -#line 38 "hb-buffer-deserialize-text-glyphs.rl" - { - hb_memset (&info, 0, sizeof (info)); - hb_memset (&pos , 0, sizeof (pos )); -} -#line 51 "hb-buffer-deserialize-text-glyphs.rl" - { - tok = p; -} -#line 55 "hb-buffer-deserialize-text-glyphs.rl" - { - /* TODO Unescape delimiters. */ - if (!hb_font_glyph_from_string (font, - tok, p - tok, - &info.codepoint)) - return false; -} -#line 43 "hb-buffer-deserialize-text-glyphs.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; -#line 671 "hb-buffer-deserialize-text-glyphs.hh" +#line 450 "hb-buffer-deserialize-text-glyphs.hh" } } _out: {} } -#line 136 "hb-buffer-deserialize-text-glyphs.rl" +#line 120 "hb-buffer-deserialize-text-glyphs.rl" - if (pe < orig_pe && *pe == ']') - { - pe++; - if (p == pe) - p++; - } - *end_ptr = p; return p == pe; diff --git a/src/hb-buffer-deserialize-text-glyphs.rl b/src/hb-buffer-deserialize-text-glyphs.rl index 21db14b56..8efedb8d3 100644 --- a/src/hb-buffer-deserialize-text-glyphs.rl +++ b/src/hb-buffer-deserialize-text-glyphs.rl @@ -86,14 +86,15 @@ glyph_item = offsets? advances? glyphflags? + ( '|' | ']') ) >clear_item %add_item ; -glyphs = glyph_item (space* '|' space* glyph_item)* space*; +glyphs = '['? glyph_item* ; -main := space* glyphs; +main := glyphs; }%% @@ -104,28 +105,11 @@ _hb_buffer_deserialize_text_glyphs (hb_buffer_t *buffer, const char **end_ptr, hb_font_t *font) { - const char *p = buf, *pe = buf + buf_len, *eof = pe, *orig_pe = pe; + const char *p = buf, *pe = buf + buf_len, *eof = pe; /* Ensure we have positions. */ (void) hb_buffer_get_glyph_positions (buffer, nullptr); - while (p < pe && ISSPACE (*p)) - p++; - if (p < pe && *p == (buffer->len ? '|' : '[')) - *end_ptr = ++p; - - const char *end = strchr ((char *) p, ']'); - if (end) - pe = eof = end; - else - { - end = strrchr ((char *) p, '|'); - if (end) - pe = eof = end; - else - pe = eof = p; - } - const char *tok = nullptr; int cs; hb_glyph_info_t info = {0}; @@ -135,13 +119,6 @@ _hb_buffer_deserialize_text_glyphs (hb_buffer_t *buffer, write exec; }%% - if (pe < orig_pe && *pe == ']') - { - pe++; - if (p == pe) - p++; - } - *end_ptr = p; return p == pe; diff --git a/src/hb-buffer-deserialize-text-unicode.hh b/src/hb-buffer-deserialize-text-unicode.hh index a8cdf67e7..0bb00c4c2 100644 --- a/src/hb-buffer-deserialize-text-unicode.hh +++ b/src/hb-buffer-deserialize-text-unicode.hh @@ -32,137 +32,108 @@ #include "hb.hh" -#line 36 "hb-buffer-deserialize-text-unicode.hh" +#line 33 "hb-buffer-deserialize-text-unicode.hh" static const unsigned char _deserialize_text_unicode_trans_keys[] = { - 0u, 0u, 9u, 117u, 43u, 102u, 48u, 102u, 48u, 57u, 9u, 124u, 9u, 124u, 9u, 124u, - 9u, 124u, 0 + 0u, 0u, 43u, 102u, 48u, 102u, 48u, 124u, 48u, 57u, 62u, 124u, 48u, 124u, 60u, 117u, + 85u, 117u, 85u, 117u, 0 }; static const char _deserialize_text_unicode_key_spans[] = { - 0, 109, 60, 55, 10, 116, 116, 116, - 116 + 0, 60, 55, 77, 10, 63, 77, 58, + 33, 33 }; static const short _deserialize_text_unicode_index_offsets[] = { - 0, 0, 110, 171, 227, 238, 355, 472, - 589 + 0, 0, 61, 117, 195, 206, 270, 348, + 407, 441 }; static const char _deserialize_text_unicode_indicies[] = { - 0, 0, 0, 0, 0, 1, 1, + 0, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 2, + 2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 0, - 1, 12, 12, 12, 12, 12, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 12, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 13, 1, 12, 12, - 12, 12, 12, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 12, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 13, 1, 0 + 1, 1, 12, 1, 0 }; static const char _deserialize_text_unicode_trans_targs[] = { - 1, 0, 2, 3, 5, 7, 8, 6, - 5, 4, 1, 6, 6, 1, 8 + 2, 0, 3, 3, 4, 9, 5, 6, + 9, 6, 8, 1, 1 }; static const char _deserialize_text_unicode_trans_actions[] = { - 0, 0, 1, 0, 2, 2, 2, 3, - 0, 4, 3, 0, 5, 5, 0 + 0, 0, 1, 0, 2, 2, 1, 1, + 3, 0, 0, 4, 6 }; static const char _deserialize_text_unicode_eof_actions[] = { - 0, 0, 0, 0, 0, 3, 0, 5, - 5 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5 }; -static const int deserialize_text_unicode_start = 1; -static const int deserialize_text_unicode_first_final = 5; +static const int deserialize_text_unicode_start = 7; +static const int deserialize_text_unicode_first_final = 7; static const int deserialize_text_unicode_error = 0; -static const int deserialize_text_unicode_en_main = 1; +static const int deserialize_text_unicode_en_main = 7; -#line 79 "hb-buffer-deserialize-text-unicode.rl" +#line 80 "hb-buffer-deserialize-text-unicode.rl" static hb_bool_t @@ -172,37 +143,19 @@ _hb_buffer_deserialize_text_unicode (hb_buffer_t *buffer, const char **end_ptr, hb_font_t *font) { - const char *p = buf, *pe = buf + buf_len, *eof = pe, *orig_pe = pe; - - while (p < pe && ISSPACE (*p)) - p++; - if (p < pe && *p == (buffer->len ? '|' : '<')) - *end_ptr = ++p; - - const char *end = strchr ((char *) p, '>'); - if (end) - pe = eof = end; - else - { - end = strrchr ((char *) p, '|'); - if (end) - pe = eof = end; - else - pe = eof = p; - } - + const char *p = buf, *pe = buf + buf_len, *eof = pe; const char *tok = nullptr; int cs; hb_glyph_info_t info = {0}; const hb_glyph_position_t pos = {0}; -#line 201 "hb-buffer-deserialize-text-unicode.hh" +#line 147 "hb-buffer-deserialize-text-unicode.hh" { cs = deserialize_text_unicode_start; } -#line 206 "hb-buffer-deserialize-text-unicode.hh" +#line 150 "hb-buffer-deserialize-text-unicode.hh" { int _slen; int _trans; @@ -227,38 +180,27 @@ _resume: goto _again; switch ( _deserialize_text_unicode_trans_actions[_trans] ) { - case 1: + case 4: #line 38 "hb-buffer-deserialize-text-unicode.rl" { hb_memset (&info, 0, sizeof (info)); } break; - case 2: + case 1: #line 51 "hb-buffer-deserialize-text-unicode.rl" { tok = p; } break; - case 4: + case 2: #line 55 "hb-buffer-deserialize-text-unicode.rl" {if (!parse_hex (tok, p, &info.codepoint )) return false; } break; case 3: -#line 55 "hb-buffer-deserialize-text-unicode.rl" - {if (!parse_hex (tok, p, &info.codepoint )) return false; } -#line 42 "hb-buffer-deserialize-text-unicode.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - if (buffer->have_positions) - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; - case 5: #line 57 "hb-buffer-deserialize-text-unicode.rl" { if (!parse_uint (tok, p, &info.cluster )) return false; } + break; + case 6: #line 42 "hb-buffer-deserialize-text-unicode.rl" { buffer->add_info (info); @@ -267,9 +209,13 @@ _resume: if (buffer->have_positions) buffer->pos[buffer->len - 1] = pos; *end_ptr = p; +} +#line 38 "hb-buffer-deserialize-text-unicode.rl" + { + hb_memset (&info, 0, sizeof (info)); } break; -#line 273 "hb-buffer-deserialize-text-unicode.hh" +#line 203 "hb-buffer-deserialize-text-unicode.hh" } _again: @@ -281,22 +227,7 @@ _again: if ( p == eof ) { switch ( _deserialize_text_unicode_eof_actions[cs] ) { - case 3: -#line 55 "hb-buffer-deserialize-text-unicode.rl" - {if (!parse_hex (tok, p, &info.codepoint )) return false; } -#line 42 "hb-buffer-deserialize-text-unicode.rl" - { - buffer->add_info (info); - if (unlikely (!buffer->successful)) - return false; - if (buffer->have_positions) - buffer->pos[buffer->len - 1] = pos; - *end_ptr = p; -} - break; case 5: -#line 57 "hb-buffer-deserialize-text-unicode.rl" - { if (!parse_uint (tok, p, &info.cluster )) return false; } #line 42 "hb-buffer-deserialize-text-unicode.rl" { buffer->add_info (info); @@ -307,23 +238,16 @@ _again: *end_ptr = p; } break; -#line 311 "hb-buffer-deserialize-text-unicode.hh" +#line 224 "hb-buffer-deserialize-text-unicode.hh" } } _out: {} } -#line 115 "hb-buffer-deserialize-text-unicode.rl" +#line 98 "hb-buffer-deserialize-text-unicode.rl" - if (pe < orig_pe && *pe == '>') - { - pe++; - if (p == pe) - p++; - } - *end_ptr = p; return p == pe; diff --git a/src/hb-buffer-deserialize-text-unicode.rl b/src/hb-buffer-deserialize-text-unicode.rl index 92873b804..1e123c8b2 100644 --- a/src/hb-buffer-deserialize-text-unicode.rl +++ b/src/hb-buffer-deserialize-text-unicode.rl @@ -67,14 +67,15 @@ unicode_item = ( unicode cluster? + ('|' | '>') ) >clear_item %add_item ; -unicodes = unicode_item (space* '|' space* unicode_item)* space*; +unicodes = '<'? unicode_item*; -main := space* unicodes; +main := unicodes; }%% @@ -85,25 +86,7 @@ _hb_buffer_deserialize_text_unicode (hb_buffer_t *buffer, const char **end_ptr, hb_font_t *font) { - const char *p = buf, *pe = buf + buf_len, *eof = pe, *orig_pe = pe; - - while (p < pe && ISSPACE (*p)) - p++; - if (p < pe && *p == (buffer->len ? '|' : '<')) - *end_ptr = ++p; - - const char *end = strchr ((char *) p, '>'); - if (end) - pe = eof = end; - else - { - end = strrchr ((char *) p, '|'); - if (end) - pe = eof = end; - else - pe = eof = p; - } - + const char *p = buf, *pe = buf + buf_len, *eof = pe; const char *tok = nullptr; int cs; @@ -114,13 +97,6 @@ _hb_buffer_deserialize_text_unicode (hb_buffer_t *buffer, write exec; }%% - if (pe < orig_pe && *pe == '>') - { - pe++; - if (p == pe) - p++; - } - *end_ptr = p; return p == pe; diff --git a/src/hb-buffer-serialize.cc b/src/hb-buffer-serialize.cc index 16f189519..de2c99d98 100644 --- a/src/hb-buffer-serialize.cc +++ b/src/hb-buffer-serialize.cc @@ -737,8 +737,7 @@ parse_hex (const char *pp, const char *end, uint32_t *pv) * Deserializes glyphs @buffer from textual representation in the format * produced by hb_buffer_serialize_glyphs(). * - * Return value: `true` if parse was successful, `false` if an error - * occurred. + * Return value: `true` if the full string was parsed, `false` otherwise. * * Since: 0.9.7 **/ @@ -810,8 +809,7 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, * Deserializes Unicode @buffer from textual representation in the format * produced by hb_buffer_serialize_unicode(). * - * Return value: `true` if parse was successful, `false` if an error - * occurred. + * Return value: `true` if the full string was parsed, `false` otherwise. * * Since: 2.7.3 **/ diff --git a/src/hb-buffer-verify.cc b/src/hb-buffer-verify.cc index 345f08d26..76f821637 100644 --- a/src/hb-buffer-verify.cc +++ b/src/hb-buffer-verify.cc @@ -63,24 +63,25 @@ static bool buffer_verify_monotone (hb_buffer_t *buffer, hb_font_t *font) { - /* Check that clusters are monotone. */ - if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES || - buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS) + if (!HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE (buffer->cluster_level)) { - bool is_forward = HB_DIRECTION_IS_FORWARD (hb_buffer_get_direction (buffer)); - - unsigned int num_glyphs; - hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, &num_glyphs); - - for (unsigned int i = 1; i < num_glyphs; i++) - if (info[i-1].cluster != info[i].cluster && - (info[i-1].cluster < info[i].cluster) != is_forward) - { - buffer_verify_error (buffer, font, BUFFER_VERIFY_ERROR "clusters are not monotone."); - return false; - } + /* Cannot perform this check without monotone clusters. */ + return true; } + bool is_forward = HB_DIRECTION_IS_FORWARD (hb_buffer_get_direction (buffer)); + + unsigned int num_glyphs; + hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, &num_glyphs); + + for (unsigned int i = 1; i < num_glyphs; i++) + if (info[i-1].cluster != info[i].cluster && + (info[i-1].cluster < info[i].cluster) != is_forward) + { + buffer_verify_error (buffer, font, BUFFER_VERIFY_ERROR "clusters are not monotone."); + return false; + } + return true; } @@ -92,8 +93,7 @@ buffer_verify_unsafe_to_break (hb_buffer_t *buffer, unsigned int num_features, const char * const *shapers) { - if (buffer->cluster_level != HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES && - buffer->cluster_level != HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS) + if (!HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE (buffer->cluster_level)) { /* Cannot perform this check without monotone clusters. */ return true; @@ -207,8 +207,7 @@ buffer_verify_unsafe_to_concat (hb_buffer_t *buffer, unsigned int num_features, const char * const *shapers) { - if (buffer->cluster_level != HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES && - buffer->cluster_level != HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS) + if (!HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE (buffer->cluster_level)) { /* Cannot perform this check without monotone clusters. */ return true; diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index d0c40664a..7fb95fe7e 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -518,7 +518,7 @@ void hb_buffer_t::merge_clusters_impl (unsigned int start, unsigned int end) { - if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS) + if (!HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE (cluster_level)) { unsafe_to_break (start, end); return; @@ -551,7 +551,7 @@ void hb_buffer_t::merge_out_clusters (unsigned int start, unsigned int end) { - if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS) + if (!HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE (cluster_level)) return; if (unlikely (end - start < 2)) diff --git a/src/hb-buffer.h b/src/hb-buffer.h index dd0edb9b7..14063ccd0 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -422,18 +422,34 @@ hb_buffer_get_flags (const hb_buffer_t *buffer); * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values. * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level, * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. - * + * @HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES: Only group clusters, but don't enforce monotone order. + * * Data type for holding HarfBuzz's clustering behavior options. The cluster level - * dictates one aspect of how HarfBuzz will treat non-base characters + * dictates one aspect of how HarfBuzz will treat non-base characters * during shaping. * * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base * characters are merged into the cluster of the base character that precedes them. + * There is also cluster merging every time the clusters will otherwise become non-monotone. * * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially * assigned their own cluster values, which are not merged into preceding base * clusters. This allows HarfBuzz to perform additional operations like reorder - * sequences of adjacent marks. + * sequences of adjacent marks. The output is still monotone, but the cluster + * values are more granular. + * + * In @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS, non-base characters are assigned their + * own cluster values, which are not merged into preceding base clusters. Moreover, + * the cluster values are not merged into monotone order. This is the most granular + * cluster level, and it is useful for clients that need to know the exact cluster + * values of each character, but is harder to use for clients, since clusters + * might appear in any order. + * + * In @HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES, non-base characters are merged into the + * cluster of the base character that precedes them. This is similar to the Unicode + * Grapheme Cluster algorithm, but it is not exactly the same. The output is + * not forced to be monotone. This is useful for clients that want to use HarfBuzz + * as a cheap implementation of the Unicode Grapheme Cluster algorithm. * * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains * backward compatibility with older versions of HarfBuzz. New client programs that @@ -446,9 +462,52 @@ typedef enum { HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, + HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES = 3, HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES } hb_buffer_cluster_level_t; +/** + * HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE: + * @level: #hb_buffer_cluster_level_t to test + * + * Tests whether a cluster level groups cluster values into monotone order. + * Requires that the level be valid. + * + * XSince: REPLACEME + */ +#define HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE(level) \ + ((bool) ((1u << (unsigned) (level)) & \ + ((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) | \ + (1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS)))) + +/** + * HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES: + * @level: #hb_buffer_cluster_level_t to test + * + * Tests whether a cluster level groups cluster values by graphemes. Requires + * that the level be valid. + * + * XSince: REPLACEME + */ +#define HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES(level) \ + ((bool) ((1u << (unsigned) (level)) & \ + ((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) | \ + (1u << HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES)))) + +/** + * HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS + * @level: #hb_buffer_cluster_level_t to test + * + * Tests whether a cluster level does not group cluster values by graphemes. + * Requires that the level be valid. + * + * XSince: REPLACEME + */ +#define HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS(level) \ + ((bool) ((1u << (unsigned) (level)) & \ + ((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARCATERS) | \ + (1u << HB_BUFFER_CLUSTER_LEVEL_CHARACTERS)))) + HB_EXTERN void hb_buffer_set_cluster_level (hb_buffer_t *buffer, hb_buffer_cluster_level_t cluster_level); diff --git a/src/hb-common.cc b/src/hb-common.cc index d3355c971..3344a1bcf 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -1217,6 +1217,58 @@ uint8_t return hb_color_get_blue (color); } +/** + * hb_malloc: + * @size: The size of the memory to allocate. + * + * Allocates @size bytes of memory, using the allocator set at + * compile-time. Typically just malloc(). + * + * Return value: A pointer to the allocated memory. + * + * XSince: REPLACEME + **/ +void* hb_malloc(size_t size) { return hb_malloc_impl (size); } + +/** + * hb_calloc: + * @nmemb: The number of elements to allocate. + * @size: The size of each element. + * + * Allocates @nmemb elements of @size bytes each, initialized to zero, + * using the allocator set at compile-time. Typically just calloc(). + * + * Return value: A pointer to the allocated memory. + * + * XSince: REPLACEME + **/ +void* hb_calloc(size_t nmemb, size_t size) { return hb_calloc_impl (nmemb, size); } + +/** + * hb_realloc: + * @ptr: The pointer to the memory to reallocate. + * @size: The new size of the memory. + * + * Reallocates the memory pointed to by @ptr to @size bytes, using the + * allocator set at compile-time. Typically just realloc(). + * + * Return value: A pointer to the reallocated memory. + * + * XSince: REPLACEME + **/ +void* hb_realloc(void *ptr, size_t size) { return hb_realloc_impl (ptr, size); } + +/** + * hb_free: + * @ptr: The pointer to the memory to free. + * + * Frees the memory pointed to by @ptr, using the allocator set at + * compile-time. Typically just free(). + * + * XSince: REPLACEME + **/ +void hb_free(void *ptr) { hb_free_impl (ptr); } + /* If there is no visibility control, then hb-static.cc will NOT * define anything. Instead, we get it to define one set in here diff --git a/src/hb-common.h b/src/hb-common.h index 110854548..1d7b824b6 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -65,6 +65,7 @@ typedef unsigned __int64 uint64_t; #else # include #endif +#include #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define HB_DEPRECATED __attribute__((__deprecated__)) @@ -948,6 +949,16 @@ typedef struct hb_glyph_extents_t { */ typedef struct hb_font_t hb_font_t; +/* Not of much use to clients. */ +HB_EXTERN void* +hb_malloc (size_t size); +HB_EXTERN void* +hb_calloc (size_t nmemb, size_t size); +HB_EXTERN void* +hb_realloc (void *ptr, size_t size); +HB_EXTERN void +hb_free (void *ptr); + HB_END_DECLS #endif /* HB_COMMON_H */ diff --git a/src/hb-coretext-font.cc b/src/hb-coretext-font.cc index 6d03e77e5..91f9b0e0b 100644 --- a/src/hb-coretext-font.cc +++ b/src/hb-coretext-font.cc @@ -28,7 +28,7 @@ #ifdef HAVE_CORETEXT -#include "hb-coretext.h" +#include "hb-coretext.hh" #include "hb-draw.hh" #include "hb-font.hh" diff --git a/src/hb-coretext-shape.cc b/src/hb-coretext-shape.cc index 16e111374..fc7b6eecc 100644 --- a/src/hb-coretext-shape.cc +++ b/src/hb-coretext-shape.cc @@ -32,279 +32,9 @@ #include "hb-shaper-impl.hh" -#include "hb-coretext.h" +#include "hb-coretext.hh" #include "hb-aat-layout.hh" - -/** - * SECTION:hb-coretext - * @title: hb-coretext - * @short_description: CoreText integration - * @include: hb-coretext.h - * - * Functions for using HarfBuzz with the CoreText fonts. - **/ - -static CTFontRef create_ct_font (CGFontRef cg_font, CGFloat font_size); - -static void -release_table_data (void *user_data) -{ - CFDataRef cf_data = reinterpret_cast (user_data); - CFRelease(cf_data); -} - -static hb_blob_t * -_hb_cg_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) -{ - CGFontRef cg_font = reinterpret_cast (user_data); - CFDataRef cf_data = CGFontCopyTableForTag (cg_font, tag); - if (unlikely (!cf_data)) - return nullptr; - - const char *data = reinterpret_cast (CFDataGetBytePtr (cf_data)); - const size_t length = CFDataGetLength (cf_data); - if (!data || !length) - { - CFRelease (cf_data); - return nullptr; - } - - return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY, - reinterpret_cast (const_cast<__CFData *> (cf_data)), - release_table_data); -} - -static unsigned -_hb_cg_get_table_tags (const hb_face_t *face HB_UNUSED, - unsigned int start_offset, - unsigned int *table_count, - hb_tag_t *table_tags, - void *user_data) -{ - CGFontRef cg_font = reinterpret_cast (user_data); - - CTFontRef ct_font = create_ct_font (cg_font, (CGFloat) HB_CORETEXT_DEFAULT_FONT_SIZE); - - auto arr = CTFontCopyAvailableTables (ct_font, kCTFontTableOptionNoOptions); - - unsigned population = (unsigned) CFArrayGetCount (arr); - unsigned end_offset; - - if (!table_count) - goto done; - - if (unlikely (start_offset >= population)) - { - *table_count = 0; - goto done; - } - - end_offset = start_offset + *table_count; - if (unlikely (end_offset < start_offset)) - { - *table_count = 0; - goto done; - } - end_offset= hb_min (end_offset, (unsigned) population); - - *table_count = end_offset - start_offset; - for (unsigned i = start_offset; i < end_offset; i++) - { - CTFontTableTag tag = (CTFontTableTag)(uintptr_t) CFArrayGetValueAtIndex (arr, i); - table_tags[i - start_offset] = tag; - } - -done: - CFRelease (arr); - CFRelease (ct_font); - return population; -} - -static void -_hb_cg_font_release (void *data) -{ - CGFontRelease ((CGFontRef) data); -} - - -static CTFontDescriptorRef -get_last_resort_font_desc () -{ - // TODO Handle allocation failures? - CTFontDescriptorRef last_resort = CTFontDescriptorCreateWithNameAndSize (CFSTR("LastResort"), 0); - CFArrayRef cascade_list = CFArrayCreate (kCFAllocatorDefault, - (const void **) &last_resort, - 1, - &kCFTypeArrayCallBacks); - CFRelease (last_resort); - CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault, - (const void **) &kCTFontCascadeListAttribute, - (const void **) &cascade_list, - 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFRelease (cascade_list); - - CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes); - CFRelease (attributes); - return font_desc; -} - -static void -release_data (void *info, const void *data, size_t size) -{ - assert (hb_blob_get_length ((hb_blob_t *) info) == size && - hb_blob_get_data ((hb_blob_t *) info, nullptr) == data); - - hb_blob_destroy ((hb_blob_t *) info); -} - -static CGFontRef -create_cg_font (hb_face_t *face) -{ - CGFontRef cg_font = nullptr; - if (face->destroy == _hb_cg_font_release) - { - cg_font = CGFontRetain ((CGFontRef) face->user_data); - } - else - { - hb_blob_t *blob = hb_face_reference_blob (face); - unsigned int blob_length; - const char *blob_data = hb_blob_get_data (blob, &blob_length); - if (unlikely (!blob_length)) - DEBUG_MSG (CORETEXT, face, "Face has empty blob"); - - CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data); - if (likely (provider)) - { - cg_font = CGFontCreateWithDataProvider (provider); - if (unlikely (!cg_font)) - DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed"); - CGDataProviderRelease (provider); - } - } - return cg_font; -} - -static CTFontRef -create_ct_font (CGFontRef cg_font, CGFloat font_size) -{ - CTFontRef ct_font = nullptr; - - /* CoreText does not enable trak table usage / tracking when creating a CTFont - * using CTFontCreateWithGraphicsFont. The only way of enabling tracking seems - * to be through the CTFontCreateUIFontForLanguage call. */ - CFStringRef cg_postscript_name = CGFontCopyPostScriptName (cg_font); - if (CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSText")) || - CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSDisplay"))) - { -#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1080 -# define kCTFontUIFontSystem kCTFontSystemFontType -# define kCTFontUIFontEmphasizedSystem kCTFontEmphasizedSystemFontType -#endif - CTFontUIFontType font_type = kCTFontUIFontSystem; - if (CFStringHasSuffix (cg_postscript_name, CFSTR ("-Bold"))) - font_type = kCTFontUIFontEmphasizedSystem; - - ct_font = CTFontCreateUIFontForLanguage (font_type, font_size, nullptr); - CFStringRef ct_result_name = CTFontCopyPostScriptName(ct_font); - if (CFStringCompare (ct_result_name, cg_postscript_name, 0) != kCFCompareEqualTo) - { - CFRelease(ct_font); - ct_font = nullptr; - } - CFRelease (ct_result_name); - } - CFRelease (cg_postscript_name); - - if (!ct_font) - ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, nullptr, nullptr); - - if (unlikely (!ct_font)) { - DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed"); - return nullptr; - } - - /* crbug.com/576941 and crbug.com/625902 and the investigation in the latter - * bug indicate that the cascade list reconfiguration occasionally causes - * crashes in CoreText on OS X 10.9, thus let's skip this step on older - * operating system versions. Except for the emoji font, where _not_ - * reconfiguring the cascade list causes CoreText crashes. For details, see - * crbug.com/549610 */ - // 0x00070000 stands for "kCTVersionNumber10_10", see CoreText.h -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - if (&CTGetCoreTextVersion != nullptr && CTGetCoreTextVersion() < 0x00070000) { -#pragma GCC diagnostic pop - CFStringRef fontName = CTFontCopyPostScriptName (ct_font); - bool isEmojiFont = CFStringCompare (fontName, CFSTR("AppleColorEmoji"), 0) == kCFCompareEqualTo; - CFRelease (fontName); - if (!isEmojiFont) - return ct_font; - } - - CFURLRef original_url = nullptr; -#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 - ATSFontRef atsFont; - FSRef fsref; - OSStatus status; - atsFont = CTFontGetPlatformFont (ct_font, NULL); - status = ATSFontGetFileReference (atsFont, &fsref); - if (status == noErr) - original_url = CFURLCreateFromFSRef (NULL, &fsref); -#else - original_url = (CFURLRef) CTFontCopyAttribute (ct_font, kCTFontURLAttribute); -#endif - - /* Create font copy with cascade list that has LastResort first; this speeds up CoreText - * font fallback which we don't need anyway. */ - { - CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc (); - CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, nullptr, last_resort_font_desc); - CFRelease (last_resort_font_desc); - if (new_ct_font) - { - /* The CTFontCreateCopyWithAttributes call fails to stay on the same font - * when reconfiguring the cascade list and may switch to a different font - * when there are fonts that go by the same name, since the descriptor is - * just name and size. - * - * Avoid reconfiguring the cascade lists if the new font is outside the - * system locations that we cannot access from the sandboxed renderer - * process in Blink. This can be detected by the new file URL location - * that the newly found font points to. */ - CFURLRef new_url = nullptr; -#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 - atsFont = CTFontGetPlatformFont (new_ct_font, NULL); - status = ATSFontGetFileReference (atsFont, &fsref); - if (status == noErr) - new_url = CFURLCreateFromFSRef (NULL, &fsref); -#else - new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURLAttribute); -#endif - // Keep reconfigured font if URL cannot be retrieved (seems to be the case - // on Mac OS 10.12 Sierra), speculative fix for crbug.com/625606 - if (!original_url || !new_url || CFEqual (original_url, new_url)) { - CFRelease (ct_font); - ct_font = new_ct_font; - } else { - CFRelease (new_ct_font); - DEBUG_MSG (CORETEXT, ct_font, "Discarding reconfigured CTFont, location changed."); - } - if (new_url) - CFRelease (new_url); - } - else - DEBUG_MSG (CORETEXT, ct_font, "Font copy with empty cascade list failed"); - } - - if (original_url) - CFRelease (original_url); - return ct_font; -} - hb_coretext_face_data_t * _hb_coretext_shaper_face_data_create (hb_face_t *face) { @@ -325,102 +55,6 @@ _hb_coretext_shaper_face_data_destroy (hb_coretext_face_data_t *data) CFRelease ((CGFontRef) data); } -/** - * hb_coretext_face_create: - * @cg_font: The CGFontRef to work upon - * - * Creates an #hb_face_t face object from the specified - * CGFontRef. - * - * Return value: (transfer full): The new face object - * - * Since: 0.9.10 - */ -hb_face_t * -hb_coretext_face_create (CGFontRef cg_font) -{ - hb_face_t *face = hb_face_create_for_tables (_hb_cg_reference_table, CGFontRetain (cg_font), _hb_cg_font_release); - hb_face_set_get_table_tags_func (face, _hb_cg_get_table_tags, cg_font, nullptr); - return face; -} - -/** - * hb_coretext_face_create_from_file_or_fail: - * @file_name: A font filename - * @index: The index of the face within the file - * - * Creates an #hb_face_t face object from the specified - * font file and face index. - * - * This is similar in functionality to hb_face_create_from_file_or_fail(), - * but uses the CoreText library for loading the font file. - * - * Return value: (transfer full): The new face object, or `NULL` if - * no face is found at the specified index or the file cannot be read. - * - * Since: 10.1.0 - */ -hb_face_t * -hb_coretext_face_create_from_file_or_fail (const char *file_name, - unsigned int index) -{ - auto url = CFURLCreateFromFileSystemRepresentation (nullptr, - (const UInt8 *) file_name, - strlen (file_name), - false); - if (unlikely (!url)) - return nullptr; - - auto ct_font_desc_array = CTFontManagerCreateFontDescriptorsFromURL (url); - if (unlikely (!ct_font_desc_array)) - { - CFRelease (url); - return nullptr; - } - auto ct_font_desc = (CFArrayGetCount (ct_font_desc_array) > index) ? - (CTFontDescriptorRef) CFArrayGetValueAtIndex (ct_font_desc_array, index) : nullptr; - if (unlikely (!ct_font_desc)) - { - CFRelease (ct_font_desc_array); - CFRelease (url); - return nullptr; - } - CFRelease (url); - auto ct_font = ct_font_desc ? CTFontCreateWithFontDescriptor (ct_font_desc, 0, nullptr) : nullptr; - CFRelease (ct_font_desc_array); - if (unlikely (!ct_font)) - return nullptr; - - auto cg_font = ct_font ? CTFontCopyGraphicsFont (ct_font, nullptr) : nullptr; - CFRelease (ct_font); - if (unlikely (!cg_font)) - return nullptr; - - hb_face_t *face = hb_coretext_face_create (cg_font); - CFRelease (cg_font); - if (unlikely (hb_face_is_immutable (face))) - return nullptr; - - return face; -} - -/** - * hb_coretext_face_get_cg_font: - * @face: The #hb_face_t to work upon - * - * Fetches the CGFontRef associated with an #hb_face_t - * face object - * - * Return value: the CGFontRef found - * - * Since: 0.9.10 - */ -CGFontRef -hb_coretext_face_get_cg_font (hb_face_t *face) -{ - return (CGFontRef) (const void *) face->data.coretext; -} - hb_coretext_font_data_t * _hb_coretext_shaper_font_data_create (hb_font_t *font) @@ -651,7 +285,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, * B1 M1 B2 M2, and B1-B2 form a ligature, M2's cluster will * continue pointing to B2 even though B2 was merged into B1's * cluster... */ - if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) + if (HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES (buffer->cluster_level)) { hb_unicode_funcs_t *unicode = buffer->unicode; unsigned int count = buffer->len; @@ -1297,7 +931,7 @@ resize_and_retry: * or the native OT backend, only that the cluster indices will be * monotonic in the output buffer. */ if (count > 1 && (status_or & kCTRunStatusNonMonotonic) && - buffer->cluster_level != HB_BUFFER_CLUSTER_LEVEL_CHARACTERS) + HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE (buffer->cluster_level)) { hb_glyph_info_t *info = buffer->info; if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc new file mode 100644 index 000000000..da7645bce --- /dev/null +++ b/src/hb-coretext.cc @@ -0,0 +1,456 @@ +/* + * Copyright © 2012,2013 Mozilla Foundation. + * Copyright © 2012,2013 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Mozilla Author(s): Jonathan Kew + * Google Author(s): Behdad Esfahbod + */ + +#include "hb.hh" + +#ifdef HAVE_CORETEXT + +#include "hb-shaper-impl.hh" + +#include "hb-coretext.hh" + + +/** + * SECTION:hb-coretext + * @title: hb-coretext + * @short_description: CoreText integration + * @include: hb-coretext.h + * + * Functions for using HarfBuzz with the CoreText fonts. + **/ + +static void +release_table_data (void *user_data) +{ + CFDataRef cf_data = reinterpret_cast (user_data); + CFRelease(cf_data); +} + +static hb_blob_t * +_hb_cg_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) +{ + CGFontRef cg_font = reinterpret_cast (user_data); + CFDataRef cf_data = CGFontCopyTableForTag (cg_font, tag); + if (unlikely (!cf_data)) + return nullptr; + + const char *data = reinterpret_cast (CFDataGetBytePtr (cf_data)); + const size_t length = CFDataGetLength (cf_data); + if (!data || !length) + { + CFRelease (cf_data); + return nullptr; + } + + return hb_blob_create (data, length, HB_MEMORY_MODE_READONLY, + reinterpret_cast (const_cast<__CFData *> (cf_data)), + release_table_data); +} + +static unsigned +_hb_cg_get_table_tags (const hb_face_t *face HB_UNUSED, + unsigned int start_offset, + unsigned int *table_count, + hb_tag_t *table_tags, + void *user_data) +{ + CGFontRef cg_font = reinterpret_cast (user_data); + + CTFontRef ct_font = create_ct_font (cg_font, (CGFloat) HB_CORETEXT_DEFAULT_FONT_SIZE); + + auto arr = CTFontCopyAvailableTables (ct_font, kCTFontTableOptionNoOptions); + + unsigned population = (unsigned) CFArrayGetCount (arr); + unsigned end_offset; + + if (!table_count) + goto done; + + if (unlikely (start_offset >= population)) + { + *table_count = 0; + goto done; + } + + end_offset = start_offset + *table_count; + if (unlikely (end_offset < start_offset)) + { + *table_count = 0; + goto done; + } + end_offset= hb_min (end_offset, (unsigned) population); + + *table_count = end_offset - start_offset; + for (unsigned i = start_offset; i < end_offset; i++) + { + CTFontTableTag tag = (CTFontTableTag)(uintptr_t) CFArrayGetValueAtIndex (arr, i); + table_tags[i - start_offset] = tag; + } + +done: + CFRelease (arr); + CFRelease (ct_font); + return population; +} + +static void +_hb_cg_font_release (void *data) +{ + CGFontRelease ((CGFontRef) data); +} + + +static CTFontDescriptorRef +get_last_resort_font_desc () +{ + // TODO Handle allocation failures? + CTFontDescriptorRef last_resort = CTFontDescriptorCreateWithNameAndSize (CFSTR("LastResort"), 0); + CFArrayRef cascade_list = CFArrayCreate (kCFAllocatorDefault, + (const void **) &last_resort, + 1, + &kCFTypeArrayCallBacks); + CFRelease (last_resort); + CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault, + (const void **) &kCTFontCascadeListAttribute, + (const void **) &cascade_list, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CFRelease (cascade_list); + + CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes (attributes); + CFRelease (attributes); + return font_desc; +} + +static void +release_data (void *info, const void *data, size_t size) +{ + assert (hb_blob_get_length ((hb_blob_t *) info) == size && + hb_blob_get_data ((hb_blob_t *) info, nullptr) == data); + + hb_blob_destroy ((hb_blob_t *) info); +} + +CGFontRef +create_cg_font (CFArrayRef ct_font_desc_array, unsigned int index) +{ + auto ct_font_desc = (CFArrayGetCount (ct_font_desc_array) > index) ? + (CTFontDescriptorRef) CFArrayGetValueAtIndex (ct_font_desc_array, index) : nullptr; + if (unlikely (!ct_font_desc)) + { + CFRelease (ct_font_desc_array); + return nullptr; + } + auto ct_font = ct_font_desc ? CTFontCreateWithFontDescriptor (ct_font_desc, 0, nullptr) : nullptr; + CFRelease (ct_font_desc_array); + if (unlikely (!ct_font)) + return nullptr; + + auto cg_font = ct_font ? CTFontCopyGraphicsFont (ct_font, nullptr) : nullptr; + CFRelease (ct_font); + + return cg_font; +} + +CGFontRef +create_cg_font (hb_blob_t *blob, unsigned int index) +{ + hb_blob_make_immutable (blob); + unsigned int blob_length; + const char *blob_data = hb_blob_get_data (blob, &blob_length); + if (unlikely (!blob_length)) + DEBUG_MSG (CORETEXT, blob, "Empty blob"); + + if (unlikely (index != 0)) + { + auto ct_font_desc_array = CTFontManagerCreateFontDescriptorsFromData (CFDataCreate (kCFAllocatorDefault, (const UInt8 *) blob_data, blob_length)); + if (unlikely (!ct_font_desc_array)) + return nullptr; + return create_cg_font (ct_font_desc_array, index); + } + + hb_blob_reference (blob); + CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data); + CGFontRef cg_font = nullptr; + if (likely (provider)) + { + cg_font = CGFontCreateWithDataProvider (provider); + if (unlikely (!cg_font)) + DEBUG_MSG (CORETEXT, blob, "CGFontCreateWithDataProvider() failed"); + CGDataProviderRelease (provider); + } + return cg_font; +} + +CGFontRef +create_cg_font (hb_face_t *face) +{ + CGFontRef cg_font = nullptr; + if (face->destroy == _hb_cg_font_release) + cg_font = CGFontRetain ((CGFontRef) face->user_data); + else + { + hb_blob_t *blob = hb_face_reference_blob (face); + cg_font = create_cg_font (blob, face->index); + hb_blob_destroy (blob); + } + return cg_font; +} + +CTFontRef +create_ct_font (CGFontRef cg_font, CGFloat font_size) +{ + CTFontRef ct_font = nullptr; + + /* CoreText does not enable trak table usage / tracking when creating a CTFont + * using CTFontCreateWithGraphicsFont. The only way of enabling tracking seems + * to be through the CTFontCreateUIFontForLanguage call. */ + CFStringRef cg_postscript_name = CGFontCopyPostScriptName (cg_font); + if (CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSText")) || + CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSDisplay"))) + { +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1080 +# define kCTFontUIFontSystem kCTFontSystemFontType +# define kCTFontUIFontEmphasizedSystem kCTFontEmphasizedSystemFontType +#endif + CTFontUIFontType font_type = kCTFontUIFontSystem; + if (CFStringHasSuffix (cg_postscript_name, CFSTR ("-Bold"))) + font_type = kCTFontUIFontEmphasizedSystem; + + ct_font = CTFontCreateUIFontForLanguage (font_type, font_size, nullptr); + CFStringRef ct_result_name = CTFontCopyPostScriptName(ct_font); + if (CFStringCompare (ct_result_name, cg_postscript_name, 0) != kCFCompareEqualTo) + { + CFRelease(ct_font); + ct_font = nullptr; + } + CFRelease (ct_result_name); + } + CFRelease (cg_postscript_name); + + if (!ct_font) + ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, nullptr, nullptr); + + if (unlikely (!ct_font)) { + DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed"); + return nullptr; + } + + /* crbug.com/576941 and crbug.com/625902 and the investigation in the latter + * bug indicate that the cascade list reconfiguration occasionally causes + * crashes in CoreText on OS X 10.9, thus let's skip this step on older + * operating system versions. Except for the emoji font, where _not_ + * reconfiguring the cascade list causes CoreText crashes. For details, see + * crbug.com/549610 */ + // 0x00070000 stands for "kCTVersionNumber10_10", see CoreText.h +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + if (&CTGetCoreTextVersion != nullptr && CTGetCoreTextVersion() < 0x00070000) { +#pragma GCC diagnostic pop + CFStringRef fontName = CTFontCopyPostScriptName (ct_font); + bool isEmojiFont = CFStringCompare (fontName, CFSTR("AppleColorEmoji"), 0) == kCFCompareEqualTo; + CFRelease (fontName); + if (!isEmojiFont) + return ct_font; + } + + CFURLRef original_url = nullptr; +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + ATSFontRef atsFont; + FSRef fsref; + OSStatus status; + atsFont = CTFontGetPlatformFont (ct_font, NULL); + status = ATSFontGetFileReference (atsFont, &fsref); + if (status == noErr) + original_url = CFURLCreateFromFSRef (NULL, &fsref); +#else + original_url = (CFURLRef) CTFontCopyAttribute (ct_font, kCTFontURLAttribute); +#endif + + /* Create font copy with cascade list that has LastResort first; this speeds up CoreText + * font fallback which we don't need anyway. */ + { + CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc (); + CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, nullptr, last_resort_font_desc); + CFRelease (last_resort_font_desc); + if (new_ct_font) + { + /* The CTFontCreateCopyWithAttributes call fails to stay on the same font + * when reconfiguring the cascade list and may switch to a different font + * when there are fonts that go by the same name, since the descriptor is + * just name and size. + * + * Avoid reconfiguring the cascade lists if the new font is outside the + * system locations that we cannot access from the sandboxed renderer + * process in Blink. This can be detected by the new file URL location + * that the newly found font points to. */ + CFURLRef new_url = nullptr; +#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + atsFont = CTFontGetPlatformFont (new_ct_font, NULL); + status = ATSFontGetFileReference (atsFont, &fsref); + if (status == noErr) + new_url = CFURLCreateFromFSRef (NULL, &fsref); +#else + new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURLAttribute); +#endif + // Keep reconfigured font if URL cannot be retrieved (seems to be the case + // on Mac OS 10.12 Sierra), speculative fix for crbug.com/625606 + if (!original_url || !new_url || CFEqual (original_url, new_url)) { + CFRelease (ct_font); + ct_font = new_ct_font; + } else { + CFRelease (new_ct_font); + DEBUG_MSG (CORETEXT, ct_font, "Discarding reconfigured CTFont, location changed."); + } + if (new_url) + CFRelease (new_url); + } + else + DEBUG_MSG (CORETEXT, ct_font, "Font copy with empty cascade list failed"); + } + + if (original_url) + CFRelease (original_url); + return ct_font; +} + +/** + * hb_coretext_face_create: + * @cg_font: The CGFontRef to work upon + * + * Creates an #hb_face_t face object from the specified + * CGFontRef. + * + * Return value: (transfer full): The new face object + * + * Since: 0.9.10 + */ +hb_face_t * +hb_coretext_face_create (CGFontRef cg_font) +{ + hb_face_t *face = hb_face_create_for_tables (_hb_cg_reference_table, CGFontRetain (cg_font), _hb_cg_font_release); + hb_face_set_get_table_tags_func (face, _hb_cg_get_table_tags, cg_font, nullptr); + return face; +} + +/** + * hb_coretext_face_create_from_file_or_fail: + * @file_name: A font filename + * @index: The index of the face within the file + * + * Creates an #hb_face_t face object from the specified + * font file and face index. + * + * This is similar in functionality to hb_face_create_from_file_or_fail(), + * but uses the CoreText library for loading the font file. + * + * Return value: (transfer full): The new face object, or `NULL` if + * no face is found at the specified index or the file cannot be read. + * + * Since: 10.1.0 + */ +hb_face_t * +hb_coretext_face_create_from_file_or_fail (const char *file_name, + unsigned int index) +{ + auto url = CFURLCreateFromFileSystemRepresentation (nullptr, + (const UInt8 *) file_name, + strlen (file_name), + false); + if (unlikely (!url)) + return nullptr; + + auto ct_font_desc_array = CTFontManagerCreateFontDescriptorsFromURL (url); + if (unlikely (!ct_font_desc_array)) + { + CFRelease (url); + return nullptr; + } + + auto cg_font = create_cg_font (ct_font_desc_array, index); + CFRelease (url); + + hb_face_t *face = hb_coretext_face_create (cg_font); + CFRelease (cg_font); + if (unlikely (hb_face_is_immutable (face))) + return nullptr; + + return face; +} + +/** + * hb_coretext_face_create_from_blob_or_fail: + * @blob: A blob containing the font data + * @index: The index of the face within the blob + * + * Creates an #hb_face_t face object from the specified + * blob and face index. + * + * This is similar in functionality to hb_face_create_from_blob_or_fail(), + * but uses the CoreText library for loading the font data. + * + * Return value: (transfer full): The new face object, or `NULL` if + * no face is found at the specified index or the blob cannot be read. + * + * XSince: REPLACEME + */ +hb_face_t * +hb_coretext_face_create_from_blob_or_fail (hb_blob_t *blob, + unsigned int index) +{ + auto cg_font = create_cg_font (blob, index); + if (unlikely (!cg_font)) + return nullptr; + + hb_face_t *face = hb_coretext_face_create (cg_font); + CFRelease (cg_font); + if (unlikely (hb_face_is_immutable (face))) + return nullptr; + + return face; +} + +/** + * hb_coretext_face_get_cg_font: + * @face: The #hb_face_t to work upon + * + * Fetches the CGFontRef associated with an #hb_face_t + * face object + * + * Return value: the CGFontRef found + * + * Since: 0.9.10 + */ +CGFontRef +hb_coretext_face_get_cg_font (hb_face_t *face) +{ + return (CGFontRef) (const void *) face->data.coretext; +} + +#endif diff --git a/src/hb-coretext.h b/src/hb-coretext.h index 3626f1c12..a7c7fee76 100644 --- a/src/hb-coretext.h +++ b/src/hb-coretext.h @@ -84,6 +84,10 @@ HB_EXTERN hb_face_t * hb_coretext_face_create_from_file_or_fail (const char *file_name, unsigned int index); +HB_EXTERN hb_face_t * +hb_coretext_face_create_from_blob_or_fail (hb_blob_t *blob, + unsigned int index); + HB_EXTERN hb_font_t * hb_coretext_font_create (CTFontRef ct_font); diff --git a/src/hb-coretext.hh b/src/hb-coretext.hh new file mode 100644 index 000000000..a58cf6c06 --- /dev/null +++ b/src/hb-coretext.hh @@ -0,0 +1,53 @@ +/* + * Copyright © 2012,2013 Mozilla Foundation. + * Copyright © 2012,2013 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Mozilla Author(s): Jonathan Kew + * Google Author(s): Behdad Esfahbod + */ + + +#ifndef HB_CORETEXT_HH +#define HB_CORETEXT_HH + +#include "hb.hh" + +#include "hb-coretext.h" + +#include "hb-aat-layout.hh" + + +HB_INTERNAL CGFontRef +create_cg_font (CFArrayRef ct_font_desc_array, unsigned int index); + +HB_INTERNAL CGFontRef +create_cg_font (hb_blob_t *blob, unsigned int index); + +HB_INTERNAL CGFontRef +create_cg_font (hb_face_t *face); + +HB_INTERNAL CTFontRef +create_ct_font (CGFontRef cg_font, CGFloat font_size); + + +#endif /* HB_OT_LAYOUT_HH */ diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index f138bd4f3..ddd765a84 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -28,9 +28,6 @@ #include "hb-shaper-impl.hh" -#include -#include - #include "hb-directwrite.h" #include "hb-ms-feature-ranges.hh" diff --git a/src/hb-directwrite.h b/src/hb-directwrite.h index 121569c15..b5b314e16 100644 --- a/src/hb-directwrite.h +++ b/src/hb-directwrite.h @@ -27,6 +27,8 @@ #include "hb.h" +#include + HB_BEGIN_DECLS HB_EXTERN hb_face_t * diff --git a/src/hb-face.cc b/src/hb-face.cc index e35aa1caf..0399e720e 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -79,14 +79,14 @@ hb_face_count (hb_blob_t *blob) if (unlikely (!blob)) return 0; - /* TODO We shouldn't be sanitizing blob. Port to run sanitizer and return if not sane. */ - /* Make API signature const after. */ - hb_blob_t *sanitized = hb_sanitize_context_t ().sanitize_blob (hb_blob_reference (blob)); - const OT::OpenTypeFontFile& ot = *sanitized->as (); - unsigned int ret = ot.get_face_count (); - hb_blob_destroy (sanitized); + hb_sanitize_context_t c (blob); - return ret; + const char *start = hb_blob_get_data (blob, nullptr); + auto *ot = reinterpret_cast (const_cast (start)); + if (unlikely (!ot->sanitize (&c))) + return 0; + + return ot->get_face_count (); } /* @@ -328,20 +328,47 @@ hb_face_create_from_file_or_fail (const char *file_name, static struct supported_face_loaders_t { char name[9]; - hb_face_t * (*func) (const char *font_file, unsigned face_index); + hb_face_t * (*from_file) (const char *font_file, unsigned face_index); + hb_face_t * (*from_blob) (hb_blob_t *blob, unsigned face_index); } supported_face_loaders[] = { + {"ot", #ifndef HB_NO_OPEN - {"ot", hb_face_create_from_file_or_fail}, + hb_face_create_from_file_or_fail, +#else + nullptr, #endif + hb_face_create_or_fail + }, #ifdef HAVE_FREETYPE - {"ft", hb_ft_face_create_from_file_or_fail}, + {"ft", + hb_ft_face_create_from_file_or_fail, + hb_ft_face_create_from_blob_or_fail + }, #endif #ifdef HAVE_CORETEXT - {"coretext", hb_coretext_face_create_from_file_or_fail}, + {"coretext", + hb_coretext_face_create_from_file_or_fail, + hb_coretext_face_create_from_blob_or_fail + }, #endif }; +static const char *get_default_loader_name () +{ + static hb_atomic_ptr_t static_loader_name; + const char *loader_name = static_loader_name.get_acquire (); + if (!loader_name) + { + loader_name = getenv ("HB_FACE_LOADER"); + if (!loader_name) + loader_name = ""; + if (!static_loader_name.cmpexch (nullptr, loader_name)) + loader_name = static_loader_name.get_acquire (); + } + return loader_name; +} + /** * hb_face_create_from_file_or_fail_using: * @file_name: A font filename @@ -353,7 +380,7 @@ static struct supported_face_loaders_t { * is used. * * For example, the FreeType ("ft") loader might be able to load - * .woff and .woff2 files if FreeType is built with those features, + * WOFF and WOFF2 files if FreeType is built with those features, * whereas the OpenType ("ot") loader will not. * * Return value: (transfer full): The new face object, or `NULL` if @@ -366,20 +393,11 @@ hb_face_create_from_file_or_fail_using (const char *file_name, unsigned int index, const char *loader_name) { + // Duplicated in hb_face_create_or_fail_using bool retry = false; - if (!loader_name || !*loader_name) { - static hb_atomic_ptr_t static_funcs_name; - loader_name = static_funcs_name.get_acquire (); - if (!loader_name) - { - loader_name = getenv ("HB_FACE_LOADER"); - if (!loader_name) - loader_name = ""; - if (!static_funcs_name.cmpexch (nullptr, loader_name)) - loader_name = static_funcs_name.get_acquire (); - } + loader_name = get_default_loader_name (); retry = true; } if (loader_name && !*loader_name) loader_name = nullptr; @@ -387,8 +405,58 @@ hb_face_create_from_file_or_fail_using (const char *file_name, retry: for (unsigned i = 0; i < ARRAY_LENGTH (supported_face_loaders); i++) { - if (!loader_name || !strcmp (supported_face_loaders[i].name, loader_name)) - return supported_face_loaders[i].func (file_name, index); + if (!loader_name || (supported_face_loaders[i].from_file && !strcmp (supported_face_loaders[i].name, loader_name))) + return supported_face_loaders[i].from_file (file_name, index); + } + + if (retry) + { + retry = false; + loader_name = nullptr; + goto retry; + } + + return nullptr; +} + +/** + * hb_face_create_or_fail_using: + * @blob: #hb_blob_t to work upon + * @index: The index of the face within @blob + * @loader_name: (nullable): The name of the loader to use, or `NULL` + * + * A thin wrapper around the face loader functions registered with HarfBuzz. + * If @loader_name is `NULL` or the empty string, the first available loader + * is used. + * + * For example, the FreeType ("ft") loader might be able to load + * WOFF and WOFF2 files if FreeType is built with those features, + * whereas the OpenType ("ot") loader will not. + * + * Return value: (transfer full): The new face object, or `NULL` if + * the loader fails to load the face. + * + * XSince: REPLACEME + **/ +hb_face_t * +hb_face_create_or_fail_using (hb_blob_t *blob, + unsigned int index, + const char *loader_name) +{ + // Duplicated in hb_face_create_from_file_or_fail_using + bool retry = false; + if (!loader_name || !*loader_name) + { + loader_name = get_default_loader_name (); + retry = true; + } + if (loader_name && !*loader_name) loader_name = nullptr; + +retry: + for (unsigned i = 0; i < ARRAY_LENGTH (supported_face_loaders); i++) + { + if (!loader_name || (supported_face_loaders[i].from_blob && !strcmp (supported_face_loaders[i].name, loader_name))) + return supported_face_loaders[i].from_blob (blob, index); } if (retry) diff --git a/src/hb-face.h b/src/hb-face.h index c59ec0c4b..5d39a48cc 100644 --- a/src/hb-face.h +++ b/src/hb-face.h @@ -63,6 +63,11 @@ HB_EXTERN hb_face_t * hb_face_create_or_fail (hb_blob_t *blob, unsigned int index); +HB_EXTERN hb_face_t * +hb_face_create_or_fail_using (hb_blob_t *blob, + unsigned int index, + const char *loader_name); + HB_EXTERN hb_face_t * hb_face_create_from_file_or_fail (const char *file_name, unsigned int index); diff --git a/src/hb-font.cc b/src/hb-font.cc index 3e6c876ac..fd9ebd118 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -2329,6 +2329,21 @@ static struct supported_font_funcs_t { #endif }; +static const char *get_default_funcs_name () +{ + static hb_atomic_ptr_t static_funcs_name; + const char *name = static_funcs_name.get_acquire (); + if (!name) + { + name = getenv ("HB_FONT_FUNCS"); + if (!name) + name = ""; + if (!static_funcs_name.cmpexch (nullptr, name)) + name = static_funcs_name.get_acquire (); + } + return name; +} + /** * hb_font_set_funcs_using: * @font: #hb_font_t to work upon @@ -2353,16 +2368,7 @@ hb_font_set_funcs_using (hb_font_t *font, if (!name || !*name) { - static hb_atomic_ptr_t static_funcs_name; - name = static_funcs_name.get_acquire (); - if (!name) - { - name = getenv ("HB_FONT_FUNCS"); - if (!name) - name = ""; - if (!static_funcs_name.cmpexch (nullptr, name)) - name = static_funcs_name.get_acquire (); - } + name = get_default_funcs_name (); retry = true; } if (name && !*name) name = nullptr; diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 7b6758715..af17efbfc 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -1610,7 +1610,8 @@ destroy_ft_library (void *arg) * font file and face index. * * This is similar in functionality to hb_face_create_from_file_or_fail(), - * but uses the FreeType library for loading the font file. + * but uses the FreeType library for loading the font file. This can + * be useful, for example, to load WOFF and WOFF2 font data. * * Return value: (transfer full): The new face object, or `NULL` if * no face is found at the specified index or the file cannot be read. @@ -1647,6 +1648,75 @@ hb_ft_face_create_from_file_or_fail (const char *file_name, return face; } +static hb_user_data_key_t ft_blob_key = {0}; + +static void +_destroy_blob (void *p) +{ + hb_blob_destroy ((hb_blob_t *) p); +} + +/** + * hb_ft_face_create_from_blob_or_fail: + * @blob: A blob + * @index: The index of the face within the blob + * + * Creates an #hb_face_t face object from the specified + * font blob and face index. + * + * This is similar in functionality to hb_face_create_from_blob_or_fail(), + * but uses the FreeType library for loading the font blob. This can + * be useful, for example, to load WOFF and WOFF2 font data. + * + * Return value: (transfer full): The new face object, or `NULL` if + * loading fails (eg. blob does not contain valid font data). + * + * XSince: REPLACEME + */ +hb_face_t * +hb_ft_face_create_from_blob_or_fail (hb_blob_t *blob, + unsigned int index) +{ + FT_Library ft_library = reference_ft_library (); + if (unlikely (!ft_library)) + { + DEBUG_MSG (FT, ft_library, "reference_ft_library failed"); + return nullptr; + } + + hb_blob_make_immutable (blob); + unsigned blob_size; + const char *blob_data = hb_blob_get_data (blob, &blob_size); + + FT_Face ft_face; + if (unlikely (FT_New_Memory_Face (ft_library, + (const FT_Byte *) blob_data, + blob_size, + index, + &ft_face))) + return nullptr; + + hb_face_t *face = hb_ft_face_create_referenced (ft_face); + FT_Done_Face (ft_face); + + ft_face->generic.data = ft_library; + ft_face->generic.finalizer = finalize_ft_library; + + if (hb_face_is_immutable (face)) + return nullptr; + + // Hook the blob to the hb_face_t, since FT_Face still needs it. + hb_blob_reference (blob); + if (!hb_face_set_user_data (face, &ft_blob_key, blob, _destroy_blob, true)) + { + hb_blob_destroy (blob); + hb_face_destroy (face); + return nullptr; + } + + return face; +} + static void _release_blob (void *arg) { diff --git a/src/hb-ft.h b/src/hb-ft.h index 42bfb4f46..227b4f221 100644 --- a/src/hb-ft.h +++ b/src/hb-ft.h @@ -88,6 +88,10 @@ HB_EXTERN hb_face_t * hb_ft_face_create_from_file_or_fail (const char *file_name, unsigned int index); +HB_EXTERN hb_face_t * +hb_ft_face_create_from_blob_or_fail (hb_blob_t *blob, + unsigned int index); + /* * hb-font from ft-face. */ diff --git a/src/hb-number-parser.hh b/src/hb-number-parser.hh index 1a9dbba6d..ec68c3a72 100644 --- a/src/hb-number-parser.hh +++ b/src/hb-number-parser.hh @@ -31,7 +31,7 @@ #include "hb.hh" -#line 35 "hb-number-parser.hh" +#line 32 "hb-number-parser.hh" static const unsigned char _double_parser_trans_keys[] = { 0u, 0u, 43u, 57u, 46u, 57u, 48u, 57u, 43u, 57u, 48u, 57u, 48u, 101u, 48u, 57u, 46u, 101u, 0 @@ -135,12 +135,12 @@ strtod_rl (const char *p, const char **end_ptr /* IN/OUT */) int cs; -#line 139 "hb-number-parser.hh" +#line 132 "hb-number-parser.hh" { cs = double_parser_start; } -#line 144 "hb-number-parser.hh" +#line 135 "hb-number-parser.hh" { int _slen; int _trans; @@ -198,7 +198,7 @@ _resume: exp_overflow = true; } break; -#line 202 "hb-number-parser.hh" +#line 187 "hb-number-parser.hh" } _again: diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index 52dafbba4..ddec57e06 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -202,7 +202,8 @@ enum hb_unicode_props_flags_t { /* If GEN_CAT=FORMAT, top byte masks: */ UPROPS_MASK_Cf_ZWJ = 0x0100u, UPROPS_MASK_Cf_ZWNJ = 0x0200u, - UPROPS_MASK_Cf_VS = 0x0400u + UPROPS_MASK_Cf_VS = 0x0400u, + UPROPS_MASK_Cf_AAT_DELETED = 0x0800u }; HB_MARK_AS_FLAG_T (hb_unicode_props_flags_t); @@ -386,6 +387,8 @@ _hb_grapheme_group_func (const hb_glyph_info_t& a HB_UNUSED, static inline void _hb_ot_layout_reverse_graphemes (hb_buffer_t *buffer) { + // MONOTONE_GRAPHEMES was already applied and is taken care of by _hb_grapheme_group_func. + // So we just check for MONOTONE_CHARACTERS here. buffer->reverse_groups (_hb_grapheme_group_func, buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS); } @@ -418,6 +421,17 @@ _hb_glyph_info_flip_joiners (hb_glyph_info_t *info) return; info->unicode_props() ^= UPROPS_MASK_Cf_ZWNJ | UPROPS_MASK_Cf_ZWJ; } +static inline bool +_hb_glyph_info_is_aat_deleted (const hb_glyph_info_t *info) +{ + return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & UPROPS_MASK_Cf_AAT_DELETED); +} +static inline void +_hb_glyph_info_set_aat_deleted (hb_glyph_info_t *info) +{ + _hb_glyph_info_set_general_category (info, HB_UNICODE_GENERAL_CATEGORY_FORMAT); + info->unicode_props() |= UPROPS_MASK_Cf_AAT_DELETED; +} /* lig_props: aka lig_id / lig_comp * diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 6eecc1a10..0469d5981 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -551,7 +551,7 @@ hb_form_clusters (hb_buffer_t *buffer) if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII)) return; - if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) + if (HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES (buffer->cluster_level)) foreach_grapheme (buffer, start, end) buffer->merge_clusters (start, end); else @@ -609,7 +609,7 @@ hb_ensure_native_direction (hb_buffer_t *buffer) * Ogham fonts are supposed to be implemented BTT or not. Need to research that * first. */ if ((HB_DIRECTION_IS_HORIZONTAL (direction) && - direction != horiz_dir && horiz_dir != HB_DIRECTION_INVALID) || + direction != horiz_dir && HB_DIRECTION_IS_VALID (horiz_dir)) || (HB_DIRECTION_IS_VERTICAL (direction) && direction != HB_DIRECTION_TTB)) { diff --git a/src/hb-ot-shaper-hangul.cc b/src/hb-ot-shaper-hangul.cc index c90476bc4..50ea53272 100644 --- a/src/hb-ot-shaper-hangul.cc +++ b/src/hb-ot-shaper-hangul.cc @@ -298,8 +298,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED, end = start + 2; if (unlikely (!buffer->successful)) break; - if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) - buffer->merge_out_clusters (start, end); + buffer->merge_out_clusters (start, end); continue; } } @@ -372,8 +371,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan HB_UNUSED, if (i < end) info[i++].hangul_shaping_feature() = TJMO; - if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) - buffer->merge_out_clusters (start, end); + buffer->merge_out_clusters (start, end); continue; } else if ((!tindex && buffer->idx + 1 < count && isT (buffer->cur(+1).codepoint))) diff --git a/src/hb-ot-shaper-indic-machine.hh b/src/hb-ot-shaper-indic-machine.hh index 6ff65c30a..92fb64ad0 100644 --- a/src/hb-ot-shaper-indic-machine.hh +++ b/src/hb-ot-shaper-indic-machine.hh @@ -53,7 +53,7 @@ enum indic_syllable_type_t { }; -#line 57 "hb-ot-shaper-indic-machine.hh" +#line 54 "hb-ot-shaper-indic-machine.hh" #define indic_syllable_machine_ex_A 9u #define indic_syllable_machine_ex_C 1u #define indic_syllable_machine_ex_CM 16u @@ -77,7 +77,7 @@ enum indic_syllable_type_t { #define indic_syllable_machine_ex_ZWNJ 5u -#line 81 "hb-ot-shaper-indic-machine.hh" +#line 76 "hb-ot-shaper-indic-machine.hh" static const unsigned char _indic_syllable_machine_trans_keys[] = { 8u, 57u, 4u, 57u, 5u, 57u, 5u, 57u, 13u, 13u, 4u, 57u, 4u, 57u, 4u, 57u, 8u, 57u, 5u, 57u, 5u, 57u, 13u, 13u, 4u, 57u, 4u, 57u, 4u, 57u, 4u, 57u, @@ -1126,7 +1126,7 @@ find_syllables_indic (hb_buffer_t *buffer) int cs; hb_glyph_info_t *info = buffer->info; -#line 1130 "hb-ot-shaper-indic-machine.hh" +#line 1119 "hb-ot-shaper-indic-machine.hh" { cs = indic_syllable_machine_start; ts = 0; @@ -1142,7 +1142,7 @@ find_syllables_indic (hb_buffer_t *buffer) unsigned int syllable_serial = 1; -#line 1146 "hb-ot-shaper-indic-machine.hh" +#line 1131 "hb-ot-shaper-indic-machine.hh" { int _slen; int _trans; @@ -1156,7 +1156,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 1160 "hb-ot-shaper-indic-machine.hh" +#line 1143 "hb-ot-shaper-indic-machine.hh" } _keys = _indic_syllable_machine_trans_keys + (cs<<1); @@ -1268,7 +1268,7 @@ _eof_trans: #line 117 "hb-ot-shaper-indic-machine.rl" {act = 7;} break; -#line 1272 "hb-ot-shaper-indic-machine.hh" +#line 1232 "hb-ot-shaper-indic-machine.hh" } _again: @@ -1277,7 +1277,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 1281 "hb-ot-shaper-indic-machine.hh" +#line 1239 "hb-ot-shaper-indic-machine.hh" } if ( ++p != pe ) diff --git a/src/hb-ot-shaper-khmer-machine.hh b/src/hb-ot-shaper-khmer-machine.hh index f1e7a91f0..848ed231f 100644 --- a/src/hb-ot-shaper-khmer-machine.hh +++ b/src/hb-ot-shaper-khmer-machine.hh @@ -48,7 +48,7 @@ enum khmer_syllable_type_t { }; -#line 52 "hb-ot-shaper-khmer-machine.hh" +#line 49 "hb-ot-shaper-khmer-machine.hh" #define khmer_syllable_machine_ex_C 1u #define khmer_syllable_machine_ex_DOTTEDCIRCLE 11u #define khmer_syllable_machine_ex_H 4u @@ -66,7 +66,7 @@ enum khmer_syllable_type_t { #define khmer_syllable_machine_ex_ZWNJ 5u -#line 70 "hb-ot-shaper-khmer-machine.hh" +#line 65 "hb-ot-shaper-khmer-machine.hh" static const unsigned char _khmer_syllable_machine_trans_keys[] = { 5u, 26u, 5u, 26u, 1u, 15u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 5u, 26u, 1u, 15u, 5u, 26u, 5u, 26u, @@ -294,7 +294,7 @@ find_syllables_khmer (hb_buffer_t *buffer) int cs; hb_glyph_info_t *info = buffer->info; -#line 298 "hb-ot-shaper-khmer-machine.hh" +#line 287 "hb-ot-shaper-khmer-machine.hh" { cs = khmer_syllable_machine_start; ts = 0; @@ -310,7 +310,7 @@ find_syllables_khmer (hb_buffer_t *buffer) unsigned int syllable_serial = 1; -#line 314 "hb-ot-shaper-khmer-machine.hh" +#line 299 "hb-ot-shaper-khmer-machine.hh" { int _slen; int _trans; @@ -324,7 +324,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 328 "hb-ot-shaper-khmer-machine.hh" +#line 311 "hb-ot-shaper-khmer-machine.hh" } _keys = _khmer_syllable_machine_trans_keys + (cs<<1); @@ -394,7 +394,7 @@ _eof_trans: #line 98 "hb-ot-shaper-khmer-machine.rl" {act = 3;} break; -#line 398 "hb-ot-shaper-khmer-machine.hh" +#line 368 "hb-ot-shaper-khmer-machine.hh" } _again: @@ -403,7 +403,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 407 "hb-ot-shaper-khmer-machine.hh" +#line 375 "hb-ot-shaper-khmer-machine.hh" } if ( ++p != pe ) diff --git a/src/hb-ot-shaper-myanmar-machine.hh b/src/hb-ot-shaper-myanmar-machine.hh index 4b8da586d..292bc9f3d 100644 --- a/src/hb-ot-shaper-myanmar-machine.hh +++ b/src/hb-ot-shaper-myanmar-machine.hh @@ -50,7 +50,7 @@ enum myanmar_syllable_type_t { }; -#line 54 "hb-ot-shaper-myanmar-machine.hh" +#line 51 "hb-ot-shaper-myanmar-machine.hh" #define myanmar_syllable_machine_ex_A 9u #define myanmar_syllable_machine_ex_As 32u #define myanmar_syllable_machine_ex_C 1u @@ -78,7 +78,7 @@ enum myanmar_syllable_type_t { #define myanmar_syllable_machine_ex_ZWNJ 5u -#line 82 "hb-ot-shaper-myanmar-machine.hh" +#line 77 "hb-ot-shaper-myanmar-machine.hh" static const unsigned char _myanmar_syllable_machine_trans_keys[] = { 1u, 57u, 3u, 57u, 5u, 57u, 5u, 57u, 3u, 57u, 5u, 57u, 3u, 57u, 3u, 57u, 3u, 57u, 3u, 57u, 3u, 57u, 5u, 57u, 1u, 15u, 3u, 57u, 3u, 57u, 3u, 57u, @@ -549,7 +549,7 @@ find_syllables_myanmar (hb_buffer_t *buffer) int cs; hb_glyph_info_t *info = buffer->info; -#line 553 "hb-ot-shaper-myanmar-machine.hh" +#line 542 "hb-ot-shaper-myanmar-machine.hh" { cs = myanmar_syllable_machine_start; ts = 0; @@ -565,7 +565,7 @@ find_syllables_myanmar (hb_buffer_t *buffer) unsigned int syllable_serial = 1; -#line 569 "hb-ot-shaper-myanmar-machine.hh" +#line 554 "hb-ot-shaper-myanmar-machine.hh" { int _slen; int _trans; @@ -579,7 +579,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 583 "hb-ot-shaper-myanmar-machine.hh" +#line 566 "hb-ot-shaper-myanmar-machine.hh" } _keys = _myanmar_syllable_machine_trans_keys + (cs<<1); @@ -649,7 +649,7 @@ _eof_trans: #line 113 "hb-ot-shaper-myanmar-machine.rl" {act = 3;} break; -#line 653 "hb-ot-shaper-myanmar-machine.hh" +#line 623 "hb-ot-shaper-myanmar-machine.hh" } _again: @@ -658,7 +658,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 662 "hb-ot-shaper-myanmar-machine.hh" +#line 630 "hb-ot-shaper-myanmar-machine.hh" } if ( ++p != pe ) diff --git a/src/hb-ot-shaper-thai.cc b/src/hb-ot-shaper-thai.cc index 6cd67cde3..6124a2114 100644 --- a/src/hb-ot-shaper-thai.cc +++ b/src/hb-ot-shaper-thai.cc @@ -360,7 +360,7 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan, { /* Since we decomposed, and NIKHAHIT is combining, merge clusters with the * previous cluster. */ - if (start && buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) + if (start) buffer->merge_out_clusters (start - 1, end); } } diff --git a/src/hb-ot-shaper-use-machine.hh b/src/hb-ot-shaper-use-machine.hh index 65b6adc36..5072e4d38 100644 --- a/src/hb-ot-shaper-use-machine.hh +++ b/src/hb-ot-shaper-use-machine.hh @@ -53,7 +53,7 @@ enum use_syllable_type_t { }; -#line 57 "hb-ot-shaper-use-machine.hh" +#line 54 "hb-ot-shaper-use-machine.hh" #define use_syllable_machine_ex_B 1u #define use_syllable_machine_ex_CGJ 6u #define use_syllable_machine_ex_CMAbv 31u @@ -100,7 +100,7 @@ enum use_syllable_type_t { #define use_syllable_machine_ex_ZWNJ 14u -#line 104 "hb-ot-shaper-use-machine.hh" +#line 99 "hb-ot-shaper-use-machine.hh" static const unsigned char _use_syllable_machine_trans_keys[] = { 49u, 51u, 0u, 56u, 11u, 56u, 11u, 56u, 1u, 53u, 14u, 48u, 14u, 47u, 14u, 47u, 14u, 47u, 14u, 46u, 14u, 46u, 14u, 14u, 14u, 48u, 14u, 48u, 14u, 48u, 1u, 14u, @@ -929,7 +929,7 @@ find_syllables_use (hb_buffer_t *buffer) unsigned int act HB_UNUSED; int cs; -#line 933 "hb-ot-shaper-use-machine.hh" +#line 922 "hb-ot-shaper-use-machine.hh" { cs = use_syllable_machine_start; ts = 0; @@ -942,7 +942,7 @@ find_syllables_use (hb_buffer_t *buffer) unsigned int syllable_serial = 1; -#line 946 "hb-ot-shaper-use-machine.hh" +#line 931 "hb-ot-shaper-use-machine.hh" { int _slen; int _trans; @@ -956,7 +956,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 960 "hb-ot-shaper-use-machine.hh" +#line 943 "hb-ot-shaper-use-machine.hh" } _keys = _use_syllable_machine_trans_keys + (cs<<1); @@ -1078,7 +1078,7 @@ _eof_trans: #line 181 "hb-ot-shaper-use-machine.rl" {act = 9;} break; -#line 1082 "hb-ot-shaper-use-machine.hh" +#line 1039 "hb-ot-shaper-use-machine.hh" } _again: @@ -1087,7 +1087,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 1091 "hb-ot-shaper-use-machine.hh" +#line 1046 "hb-ot-shaper-use-machine.hh" } if ( ++p != pe ) diff --git a/src/hb-static.cc b/src/hb-static.cc index c9bd0a61b..e328bc48a 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -41,6 +41,7 @@ #include "hb-ot-maxp-table.hh" #ifndef HB_NO_VISIBILITY + #include "hb-ot-name-language-static.hh" uint64_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = {}; diff --git a/src/hb.hh b/src/hb.hh index 0691c8425..ffbfef099 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -230,33 +230,6 @@ #define HB_PASTE(a,b) HB_PASTE1(a,b) -/* Compile-time custom allocator support. */ - -#if !defined(HB_CUSTOM_MALLOC) \ - && defined(hb_malloc_impl) \ - && defined(hb_calloc_impl) \ - && defined(hb_realloc_impl) \ - && defined(hb_free_impl) -#define HB_CUSTOM_MALLOC -#endif - -#ifdef HB_CUSTOM_MALLOC -extern "C" void* hb_malloc_impl(size_t size); -extern "C" void* hb_calloc_impl(size_t nmemb, size_t size); -extern "C" void* hb_realloc_impl(void *ptr, size_t size); -extern "C" void hb_free_impl(void *ptr); -#define hb_malloc hb_malloc_impl -#define hb_calloc hb_calloc_impl -#define hb_realloc hb_realloc_impl -#define hb_free hb_free_impl -#else -#define hb_malloc malloc -#define hb_calloc calloc -#define hb_realloc realloc -#define hb_free free -#endif - - /* * Compiler attributes */ @@ -539,6 +512,29 @@ static_assert ((sizeof (hb_var_int_t) == 4), ""); #define HB_PI 3.14159265358979f #define HB_2_PI (2.f * HB_PI) +/* Compile-time custom allocator support. */ + +#if !defined(HB_CUSTOM_MALLOC) \ + && defined(hb_malloc_impl) \ + && defined(hb_calloc_impl) \ + && defined(hb_realloc_impl) \ + && defined(hb_free_impl) +#define HB_CUSTOM_MALLOC +#endif + +#ifdef HB_CUSTOM_MALLOC +extern "C" void* hb_malloc_impl(size_t size); +extern "C" void* hb_calloc_impl(size_t nmemb, size_t size); +extern "C" void* hb_realloc_impl(void *ptr, size_t size); +extern "C" void hb_free_impl(void *ptr); +#else +#define hb_malloc_impl malloc +#define hb_calloc_impl calloc +#define hb_realloc_impl realloc +#define hb_free_impl free +#endif + + /* Headers we include for everyone. Keep topologically sorted by dependency. * They express dependency amongst themselves, but no other file should include diff --git a/src/meson.build b/src/meson.build index e71070910..eb193676b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -352,7 +352,7 @@ hb_wasm_headers = files() # System-dependent sources and headers -hb_coretext_sources = files('hb-coretext-shape.cc', 'hb-coretext-font.cc') +hb_coretext_sources = files('hb-coretext.cc', 'hb-coretext-shape.cc', 'hb-coretext-font.cc') hb_coretext_headers = files('hb-coretext.h') hb_directwrite_sources = files('hb-directwrite.cc') diff --git a/src/test-buffer-serialize.cc b/src/test-buffer-serialize.cc index aced1c8d1..421e5da68 100644 --- a/src/test-buffer-serialize.cc +++ b/src/test-buffer-serialize.cc @@ -43,6 +43,23 @@ main (int argc, char **argv) #ifndef HB_NO_BUFFER_SERIALIZE + hb_buffer_serialize_format_t format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; + if (argc > 1) + { + if (!strcmp (argv[1], "--json")) + { + format = HB_BUFFER_SERIALIZE_FORMAT_JSON; + argc--; + argv++; + } + else if (!strcmp (argv[1], "--text")) + { + format = HB_BUFFER_SERIALIZE_FORMAT_TEXT; + argc--; + argv++; + } + } + if (argc < 2) argv[1] = (char *) "/dev/null"; @@ -68,10 +85,13 @@ main (int argc, char **argv) while (true) { const char *p = line; + const char *end = p + strlen (p); + if (p < end && *(end - 1) == '\n') + end--; if (!hb_buffer_deserialize_glyphs (buf, - p, -1, &p, + p, end - p, &p, font, - HB_BUFFER_SERIALIZE_FORMAT_TEXT)) + format)) { ret = false; break; @@ -97,7 +117,8 @@ main (int argc, char **argv) unsigned len; offset += hb_buffer_serialize_glyphs (buf, offset, count, out, sizeof (out), &len, - font, HB_BUFFER_SERIALIZE_FORMAT_TEXT, + font, + format, HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS); fwrite (out, 1, len, stdout); } diff --git a/test/api/hb-test.h b/test/api/hb-test.h index 25d07ce0a..648f452e4 100644 --- a/test/api/hb-test.h +++ b/test/api/hb-test.h @@ -223,16 +223,6 @@ hb_test_add_func (const char *test_path, } #define hb_test_add(Func) hb_test_add_func (#Func, Func) -static inline void -hb_test_add_func_flavor (const char *test_path, - const char *flavor, - hb_test_func_t test_func) -{ - char *path = g_strdup_printf ("%s/%s", test_path, flavor); - hb_test_add_func (path, test_func); - g_free (path); -} -#define hb_test_add_flavor(Flavor, Func) hb_test_add_func (#Func, Flavor, Func) static inline void hb_test_add_data_func (const char *test_path, @@ -251,12 +241,18 @@ hb_test_add_data_func_flavor (const char *test_path, gconstpointer test_data, hb_test_data_func_t test_func) { - char *path = g_strdup_printf ("%s/%s", test_path, flavor); - hb_test_add_data_func (path, test_data, test_func); - g_free (path); + if (flavor && *flavor) + { + char *path = g_strdup_printf ("%s/%s", test_path, flavor); + hb_test_add_data_func (path, test_data, test_func); + g_free (path); + } + else + hb_test_add_data_func (test_path, test_data, test_func); } #define hb_test_add_data_flavor(UserData, Flavor, Func) hb_test_add_data_func_flavor (#Func, Flavor, UserData, Func) +#define hb_test_add_flavor(Flavor, Func) hb_test_add_data_flavor (Flavor, Flavor, Func) static inline void hb_test_add_vtable (const char *test_path, @@ -314,27 +310,38 @@ G_STMT_START { \ } G_STMT_END -static inline hb_face_t * -hb_test_open_font_file (const char *font_path) +static inline char * +hb_test_resolve_path (const char *path) { #if GLIB_CHECK_VERSION(2,37,2) - char *path = g_test_build_filename (G_TEST_DIST, font_path, NULL); -#else - char *path = g_strdup (font_path); + if (path[0] != '/') + return g_test_build_filename (G_TEST_DIST, path, NULL); #endif + return g_strdup (path); +} + +static inline hb_face_t * +hb_test_open_font_file_with_index (const char *font_path, unsigned face_index) +{ + char *path = hb_test_resolve_path (font_path); hb_blob_t *blob = hb_blob_create_from_file_or_fail (path); hb_face_t *face; if (!blob) g_error ("Font %s not found.", path); - face = hb_face_create (blob, 0); + face = hb_face_create (blob, face_index); hb_blob_destroy (blob); g_free (path); return face; } +static inline hb_face_t * +hb_test_open_font_file (const char *font_path) +{ + return hb_test_open_font_file_with_index (font_path, 0); +} HB_END_DECLS diff --git a/test/api/meson.build b/test/api/meson.build index 59e7af387..bc4e0c5b8 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -18,6 +18,7 @@ tests = [ 'test-draw.c', 'test-draw-varc.c', 'test-extents.c', + 'test-face.c', 'test-font.c', 'test-font-scale.c', 'test-get-table-tags.c', @@ -87,7 +88,7 @@ if conf.get('HAVE_DIRECTWRITE', 0) == 1 ] endif -if conf.get('HAVE_FREETYPE', 0) == 1 and conf.get('HAVE_PTHREAD', 0) == 1 +if conf.get('HAVE_PTHREAD', 0) == 1 tests += 'test-multithread.c' endif @@ -102,7 +103,17 @@ foreach source : tests cpp_args = [] test_name = source.split('.')[0] - deps = [glib_dep, freetype_dep, thread_dep, libharfbuzz_dep, libharfbuzz_icu_dep] + deps = [coretext_deps, + freetype_dep, + gdi_uniscribe_deps, + glib_dep, + graphite2_dep, + thread_dep, + libharfbuzz_dep, + libharfbuzz_icu_dep, + libharfbuzz_cairo_dep, + #libharfbuzz_gobject_dep + ] suite = ['api'] if test_name.contains('-subset') or test_name.contains('-instance') deps += libharfbuzz_subset_dep diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c index 522fc7323..59db49e28 100644 --- a/test/api/test-buffer.c +++ b/test/api/test-buffer.c @@ -869,7 +869,7 @@ static const serialization_test_t serialization_tests[] = { { "[{\"u\":1600,\"cl\":0},{\"u\":1589,\"cl\":1}]", HB_BUFFER_SERIALIZE_FORMAT_JSON, -1, 2, TRUE }, /* Unfinished */ - //{ "[{\"u\":1600,\"cl\":0},{\"u\":1589,\"cl\":1}", HB_BUFFER_SERIALIZE_FORMAT_JSON, -1, 2, TRUE }, + { "[{\"u\":1600,\"cl\":0},{\"u\":1589,\"cl\":1}", HB_BUFFER_SERIALIZE_FORMAT_JSON, 36, 1, TRUE }, /* Mixed glyphs/Unicodes -> parse fail */ { "[{\"u\":1600,\"cl\":0},{\"g\":1589,\"cl\":1}]", HB_BUFFER_SERIALIZE_FORMAT_JSON, -1, 0, FALSE }, @@ -894,8 +894,7 @@ test_buffer_serialize_deserialize (void) const serialization_test_t *test = &serialization_tests[i]; g_test_message ("serialize test #%d", i); - - (void) hb_buffer_deserialize_unicode (b, test->contents, -1, &end_ptr, test->format); + bool ret = hb_buffer_deserialize_unicode (b, test->contents, -1, &end_ptr, test->format); // Expected parse failure, got one, don't round-trip if (test->success) @@ -908,13 +907,17 @@ test_buffer_serialize_deserialize (void) consumed = end_ptr - test->contents; g_assert_cmpint (consumed, ==, test->parsed_length); } - - consumed = 0; - hb_buffer_serialize_unicode (b, 0, num_glyphs, round_trip, - sizeof(round_trip), &consumed, test->format, - HB_BUFFER_SERIALIZE_FLAG_DEFAULT); - g_assert_cmpstr (round_trip, ==, test->contents); + else + { + consumed = 0; + hb_buffer_serialize (b, 0, num_glyphs, round_trip, + sizeof(round_trip), &consumed, NULL, test->format, + HB_BUFFER_SERIALIZE_FLAG_DEFAULT); + g_assert_cmpstr (round_trip, ==, test->contents); + } } + else + g_assert (!ret); hb_buffer_destroy (b); diff --git a/test/api/test-c.c b/test/api/test-c.c index 59eef4242..d0bdc9d6d 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -32,31 +32,54 @@ #endif #include +#include #include #include -#ifdef HAVE_GLIB -#include -#endif - -#ifdef HAVE_ICU -#include -#endif - -#ifdef HAVE_FREETYPE -#include -#endif - -#ifdef HAVE_UNISCRIBE -#include +#ifdef HAVE_CAIRO +#include #endif #ifdef HAVE_CORETEXT #include #endif +#ifdef HAVE_FREETYPE +#include +#endif + +#ifdef HAVE_FONTATIONS +#include +#endif + +#ifdef HAVE_GDI +#include +#endif + +#ifdef HAVE_GLIB +#include +#endif + +#ifdef HAVE_GRAPHITE2 +#include +#endif + +#ifdef HAVE_GOBJECT +//#include // Doesn't work uninstalled +#endif + +#ifdef HAVE_ICU +#include +#endif + +#ifdef HAVE_UNISCRIBE +#include +#endif + +#ifndef NO_MAIN int main (void) { return !*hb_shape_list_shapers (); } +#endif diff --git a/test/api/test-cplusplus.cc b/test/api/test-cplusplus.cc index 01b000271..74e4fb265 100644 --- a/test/api/test-cplusplus.cc +++ b/test/api/test-cplusplus.cc @@ -28,33 +28,12 @@ /* This file tests that all headers can be included from C++ files, * as well as test the C++ API. */ -#ifdef HAVE_CONFIG_H -#include -#endif +#define NO_MAIN +#include "test-c.c" +#undef NO_MAIN -#include -#include -#include -#include - -#ifdef HAVE_GLIB -#include -#endif - -#ifdef HAVE_ICU -#include -#endif - -#ifdef HAVE_FREETYPE -#include -#endif - -#ifdef HAVE_UNISCRIBE -#include -#endif - -#ifdef HAVE_CORETEXT -#include +#ifdef HAVE_DIRECTWRITE +#include #endif diff --git a/test/api/test-directwrite.cc b/test/api/test-directwrite.cc index 345b9d2a9..c48572192 100644 --- a/test/api/test-directwrite.cc +++ b/test/api/test-directwrite.cc @@ -25,8 +25,6 @@ */ -#include - #include "hb-test.h" #include "hb-directwrite.h" diff --git a/test/api/test-draw.c b/test/api/test-draw.c index 00da41989..1b5b0f209 100644 --- a/test/api/test-draw.c +++ b/test/api/test-draw.c @@ -26,12 +26,6 @@ #include #include -#ifdef HAVE_FREETYPE -#include -#endif -#ifdef HAVE_FONTATIONS -#include -#endif typedef struct draw_data_t { @@ -1078,8 +1072,9 @@ test_hb_draw_immutable (void) } static void -test_hb_draw_funcs (const char* font_funcs_name) +test_hb_draw_funcs (const void* user_data) { + const char *font_funcs_name = user_data; char str[1024]; draw_data_t draw_data = { .str = str, @@ -1097,12 +1092,6 @@ test_hb_draw_funcs (const char* font_funcs_name) char expected[] = "M50,0L50,750L450,750L450,0L50,0Z"; g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1); } - { - draw_data.consumed = 0; - hb_font_draw_glyph (font, 5, funcs, &draw_data); - char expected[] = "M15,0Q15,0 15,0Z"; - g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1); - } hb_font_destroy (font); } { @@ -1127,8 +1116,9 @@ test_hb_draw_funcs (const char* font_funcs_name) } static void -test_hb_draw_compare_ot_funcs (const char* font_funcs_name) +test_hb_draw_compare_ot_funcs (const void *user_data) { + const char* font_funcs_name = user_data; char str[1024]; draw_data_t draw_data = { .str = str, @@ -1162,34 +1152,6 @@ test_hb_draw_compare_ot_funcs (const char* font_funcs_name) hb_face_destroy (face); } -#ifdef HAVE_FREETYPE -static void -test_hb_draw_ft (void) -{ - test_hb_draw_funcs ("ft"); -} - -static void -test_hb_draw_compare_ot_ft (void) -{ - test_hb_draw_compare_ot_funcs ("ft"); -} -#endif - -#ifdef HAVE_FONTATIONS -static void -test_hb_draw_fontations (void) -{ - test_hb_draw_funcs ("fontations"); -} - -static void -test_hb_draw_compare_ot_fontations (void) -{ - test_hb_draw_compare_ot_funcs ("fontations"); -} -#endif - int main (int argc, char **argv) { @@ -1224,14 +1186,13 @@ main (int argc, char **argv) hb_test_add (test_hb_draw_synthetic_slant); hb_test_add (test_hb_draw_subfont_scale); hb_test_add (test_hb_draw_immutable); -#ifdef HAVE_FREETYPE - hb_test_add (test_hb_draw_ft); - hb_test_add (test_hb_draw_compare_ot_ft); -#endif -#ifdef HAVE_FONTATIONS - hb_test_add (test_hb_draw_fontations); - hb_test_add (test_hb_draw_compare_ot_fontations); -#endif + + const char **font_funcs = hb_font_list_funcs (); + for (const char **font_funcs_name = font_funcs; *font_funcs_name; font_funcs_name++) + { + hb_test_add_flavor (*font_funcs_name, test_hb_draw_funcs); + hb_test_add_flavor (*font_funcs_name, test_hb_draw_compare_ot_funcs); + } unsigned result = hb_test_run (); diff --git a/test/api/test-face.c b/test/api/test-face.c new file mode 100644 index 000000000..9d45eca29 --- /dev/null +++ b/test/api/test-face.c @@ -0,0 +1,106 @@ +/* + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Author(s): Behdad Esfahbod + */ + +#include "hb-test.h" + +/* Unit tests for hb-face.h */ + +#define FONT_FILE "fonts/Roboto-Regular.ac.ttf" +static const char *font_file = NULL; +static unsigned int face_index = 0; + +hb_face_t *master_face = NULL; + +#define HEAD_TAG HB_TAG ('h', 'e', 'a', 'd') +hb_blob_t *master_head = NULL; + +static void +test_face (hb_face_t *face) +{ + g_assert_nonnull (face); + + hb_blob_t *head = hb_face_reference_table (face, HEAD_TAG); + + unsigned int length; + unsigned int master_length; + const char *data = hb_blob_get_data (head, &length); + const char *master_data = hb_blob_get_data (master_head, &master_length); + g_assert_cmpmem (data, length, master_data, master_length); + + hb_blob_destroy (head); +} + +static void +test_create_from_file_using (const void *user_data) +{ + const char *loader = user_data; + hb_face_t *face = hb_face_create_from_file_or_fail_using (font_file, face_index, loader); + test_face (face); + hb_face_destroy (face); +} + +static void +test_create_from_blob_using (const void *user_data) +{ + const char *loader = user_data; + hb_blob_t *blob = hb_blob_create_from_file_or_fail (font_file); + hb_face_t *face = hb_face_create_or_fail_using (blob, face_index, loader); + hb_blob_destroy (blob); + test_face (face); + hb_face_destroy (face); +} + +int +main (int argc, char **argv) +{ + hb_test_init (&argc, &argv); + + font_file = FONT_FILE; + if (argc > 1) + font_file = argv[1]; + if (argc > 2) + face_index = atoi (argv[2]); + + master_face = hb_test_open_font_file_with_index (font_file, face_index); + master_head = hb_face_reference_table (master_face, HEAD_TAG); + g_assert (hb_blob_get_length (master_head) > 0); + + font_file = hb_test_resolve_path (font_file); + + hb_test_add_flavor ("", test_create_from_file_using); + hb_test_add_flavor ("", test_create_from_blob_using); + for (const char **loaders = hb_face_list_loaders (); *loaders; loaders++) + { + hb_test_add_flavor (*loaders, test_create_from_file_using); + hb_test_add_flavor (*loaders, test_create_from_blob_using); + } + + int ret = hb_test_run(); + + hb_blob_destroy (master_head); + hb_face_destroy (master_face); + g_free ((char *) font_file); + + return ret; +} diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c index b83ca6693..90bde064e 100644 --- a/test/api/test-multithread.c +++ b/test/api/test-multithread.c @@ -26,8 +26,6 @@ #include #include -#include -#include #include "hb-test.h" diff --git a/test/api/test-paint.c b/test/api/test-paint.c index 5752359c5..77d283441 100644 --- a/test/api/test-paint.c +++ b/test/api/test-paint.c @@ -467,7 +467,7 @@ test_hb_paint (gconstpointer d, } static void -test_compare_ot_ft (const char *file, hb_codepoint_t glyph) +test_compare_to_ot (const char *file, hb_codepoint_t glyph) { hb_face_t *face; hb_font_t *font; @@ -525,21 +525,15 @@ test_hb_paint_ft (gconstpointer data) } static void -test_compare_ot_ft_novf (gconstpointer d) +test_compare_to_ot_novf (gconstpointer d) { - if (have_ft_colrv1 ()) - test_compare_ot_ft (TEST_GLYPHS, GPOINTER_TO_UINT (d)); - else - g_test_skip ("FreeType COLRv1 support not present"); + test_compare_to_ot (TEST_GLYPHS, GPOINTER_TO_UINT (d)); } static void -test_compare_ot_ft_vf (gconstpointer d) +test_compare_to_ot_vf (gconstpointer d) { - if (have_ft_colrv1 ()) - test_compare_ot_ft (TEST_GLYPHS_VF, GPOINTER_TO_UINT (d)); - else - g_test_skip ("FreeType COLRv1 support not present"); + test_compare_to_ot (TEST_GLYPHS_VF, GPOINTER_TO_UINT (d)); } static void @@ -650,12 +644,20 @@ main (int argc, char **argv) hb_face_t *face = hb_test_open_font_file (TEST_GLYPHS); unsigned glyph_count = hb_face_get_glyph_count (face); - for (unsigned int i = 1; i < glyph_count; i++) + const char **font_funcs = hb_font_list_funcs (); + for (const char **font_func = font_funcs; *font_func; font_func++) { - char buf[20]; - snprintf (buf, 20, "test-%u", i); - hb_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_ot_ft_novf); - hb_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_ot_ft_vf); + if (strcmp (*font_func, "ot") == 0) + continue; + if (!have_ft_colrv1 () && strcmp (*font_func, "ft") == 0) + continue; + for (unsigned int i = 1; i < glyph_count; i++) + { + char buf[32]; + snprintf (buf, 32, "test-%s-%u", *font_func, i); + hb_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_to_ot_novf); + hb_test_add_data_flavor (GUINT_TO_POINTER (i), buf, test_compare_to_ot_vf); + } } hb_face_destroy (face); diff --git a/test/shape/data/in-house/tests/cluster.tests b/test/shape/data/in-house/tests/cluster.tests index 2663e2362..544a561be 100644 --- a/test/shape/data/in-house/tests/cluster.tests +++ b/test/shape/data/in-house/tests/cluster.tests @@ -1,3 +1,5 @@ +# Our cluster-level=3 doesn't really test anything here. +../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=3;U+0078,U+030A,U+0058,U+030A;[gid2=0+1083|gid3=1@-1132,-8+0|gid1=2+1200|gid3=3@-1190,349+0] ../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf;--cluster-level=2;U+0078,U+030A,U+0058,U+030A;[gid2=0+1083|gid3=1@-1132,-8+0|gid1=2+1200|gid3=3@-1190,349+0] ../fonts/43ef465752be9af900745f72fe29cb853a1401a5.ttf;--cluster-level=1;U+05D4,U+05B7,U+05E9,U+05BC,U+05C1,U+05B8,U+05DE,U+05B4,U+05DD;[uni05DD=8+1359|uni05B4=7@111,0+0|uni05DE=6+1391|uni05B8=5+0|uni05BC=3+0|uni05C1=3+0|uni05E9=2+1451|uni05B7=1@28,0+0|uni05D4=0+1338] ../fonts/6f36d056bad6d478fc0bf7397bd52dc3bd197d5f.ttf;--cluster-level=1;U+099B,U+09CB,U+09C8,U+09C2,U+09CB,U+098C;[evowelsigninibeng=0+346|aivowelsignbeng=0+346|evowelsignbeng=0+346|chabeng=0+687|uuvowelsignlongbeng=0@-96,0+0|aavowelsignbeng=0+266|aavowelsignbeng=4+266|lvocalicbeng=5+639] diff --git a/util/shape-options.hh b/util/shape-options.hh index caad5a999..a663008ff 100644 --- a/util/shape-options.hh +++ b/util/shape-options.hh @@ -383,7 +383,7 @@ shape_options_t::add_options (option_parser_t *parser) 0, 0, G_OPTION_ARG_INT, &this->not_found_variation_selector_glyph, "Glyph value to replace not-found variation-selector characters with", nullptr}, {"utf8-clusters", 0, 0, G_OPTION_ARG_NONE, &this->utf8_clusters, "Use UTF8 byte indices, not char indices", nullptr}, - {"cluster-level", 0, 0, G_OPTION_ARG_INT, &this->cluster_level, "Cluster merging level (default: 0)", "0/1/2"}, + {"cluster-level", 0, 0, G_OPTION_ARG_INT, &this->cluster_level, "Cluster merging level (default: 0)", "0/1/2/3"}, {"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", nullptr}, {"unsafe-to-concat",0, 0, G_OPTION_ARG_NONE, &this->unsafe_to_concat, "Produce unsafe-to-concat glyph flag", nullptr}, {"safe-to-insert-tatweel",0, 0, G_OPTION_ARG_NONE, &this->safe_to_insert_tatweel, "Produce safe-to-insert-tatweel glyph flag", nullptr},