Commit Graph

244 Commits

Author SHA1 Message Date
Behdad Esfahbod d1c00c0470 [COLR] Respect HB_NO_PAINT
Fixes https://github.com/harfbuzz/harfbuzz/issues/4204
2023-04-24 13:24:47 -06:00
Behdad Esfahbod 000a3c5dca [beyond-64k/subset] Fetch lsb from glyph table if not available
The beyond-64k hmtx table doesn't encode LSB. If subsetting brings
the glyph under 64k (which currently is the only mode we support),
then we need to encode the LSB, which wasn't available. We need to
fetch xMin from glyf table and set it as LSB.
2023-04-20 15:53:10 -06:00
Behdad Esfahbod ab191d9dc7 [ot-font] Minor division rounding 2023-02-11 09:31:21 -07:00
Behdad Esfahbod be1c14ee0a [embolden] Adjust font_h_extents 2023-02-07 13:52:53 -07:00
Behdad Esfahbod aef002e0d9 [embolden] Add in-place option
Adds --font-grade to hb-view and hb-shape.
2023-02-07 11:52:25 -07:00
Behdad Esfahbod 2119eab69f [embolden] Adjust advance values 2023-02-02 15:51:22 -07:00
Behdad Esfahbod b087266e51 [ot-font] Conditionalize emboldening 2023-02-02 15:51:22 -07:00
Behdad Esfahbod 36dcc9a432 [ot-font] Fix emboldening CFF 2023-02-02 15:51:22 -07:00
Behdad Esfahbod e39104ba19 [font/util] Add emboldening API, --font-bold
Needs documentation.
2023-02-02 15:51:22 -07:00
Behdad Esfahbod ae522a1372 [embolden] Rename to hb-outline 2023-02-02 15:51:22 -07:00
Behdad Esfahbod fda2f6f64e [embolden] Shuffle under hb_outline_t 2023-02-02 15:51:22 -07:00
Behdad Esfahbod 70149885a7 [font] Towards implementing emboldening 2023-02-02 15:51:22 -07:00
Behdad Esfahbod 7a4bd97e4a [layout] Build lookup accelerators lazily on-demand
Reduces memory consumption for large multi-script fonts
drastically.
2023-01-31 16:19:37 -07:00
Matthias Clasen 318aa10708 [ot-font] Use the cmap cache more
Use the cmap cache for get_nominal_glyph and
get_variation_glyph as well. The first of these
is used a lot in pango.
2023-01-29 09:17:17 -05:00
Behdad Esfahbod 5da829eaf5 [font] Comments 2023-01-28 22:18:53 -07:00
Behdad Esfahbod 544dd9678c [font] Fix unlikely 2023-01-28 22:06:46 -07:00
Behdad Esfahbod c1d0daf5f1 [font] unlikely 2023-01-28 22:05:24 -07:00
Behdad Esfahbod 30ee7a21e1 [font] Typo 2023-01-28 21:48:52 -07:00
Behdad Esfahbod f8a744d9d5 [ot-font] Add a cmap cache
Speeds up Roboto shaping by 7%, for 1kb per face.
2023-01-28 13:38:07 -07:00
Behdad Esfahbod 1b53ed3c41 [cache] Remove empty fini() 2023-01-28 13:38:07 -07:00
Matthias Clasen 4adc748b13 Move Color tables to src/OT/Color/ 2023-01-01 14:57:53 -07:00
Matthias Clasen 9be01b6bff [paint] Pass hb_paint_context_t along
Replace the font argument with a hb_paint_context_t
that carries the font, the palette index and the
foreground color.

The hb_font_paint_glyph() api now takes the palette
index and the foreground color as extra arguments.

Update all callers and regenerate test results.
2022-12-23 13:37:59 -07:00
Matthias Clasen 14b026ff86 [draw] Add hb_font_draw_glyph
hb_font_draw_glyph(), hb_font_draw_glyph_func_t and
hb_font_funcs_set_draw_glyph_func() are just alternative
names for hb_font_get_glyph_shape and friends, to better
align with hb_font_paint_glyph.
2022-12-23 13:37:59 -07:00
Matthias Clasen 0f287e75ec [paint] Rename hb_font_get_glyph_paint_func_t
The 'get' was just there due to implementation
choices. Work around that and call the vfunc
what it should be: hb_font_paint_glyph_func_t.
2022-12-23 13:37:59 -07:00
Matthias Clasen 6079173a52 Try paint_glyph for more tables
If the COLR table does not paint the glyph,
try SVG, CBDT and sbix too, before giving up
on color.
2022-12-23 13:37:59 -07:00
Matthias Clasen 9461ab7088 Try paint_glyph for more tables
If the COLR table can't paint the glyph,
try glyf, cff1 and cff2 too.
2022-12-23 13:37:59 -07:00
Matthias Clasen 6a48ac42f4 COLR implementation 2022-12-23 13:37:59 -07:00
Matthias Clasen 7a748ad4ac COLRv1: use ClipBoxes for extents
This is a first step; ultimatively, we
should compute the extents is ClipBoxes
are missing.
2022-12-11 13:12:30 -07:00
Behdad Esfahbod 6dfd4a16e7 [ot-font] Remove stale TODO 2022-11-16 22:44:22 -07:00
Khaled Hosny d2966d3919 [ot-font] Try CBDT extents before outline tables
Like we do for sbix table.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3827
2022-09-22 15:50:27 -06:00
Behdad Esfahbod c02a1a4adc [ot-font] Remove unused include 2022-09-20 17:40:13 -06:00
Behdad Esfahbod d7adc55e18 [ot-font] Allow 24bit glyphs in advance cache 2022-08-04 11:40:54 -06:00
Behdad Esfahbod ec90d1e161 [cache] Add a non-threadsafe version
Use in hb-ft, since already mutex'ed.
2022-08-03 13:01:04 -06:00
Behdad Esfahbod 86d1e22d4f [atomic-ptr] Rename get 2022-08-03 13:01:04 -06:00
Behdad Esfahbod d3f2287e0b [atomic-int] Rename get/set 2022-08-03 13:01:04 -06:00
Behdad Esfahbod a5d9012e94 Revert "[ot-font] Minor simplification"
This reverts commit 28c02b3768.

Old code was used in case of memory allocation failure (as shown
by fuzzers...)
2022-07-29 19:51:00 -06:00
Behdad Esfahbod 28c02b3768 [ot-font] Minor simplification 2022-07-29 15:55:16 -06:00
Behdad Esfahbod b0cb9a1a63 Make get_leading_bearing return bool
Fixes https://github.com/harfbuzz/harfbuzz/issues/3496

Part of supporting >64k glyphs correctly.
2022-07-03 15:32:32 -06:00
Behdad Esfahbod f46ddeba48 [hmtx/glyf] Rename side-bearing functions for clarity 2022-07-03 13:12:49 -06:00
Behdad Esfahbod ab5ce64313 [VVAR] Rename vorg function for clarity 2022-07-03 13:00:22 -06:00
Behdad Esfahbod b2d60cbd6e [glyf] Rename advance functions for clarity 2022-07-03 12:56:48 -06:00
Behdad Esfahbod 35c00c1216 [hmtx] Rename advance functions for clarity 2022-07-03 12:54:17 -06:00
Behdad Esfahbod b07fa2bb1a [ot-font] Respect VORG even if it has no variations 2022-07-03 12:39:55 -06:00
Behdad Esfahbod aba4a4957a [ot-font] Disable VORG variation code in HB_NO_VAR 2022-06-30 14:13:44 -06:00
Behdad Esfahbod d5921b379b [tt-font] Apply VVAR.vOrg variation to VORG origin
Mostly fixes https://github.com/harfbuzz/harfbuzz/issues/1694
2022-06-30 14:09:09 -06:00
Behdad Esfahbod eee29f7327 [hmtx] Specialize var_table 2022-06-30 14:09:09 -06:00
Behdad Esfahbod a719e67887 [ot-font] Use atomic ops for cache serial number
This guarantees the cache is coherent.
2022-05-26 05:02:50 -06:00
Behdad Esfahbod 5248b2567b [ot-font/h-advance] Adjust varStore cache condition
This gives best performance for short strings, now that we have a h-advance cache as well.
The en-words benchmark in particular, now ot-font is faster than ft.

Second to last line is of interest:

Before:
-----------------------------------------------------------------------------------------------------
Benchmark                                                           Time             CPU   Iterations
-----------------------------------------------------------------------------------------------------
BM_Shape/en-words.txt/Roboto-Regular.ttf/hb                      29.8 ms         29.8 ms           23
BM_Shape/en-words.txt/Roboto-Regular.ttf/ft                      30.4 ms         30.4 ms           23
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/hb           16.3 ms         16.3 ms           43
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/ft           16.5 ms         16.5 ms           42
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/hb       18.0 ms         18.0 ms           39
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/ft       17.8 ms         17.8 ms           39

After:
behdad@Behdads-MacBook-Pro harfbuzz % ninja -Cbuild && build/perf/benchmark-shape --benchmark_filter=en-words
-----------------------------------------------------------------------------------------------------
Benchmark                                                           Time             CPU   Iterations
-----------------------------------------------------------------------------------------------------
BM_Shape/en-words.txt/Roboto-Regular.ttf/hb                      30.0 ms         30.0 ms           23
BM_Shape/en-words.txt/Roboto-Regular.ttf/ft                      30.3 ms         30.3 ms           23
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/hb           16.3 ms         16.3 ms           43
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/ft           16.4 ms         16.4 ms           43
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/hb       17.6 ms         17.6 ms           40
BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/ft       17.8 ms         17.8 ms           39
2022-05-26 05:02:50 -06:00
Behdad Esfahbod 12fff976b6 [ot-var] Use atomic int for cached-serial 2022-05-26 05:02:50 -06:00
Behdad Esfahbod 0919eaa6e8 [ot-font] Remove lock around cache
Not needed.
2022-05-26 05:02:50 -06:00