src/hb-coretext.cc | 4 +- src/hb-directwrite.cc | 4 +- src/hb-face-private.hh | 9 +++++ src/hb-face.cc | 19 +++++++++++- src/hb-fallback-shape.cc | 4 ++ src/hb-font-private.hh | 12 +++++++ src/hb-font.cc | 59 ++++++++++++++++++++++++++++++++++++++ src/hb-font.h | 4 ++ src/hb-graphite2.cc | 4 +- src/hb-ot-layout-private.hh | 1 src/hb-ot-layout.cc | 2 - src/hb-ot-math.cc | 3 - src/hb-ot-shape-complex-arabic.cc | 2 - src/hb-ot-shape.cc | 4 ++ src/hb-ot-var.cc | 2 - src/hb-shape-plan.cc | 7 ---- src/hb-shaper-private.hh | 16 ++++++---- src/hb-uniscribe.cc | 4 +- 18 files changed, 130 insertions(+), 30 deletions(-)
New commits: commit 73c6dcbb45269186f204b2212288b6384ce42c9d Author: Behdad Esfahbod <beh...@behdad.org> Date: Tue Feb 7 16:53:21 2017 -0800 Silence Coverity warning Fixes https://github.com/behdad/harfbuzz/issues/408 diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 56ec5cd..57ffc1d 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -540,7 +540,7 @@ apply_stch (const hb_ot_shape_plan_t *plan, /* See if we can improve the fit by adding an extra repeat and squeezing them together a bit. */ hb_position_t extra_repeat_overlap = 0; hb_position_t shortfall = sign * w_remaining - sign * w_repeating * (n_copies + 1); - if (shortfall > 0) + if (shortfall > 0 && n_repeating > 0) { ++n_copies; hb_position_t excess = (n_copies + 1) * sign * w_repeating - sign * w_remaining; commit 466b3e58bdc64229dab08c6e0e0079c789540370 Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Feb 3 16:43:25 2017 -0800 Shuffle things around a bit diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index e857dfa..86de0be 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -69,8 +69,8 @@ hb_coretext_face_create (CGFontRef cg_font) } -HB_SHAPER_DATA_ENSURE_DECLARE(coretext, face) -HB_SHAPER_DATA_ENSURE_DECLARE(coretext, font) +HB_SHAPER_DATA_ENSURE_DEFINE(coretext, face) +HB_SHAPER_DATA_ENSURE_DEFINE(coretext, font) /* diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index d63bc04..ab07d8a 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -34,8 +34,8 @@ #define HB_DEBUG_DIRECTWRITE (HB_DEBUG+0) #endif -HB_SHAPER_DATA_ENSURE_DECLARE(directwrite, face) -HB_SHAPER_DATA_ENSURE_DECLARE(directwrite, font) +HB_SHAPER_DATA_ENSURE_DEFINE(directwrite, face) +HB_SHAPER_DATA_ENSURE_DEFINE(directwrite, font) /* diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc index e5a80ee..4b60c6c 100644 --- a/src/hb-fallback-shape.cc +++ b/src/hb-fallback-shape.cc @@ -28,6 +28,10 @@ #include "hb-shaper-impl-private.hh" +HB_SHAPER_DATA_ENSURE_DEFINE(fallback, face) +HB_SHAPER_DATA_ENSURE_DEFINE(fallback, font) + + /* * shaper face data */ diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index a2d90db..68f0817 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -35,8 +35,8 @@ #include <graphite2/Segment.h> -HB_SHAPER_DATA_ENSURE_DECLARE(graphite2, face) -HB_SHAPER_DATA_ENSURE_DECLARE(graphite2, font) +HB_SHAPER_DATA_ENSURE_DEFINE(graphite2, face) +HB_SHAPER_DATA_ENSURE_DEFINE(graphite2, font) /* diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 8c348be..071a439 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -623,5 +623,4 @@ _hb_buffer_assert_gsubgpos_vars (hb_buffer_t *buffer) #undef lig_props #undef glyph_props - #endif /* HB_OT_LAYOUT_PRIVATE_HH */ diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 580397b..a1682a5 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -39,8 +39,6 @@ #include "hb-ot-map-private.hh" -HB_SHAPER_DATA_ENSURE_DECLARE(ot, face) - hb_ot_layout_t * _hb_ot_layout_create (hb_face_t *face) { diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc index 2d7e679..f82a073 100644 --- a/src/hb-ot-math.cc +++ b/src/hb-ot-math.cc @@ -26,10 +26,9 @@ #include "hb-open-type-private.hh" +#include "hb-ot-layout-private.hh" #include "hb-ot-math-table.hh" -HB_SHAPER_DATA_ENSURE_DECLARE(ot, face) - static inline const OT::MATH& _get_math (hb_face_t *face) { diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 6b38739..2eacb34 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -128,6 +128,8 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, * shaper face data */ +HB_SHAPER_DATA_ENSURE_DEFINE(ot, face) + hb_ot_shaper_face_data_t * _hb_ot_shaper_face_data_create (hb_face_t *face) { @@ -145,6 +147,8 @@ _hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data) * shaper font data */ +HB_SHAPER_DATA_ENSURE_DEFINE(ot, font) + struct hb_ot_shaper_font_data_t {}; hb_ot_shaper_font_data_t * diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc index b0d3790..691196d 100644 --- a/src/hb-ot-var.cc +++ b/src/hb-ot-var.cc @@ -32,8 +32,6 @@ #include "hb-ot-var-mvar-table.hh" #include "hb-ot-var.h" -HB_SHAPER_DATA_ENSURE_DECLARE(ot, face) - /* * fvar/avar */ diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index 600faae..1ac77be 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -35,13 +35,6 @@ #endif -#define HB_SHAPER_IMPLEMENT(shaper) \ - HB_SHAPER_DATA_ENSURE_DECLARE(shaper, face) \ - HB_SHAPER_DATA_ENSURE_DECLARE(shaper, font) -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - - static void hb_shape_plan_plan (hb_shape_plan_t *shape_plan, const hb_feature_t *user_features, diff --git a/src/hb-shaper-private.hh b/src/hb-shaper-private.hh index 9535841..381398a 100644 --- a/src/hb-shaper-private.hh +++ b/src/hb-shaper-private.hh @@ -71,22 +71,25 @@ struct hb_shaper_data_t { #define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE(shaper, object, object) #define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_create #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_destroy +#define HB_SHAPER_DATA_ENSURE_FUNC(shaper, object) hb_##shaper##_shaper_##object##_data_ensure #define HB_SHAPER_DATA_PROTOTYPE(shaper, object) \ HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \ extern "C" HB_INTERNAL HB_SHAPER_DATA_TYPE (shaper, object) * \ HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS); \ extern "C" HB_INTERNAL void \ - HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shaper, object) *data) + HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shaper, object) *data); \ + extern "C" HB_INTERNAL bool \ + HB_SHAPER_DATA_ENSURE_FUNC (shaper, object) (hb_##object##_t *object) #define HB_SHAPER_DATA_DESTROY(shaper, object) \ if (HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, object)) \ if (data != HB_SHAPER_DATA_INVALID && data != HB_SHAPER_DATA_SUCCEEDED) \ HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); -#define HB_SHAPER_DATA_ENSURE_DECLARE(shaper, object) \ -static inline bool \ -hb_##shaper##_shaper_##object##_data_ensure (hb_##object##_t *object) \ +#define HB_SHAPER_DATA_ENSURE_DEFINE(shaper, object) \ +bool \ +HB_SHAPER_DATA_ENSURE_FUNC(shaper, object) (hb_##object##_t *object) \ {\ retry: \ HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, object) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \ diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc index 6e4db01..58f983d 100644 --- a/src/hb-uniscribe.cc +++ b/src/hb-uniscribe.cc @@ -293,8 +293,8 @@ struct range_record_t { unsigned int index_last; /* == end - 1 */ }; -HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, face) -HB_SHAPER_DATA_ENSURE_DECLARE(uniscribe, font) +HB_SHAPER_DATA_ENSURE_DEFINE(uniscribe, face) +HB_SHAPER_DATA_ENSURE_DEFINE(uniscribe, font) /* commit fc8189b63931f03c5d2e70dde198e9c856bd78f5 Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Feb 3 16:17:08 2017 -0800 Minor diff --git a/src/hb-shaper-private.hh b/src/hb-shaper-private.hh index d1d1146..9535841 100644 --- a/src/hb-shaper-private.hh +++ b/src/hb-shaper-private.hh @@ -65,9 +65,10 @@ struct hb_shaper_data_t { #define HB_SHAPER_DATA_INVALID ((void *) -1) #define HB_SHAPER_DATA_IS_INVALID(data) ((void *) (data) == HB_SHAPER_DATA_INVALID) -#define HB_SHAPER_DATA_TYPE(shaper, object) struct hb_##shaper##_shaper_##object##_data_t +#define HB_SHAPER_DATA_TYPE_NAME(shaper, object) hb_##shaper##_shaper_##object##_data_t +#define HB_SHAPER_DATA_TYPE(shaper, object) struct HB_SHAPER_DATA_TYPE_NAME(shaper, object) #define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(instance)->shaper_data.shaper) -#define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE (shaper, object, object) +#define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE(shaper, object, object) #define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_create #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_destroy commit d3d3691806aaa6aed93a88c845d472e727e7f850 Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Feb 3 15:42:03 2017 -0800 Add dirty-state tracking to hb_face_t diff --git a/src/hb-face-private.hh b/src/hb-face-private.hh index 43e7b1c..eb0e850 100644 --- a/src/hb-face-private.hh +++ b/src/hb-face-private.hh @@ -54,6 +54,13 @@ struct hb_face_t { mutable unsigned int upem; /* Units-per-EM. */ mutable unsigned int num_glyphs; /* Number of glyphs. */ + enum dirty_t { + NOTHING = 0x0000, + INDEX = 0x0001, + UPEM = 0x0002, + NUM_GLYPHS = 0x0004, + } dirty; + struct hb_shaper_data_t shaper_data; /* Various shaper data. */ /* Various non-shaping data. */ @@ -99,6 +106,8 @@ struct hb_face_t { HB_INTERNAL void load_num_glyphs (void) const; }; +HB_MARK_AS_FLAG_T (hb_face_t::dirty_t); + extern HB_INTERNAL const hb_face_t _hb_face_nil; #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS diff --git a/src/hb-face.cc b/src/hb-face.cc index 1ba9707..1800c99 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -51,6 +51,8 @@ const hb_face_t _hb_face_nil = { 1000, /* upem */ 0, /* num_glyphs */ + hb_face_t::NOTHING, /* dirty */ + { #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, #include "hb-shaper-list.hh" @@ -171,7 +173,7 @@ hb_face_create (hb_blob_t *blob, closure, (hb_destroy_func_t) _hb_face_for_data_closure_destroy); - hb_face_set_index (face, index); + face->index = index; return face; } @@ -365,6 +367,11 @@ hb_face_set_index (hb_face_t *face, if (face->immutable) return; + if (face->index == index) + return; + + face->dirty |= face->INDEX; + face->index = index; } @@ -400,6 +407,11 @@ hb_face_set_upem (hb_face_t *face, if (face->immutable) return; + if (face->upem == upem) + return; + + face->dirty |= face->UPEM; + face->upem = upem; } @@ -444,6 +456,11 @@ hb_face_set_glyph_count (hb_face_t *face, if (face->immutable) return; + if (face->num_glyphs == glyph_count) + return; + + face->dirty |= face->NUM_GLYPHS; + face->num_glyphs = glyph_count; } diff --git a/src/hb-font.cc b/src/hb-font.cc index cc0e6c3..a08766f 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1196,7 +1196,7 @@ hb_font_get_empty (void) NULL, /* user_data */ NULL, /* destroy */ - hb_font_t::NOTHING, /* dirty_bits */ + hb_font_t::NOTHING, /* dirty */ { #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, commit 2171f48b4b1e66a3c16a83cc00b0006d32ae9738 Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Feb 3 10:58:09 2017 -0800 Add dirty-state tracking to hb_font_t diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh index 53671d7..fbb16a0 100644 --- a/src/hb-font-private.hh +++ b/src/hb-font-private.hh @@ -116,6 +116,16 @@ struct hb_font_t { void *user_data; hb_destroy_func_t destroy; + enum dirty_t { + NOTHING = 0x0000, + FACE = 0x0001, + PARENT = 0x0002, + FUNCS = 0x0004, + SCALE = 0x0008, + PPEM = 0x0010, + VARIATIONS = 0x0020, + } dirty; + struct hb_shaper_data_t shaper_data; @@ -543,6 +553,8 @@ struct hb_font_t { } }; +HB_MARK_AS_FLAG_T (hb_font_t::dirty_t); + #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); #include "hb-shaper-list.hh" diff --git a/src/hb-font.cc b/src/hb-font.cc index db3ffcc..cc0e6c3 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1196,6 +1196,8 @@ hb_font_get_empty (void) NULL, /* user_data */ NULL, /* destroy */ + hb_font_t::NOTHING, /* dirty_bits */ + { #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, #include "hb-shaper-list.hh" @@ -1348,6 +1350,11 @@ hb_font_set_parent (hb_font_t *font, if (!parent) parent = hb_font_get_empty (); + if (parent == font->parent) + return; + + font->dirty |= font->PARENT; + hb_font_t *old = font->parent; font->parent = hb_font_reference (parent); @@ -1393,6 +1400,8 @@ hb_font_set_face (hb_font_t *font, if (font->face == face) return; + font->dirty |= font->FACE; + hb_face_t *old = font->face; font->face = hb_face_reference (face); @@ -1446,6 +1455,8 @@ hb_font_set_funcs (hb_font_t *font, if (!klass) klass = hb_font_funcs_get_empty (); + font->dirty |= font->FUNCS; + hb_font_funcs_reference (klass); hb_font_funcs_destroy (font->klass); font->klass = klass; @@ -1501,6 +1512,11 @@ hb_font_set_scale (hb_font_t *font, if (font->immutable) return; + if (font->x_scale == x_scale && font->y_scale == y_scale) + return; + + font->dirty |= font->SCALE; + font->x_scale = x_scale; font->y_scale = y_scale; } @@ -1542,6 +1558,11 @@ hb_font_set_ppem (hb_font_t *font, if (font->immutable) return; + if (font->x_ppem == x_ppem && font->y_ppem == y_ppem) + return; + + font->dirty |= font->PPEM; + font->x_ppem = x_ppem; font->y_ppem = y_ppem; } @@ -1574,6 +1595,15 @@ _hb_font_adopt_var_coords_normalized (hb_font_t *font, int *coords, /* 2.14 normalized */ unsigned int coords_length) { + if (font->num_coords == coords_length && + 0 == memcmp (font->coords, coords, coords_length * sizeof (coords[0]))) + { + free (coords); + return; + } + + font->dirty |= font->VARIATIONS; + free (font->coords); font->coords = coords; commit 95808bad2c17a9ef41c58c04faf1b4706fb7d72e Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Feb 3 10:39:40 2017 -0800 Add new API hb_font_set_face() For completeness. diff --git a/src/hb-font.cc b/src/hb-font.cc index 826d3e1..db3ffcc 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1372,6 +1372,35 @@ hb_font_get_parent (hb_font_t *font) } /** + * hb_font_set_face: + * @font: a font. + * @face: new face. + * + * Sets font-face of @font. + * + * Since: 1.4.3 + **/ +void +hb_font_set_face (hb_font_t *font, + hb_face_t *face) +{ + if (font->immutable) + return; + + if (unlikely (!face)) + face = hb_face_get_empty (); + + if (font->face == face) + return; + + hb_face_t *old = font->face; + + font->face = hb_face_reference (face); + + hb_face_destroy (old); +} + +/** * hb_font_get_face: * @font: a font. * diff --git a/src/hb-font.h b/src/hb-font.h index e2e5979..85fb56d 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -563,6 +563,10 @@ hb_font_set_parent (hb_font_t *font, HB_EXTERN hb_font_t * hb_font_get_parent (hb_font_t *font); +HB_EXTERN void +hb_font_set_face (hb_font_t *font, + hb_face_t *face); + HB_EXTERN hb_face_t * hb_font_get_face (hb_font_t *font); _______________________________________________ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz