src/hb-aat-layout-morx-table.hh | 13 +-- src/hb-dsalgs.hh | 6 + src/hb-set.hh | 4 - src/test-ot-color.cc | 135 ++++++++++++++++++---------------------- 4 files changed, 74 insertions(+), 84 deletions(-)
New commits: commit 5854d3fa251069f8158b97a831d1439c2ff8b510 Author: Behdad Esfahbod <[email protected]> Date: Wed Oct 31 10:42:49 2018 -0700 [set] Warning fix with gcc 8.1 https://github.com/harfbuzz/harfbuzz/pull/1334 diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index e8bd95c2..59df860d 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -610,8 +610,10 @@ struct HbOpXor template <typename elt_t, unsigned int byte_size> struct hb_vector_size_t { - elt_t& operator [] (unsigned int i) { return u.v[i]; } - const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + inline elt_t& operator [] (unsigned int i) { return u.v[i]; } + inline const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + + inline void clear (unsigned char v = 0) { memset (this, v, sizeof (*this)); } template <class Op> inline hb_vector_size_t process (const hb_vector_size_t &o) const diff --git a/src/hb-set.hh b/src/hb-set.hh index 2dfcc242..947e8d9d 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -53,8 +53,8 @@ struct hb_set_t struct page_t { - inline void init0 (void) { memset (reinterpret_cast<char*>(&v), 0, sizeof (v)); } - inline void init1 (void) { memset (reinterpret_cast<char*>(&v), 0xff, sizeof (v)); } + inline void init0 (void) { v.clear (); } + inline void init1 (void) { v.clear (0xFF); } inline unsigned int len (void) const { return ARRAY_LENGTH_CONST (v); } commit 850a7af3a419c6c4ab92bff59991758a2951d41f Author: Ebrahim Byagowi <[email protected]> Date: Wed Oct 31 14:20:23 2018 +0330 [ot-color-test] Remove the non-working exact strike size storing (#1339) diff --git a/src/test-ot-color.cc b/src/test-ot-color.cc index cb369c0f..1e492e66 100644 --- a/src/test-ot-color.cc +++ b/src/test-ot-color.cc @@ -23,7 +23,7 @@ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -#include "hb.hh" +#include "hb.h" #include "hb-ot.h" #include "hb-ft.h" @@ -40,74 +40,6 @@ #include <stdio.h> static void -png_dump (hb_face_t *face, unsigned int face_index) -{ - unsigned glyph_count = hb_face_get_glyph_count (face); - hb_font_t *font = hb_font_create (face); - - /* ugly hack, scans the font for strikes, not needed for regular clients */ - #define STRIKES_MAX 20 - unsigned int strikes_count = 0; - unsigned int strikes[STRIKES_MAX] = {0}; - { - /* find a sample glyph */ - unsigned int sample_glyph_id; - /* we don't care much about different strikes for different glyphs */ - for (sample_glyph_id = 0; sample_glyph_id < glyph_count; sample_glyph_id++) - { - hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); - unsigned int blob_length = hb_blob_get_length (blob); - hb_blob_destroy (blob); - if (blob_length != 0) - break; - } - /* find strikes it has */ - unsigned int upem = hb_face_get_upem (face); - unsigned int blob_length = 0; - for (unsigned int ppem = 1; ppem <= upem && strikes_count < STRIKES_MAX; ppem++) - { - hb_font_set_ppem (font, ppem, ppem); - hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); - unsigned int new_blob_length = hb_blob_get_length (blob); - if (blob_length != new_blob_length) - { - strikes_count++; - blob_length = new_blob_length; - } - if (strikes_count != 0) - strikes[strikes_count - 1] = ppem; - hb_blob_destroy (blob); - } - /* can't report the biggest strike correctly, and, we can't do anything about it */ - } - #undef STRIKES_MAX - - for (unsigned int strike = 0; strike < strikes_count; strike++) - for (unsigned int glyph_id = 0; glyph_id < glyph_count; glyph_id++) - { - unsigned int ppem = strikes[strike]; - hb_font_set_ppem (font, ppem, ppem); - hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, glyph_id); - - if (hb_blob_get_length (blob) == 0) continue; - - unsigned int length; - const char *data = hb_blob_get_data (blob, &length); - - char output_path[255]; - sprintf (output_path, "out/png-%d-%d-%d.png", glyph_id, strike, face_index); - - FILE *f = fopen (output_path, "wb"); - fwrite (data, 1, length, f); - fclose (f); - - hb_blob_destroy (blob); - } - - hb_font_destroy (font); -} - -static void svg_dump (hb_face_t *face, unsigned int face_index) { unsigned glyph_count = hb_face_get_glyph_count (face); @@ -136,6 +68,63 @@ svg_dump (hb_face_t *face, unsigned int face_index) } } +/* _png API is so easy to use unlike the below code, don't get confused */ +static void +png_dump (hb_face_t *face, unsigned int face_index) +{ + unsigned glyph_count = hb_face_get_glyph_count (face); + hb_font_t *font = hb_font_create (face); + + /* scans the font for strikes */ + unsigned int sample_glyph_id; + /* we don't care about different strikes for different glyphs at this point */ + for (sample_glyph_id = 0; sample_glyph_id < glyph_count; sample_glyph_id++) + { + hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); + unsigned int blob_length = hb_blob_get_length (blob); + hb_blob_destroy (blob); + if (blob_length != 0) + break; + } + + unsigned int upem = hb_face_get_upem (face); + unsigned int blob_length = 0; + unsigned int strike = 0; + for (unsigned int ppem = 1; ppem <= upem; ppem++) + { + hb_font_set_ppem (font, ppem, ppem); + hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, sample_glyph_id); + unsigned int new_blob_length = hb_blob_get_length (blob); + hb_blob_destroy (blob); + if (new_blob_length != blob_length) + { + for (unsigned int glyph_id = 0; glyph_id < glyph_count; glyph_id++) + { + hb_blob_t *blob = hb_ot_color_glyph_reference_png (font, glyph_id); + + if (hb_blob_get_length (blob) == 0) continue; + + unsigned int length; + const char *data = hb_blob_get_data (blob, &length); + + char output_path[255]; + sprintf (output_path, "out/png-%d-%d-%d.png", glyph_id, strike, face_index); + + FILE *f = fopen (output_path, "wb"); + fwrite (data, 1, length, f); + fclose (f); + + hb_blob_destroy (blob); + } + + strike++; + blob_length = new_blob_length; + } + } + + hb_font_destroy (font); +} + static void layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int face_index) { @@ -144,7 +133,7 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int unsigned glyph_count = hb_face_get_glyph_count (face); for (hb_codepoint_t gid = 0; gid < glyph_count; ++gid) { - unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, nullptr, nullptr); + unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, NULL, NULL); if (!num_layers) continue; @@ -181,7 +170,7 @@ layered_glyph_dump (hb_face_t *face, cairo_font_face_t *cairo_face, unsigned int for (unsigned int palette = 0; palette < palette_count; palette++) { char output_path[255]; - unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, nullptr, nullptr); + unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, NULL, NULL); if (!num_colors) continue; @@ -282,14 +271,14 @@ main (int argc, char **argv) FILE *font_name_file = fopen ("out/.dumped_font_name", "r"); - if (font_name_file != nullptr) + if (font_name_file != NULL) { fprintf (stderr, "Purge or move ./out folder in order to run a new dump\n"); exit (1); } font_name_file = fopen ("out/.dumped_font_name", "w"); - if (font_name_file == nullptr) + if (font_name_file == NULL) { fprintf (stderr, "./out is not accessible as a folder, create it please\n"); exit (1); commit 2e639c47c9d35ff7dc4dde21f744f9ee695a27f3 Author: Ebrahim Byagowi <[email protected]> Date: Wed Oct 31 14:20:14 2018 +0330 [aat] Fix older compilers by not referencing enum directly (#1340) diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 51bb3b33..45dbc28a 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -427,13 +427,12 @@ struct LigatureSubtable typedef LigatureEntry<Types::extended> LigatureEntryT; typedef typename LigatureEntryT::EntryData EntryData; - typedef typename LigatureEntryT::Flags Flags; struct driver_context_t { enum { - DontAdvance = LigatureEntry<Types::extended>::DontAdvance, + DontAdvance = LigatureEntryT::DontAdvance, }; static const bool in_place = false; enum LigActionFlags @@ -470,7 +469,7 @@ struct LigatureSubtable unsigned int flags = entry->flags; DEBUG_MSG (APPLY, nullptr, "Ligature transition at %d", buffer->idx); - if (flags & Flags::SetComponent) + if (flags & LigatureEntryT::SetComponent) { if (unlikely (match_length >= ARRAY_LENGTH (match_positions))) return false; commit 642c9dcf1b34b51ffdbf88ccbef4762aa12a5cbe Author: Ebrahim Byagowi <[email protected]> Date: Wed Oct 31 14:02:37 2018 +0330 [aat] Minor, remove extra semicolons diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 08a380a4..51bb3b33 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -388,11 +388,11 @@ struct LigatureEntry<true> template <typename Flags> static inline bool performAction (Flags flags) - { return flags & PerformAction; }; + { return flags & PerformAction; } template <typename Entry, typename Flags> static inline unsigned int ligActionIndex (Entry &entry, Flags flags) - { return entry->data.ligActionIndex; }; + { return entry->data.ligActionIndex; } }; template <> struct LigatureEntry<false> @@ -412,11 +412,11 @@ struct LigatureEntry<false> template <typename Flags> static inline bool performAction (Flags flags) - { return flags & Offset; }; + { return flags & Offset; } template <typename Entry, typename Flags> static inline unsigned int ligActionIndex (Entry &entry, Flags flags) - { return flags & 0x3FFF; }; + { return flags & 0x3FFF; } }; _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
