Commit Graph
20023 Commits
Author SHA1 Message Date
Behdad Esfahbod 15eb6bdb32 [hb-draw] Set variations on the upem font 2026-02-16 16:10:23 -03:00
dependabot[bot] bba8eef5a6 Bump github/codeql-action from 4.32.2 to 4.32.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.32.2 to 4.32.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2...9e907b5e64f6b83e7804b09294d44122997950d6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.32.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-16 14:12:29 +02:00
Behdad Esfahbod c63fcd1684 Merge pull request #5745 from solbjorn/dwrite
[hb-directwrite] Fix building with `HB_DISABLE_DEPRECATED`
2026-02-15 19:23:48 -07:00
Alexander Lobakin 7d67028e08 [hb-directwrite] Fix building with HB_DISABLE_DEPRECATED
Fix the following build error with HB_DISABLE_DEPRECATED:

In file included from harfbuzz\src\harfbuzz.cc:14:
harfbuzz\src\hb-directwrite.cc(468,1): error : no previous prototype
for function 'hb_directwrite_font_get_dw_font'
[-Werror,-Wmissing-prototypes]
    468 | hb_directwrite_font_get_dw_font (hb_font_t *font)
        | ^

hb_directwrite_font_get_dw_font() is guarded with
HB_DISABLE_DEPRECATED only in the header file, but not in the .cc.

Signed-off-by: Alexander Lobakin <alobakin@mailbox.org>
2026-02-16 02:28:45 +01:00
Khaled Hosny c763763662 [buffer-serialize] Fix calculating absolute offsets with partial range
Fixes https://github.com/harfbuzz/harfbuzz/issues/5743
2026-02-15 17:30:16 +02:00
Behdad Esfahbod 79ccd2112a Handle a couple of degenerate cases in solve_itp() 2026-02-15 10:19:27 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 f33645dd8b [util] Fix multiple bugs in drawing utilities
Fixed three bugs found during code review:

1. Division by zero in normalize_pt(): Added check to return {0, 0}
   when normalizing a zero-length vector, preventing NaN values in
   sweep gradient rendering.

2. Memory leak in get_color_stops(): Now properly frees old memory
   before reallocating and checks for malloc failure to prevent
   null pointer dereference.

3. Integer division in helper_cairo_create_context(): Fixed missing
   decimal point causing integer division (br / 255) instead of
   floating-point division, which resulted in incorrect alpha
   channel calculations for color blending.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 10:12:43 -03:00
Behdad Esfahbod d0df361a82 [util] Fix color parsing
Eg. "fff" was getting some non-ff alpha.
2026-02-15 09:26:23 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 22d8dbfe81 [hb-draw] Fix PNG image Y positioning
Position PNG images at y_bearing to place them correctly in the glyph box.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 08:07:02 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 882f405e52 [hb-draw] Fix PNG image positioning in SVG output
Position PNG images at bottom-left of glyph box for correct rendering.
Uses y_bearing + height to account for negative height values in glyph extents.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 08:05:07 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 96884e9e09 [hb-draw] Fix PNG color-font rendering
PNG color-fonts (like Apple Color Emoji's sbix table) were not being
rendered by hb-draw. There were two issues:

1. probe_paint_funcs had no callbacks registered, so HarfBuzz couldn't
   detect PNG glyphs as color glyphs. Fixed by adding a simple
   probe_paint_image callback that returns true.

2. PNG images were using negative height directly in SVG <image>
   elements, which doesn't work properly. Fixed by wrapping PNG images
   in a <g> element with a transform that handles coordinate system
   flip, similar to how SVG embedded images are handled.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 07:58:24 -03:00
Behdad Esfahbod dc3303963c [update-unicode-tables.make] Add 'touch' target
To force regeneration.
2026-02-14 21:32:11 -03:00
Behdad Esfahbod 3a827474c0 Merge pull request #5735 from harfbuzz/hb-draw
Add `hb-draw`
2026-02-14 17:26:33 -07:00
Behdad EsfahbodandClaude Sonnet 4.5 49c1678b75 [test] Update draw tests after removing --quiet option
- Remove tests for --quiet/-q option
- Change --ned to --flat in remaining tests
- Remove expected output files for quiet tests

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 18:28:48 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 e7bbd69a90 [hb-draw] Remove --quiet option and all related code
Removes the --quiet/-q option that output raw path data only.
This simplifies the codebase by eliminating the write_raw_paths()
function and associated logic.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 18:26:36 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 a29bbc1ec6 [hb-draw] Change scale precision from 5 to 7
This increases the precision of scale and transform values in SVG output
for better accuracy in rendering.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 18:25:32 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 7e28124b19 [hb-draw] Rename --ned to --flat
Renames --ned option to --flat for better clarity. The option flattens
geometry and disables reuse of glyph definitions in SVG output.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 18:22:47 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 ac76eba763 [hb-draw] Add missing unordered_map include
Fixes compilation error when using std::unordered_map for glyph extents cache.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 16:50:06 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 30ca201fff [hb-draw] Cache glyph extents in hashtable to avoid redundant lookups
Uses std::unordered_map to cache hb_glyph_extents_t by glyph ID, avoiding
redundant hb_font_get_glyph_extents() calls when the same glyph appears
multiple times (e.g., 'e' in "speed").

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 16:40:55 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 31242fdfc6 [hb-draw] Support --logical --ink together for union of both extents
When both --logical and --ink are specified, the bounding box is computed as
the union of logical and ink extents, providing maximum coverage. This matches
the behavior of specifying both flags in hb-view.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 16:38:31 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 00785bb962 [hb-draw] Add --logical and --ink options for bounding box control
Adds --logical (default) and --ink options to control bounding box calculation.
--logical uses font logical extents (ascender/descender), --ink uses actual
glyph ink extents for a tighter bounding box. Default behavior is --logical.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 16:36:31 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 fc1967a91b [hb-draw] Add --margin option with default of 0
Adds --margin option similar to hb-view but with default of 0 instead of 16.
Accepts 1-4 space-separated numbers (top right bottom left, with CSS-style
fallback logic). Expands SVG viewBox and dimensions accordingly.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 11:55:29 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 1f0c492a72 [hb-draw] Make --foreground work for all fonts by wrapping in fill group
Previously foreground only worked for color fonts. Now it works for all fonts
by wrapping content in a compact <g fill="..."> element that applies to all
child elements. Supports RGB and RGBA colors with transparency.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 11:51:18 -03:00
Behdad EsfahbodandClaude Sonnet 4.5 e0362c34a4 [hb-draw] Add --background option for SVG background color
Adds --background command-line option to hb-draw, similar to hb-view/hb-cairo.
Supports RGB and RGBA color formats (rrggbb[aa]). Background is rendered as
an SVG rect element covering the viewBox when specified.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 11:41:45 -03:00
Garret Rieger 07e48ef1f0 Fix two bugs in hb_set_is_subset().
1. If smaller set has empty pages the subset checking logic was incorrectly incrementing the larger page index after skipping the empty smaller page index.
2. The logic for is_subset() on mixed inverted/not inverted sets was wrong.
2026-02-13 15:06:01 -07:00
Behdad Esfahbod 6675656bff Update Unicode tables to packtab 1.2.0 2026-02-12 20:06:26 -05:00
Behdad Esfahbod 8f7733c7ff Regenerate Unicode tables with newer packtab 1.1.0 2026-02-12 19:44:29 -05:00
Behdad EsfahbodandClaude Sonnet 4.5 e5ebd0465c [hb-draw] Add color glyph reuse in defs for smaller SVG output
Color glyphs are now defined once in <defs> and reused via <use> elements,
similar to non-color glyphs. Previously each color glyph instance rendered
the full paint operations inline, causing duplication.

Tested with repeating emoji: reduces SVG size by ~44% for files with
repeated color glyphs (e.g., 3 emoji instances: 5.8KB vs 11KB without reuse).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad EsfahbodandClaude Opus 4.6 e5a8f3c325 [hb-draw] Fix color glyph rendering at non-upem font sizes
In reuse mode, the outer scale(font_scale_x, -font_scale_y) wrapper
already flips Y. The color glyph wrapper was incorrectly also applying
scale(1,-1), causing a double Y-flip that made the output appear
off-bounds at any font size other than upem.

Now only apply scale(1,-1) in upem_scale mode (no outer wrapper).
Also restore precision 9 for 1/upem scale values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad EsfahbodandClaude Opus 4.6 585be5163e [hb-draw] Double sweep gradient subdivision for smoother rendering
Reduce MAX_ANGLE from pi/8 to pi/16, producing ~32 slices per full
circle instead of ~16. This reduces visible color banding in sweep
gradient approximation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad EsfahbodandClaude Opus 4.6 2965686b15 [hb-draw] Use higher precision (min 5) for transform/scale values
Coordinate data uses the user's --precision (default 2), but scale and
transform matrix values need more decimal places to avoid compounding
rounding errors. Add scale_precision() helper that returns max(precision, 5).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad EsfahbodandClaude Opus 4.6 1c32b69fe3 [hb-draw] Fix color font scaling by creating upem_font from face directly
Creating upem_font as a sub-font of the main font (which has scale =
upem * 64 due to subpixel bits) caused the paint API to emit spurious
parent→child scale transforms. With precision=2 rounding, 1/64 rounds
to 0.02 and 0.02*64 = 1.28, destroying the mathematical cancellation
and making color glyphs ~1.6x too large.

Fix by creating upem_font directly from the face, eliminating the
parent-child relationship. Update expected test outputs accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad EsfahbodandClaude Opus 4.6 6ec56f5442 [hb-draw] Add color font rendering via paint API → SVG
Render COLRv0/v1, CBDT/sbix bitmaps, and SVG table glyphs as rich SVG
with colors, gradients, compositing, and inlined bitmap images using
hb_font_paint_glyph(). Falls back to monochrome outlines when no color
data is available.

New options: --no-color, --palette N, --foreground rrggbb[aa]

Glyph outline paths are stored as shared <defs> and reused by both
display <use> elements and <clipPath> references, avoiding duplicate
path data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 15:26:19 -07:00
Behdad Esfahbod fe9a8de890 [hb-svg-compare] Try normalize paths to drop degenerate lineto's
Such that we can compare to both FreeType and Fontations.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod 77d3ed5e75 [hb-draw] Use 6 bits of subpixel
Helps hb-ft since that doesn't work in floats all through.
Other backends should be unaffected.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod 1fdfbcd78e Revert "[glyf/path-builder] Don't emit no-op contour-final line-to"
This reverts commit b53ce9c7efe73443e7b73a3b1898891c1954b1a6.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod fe58d1bd0d [hb-draw-compare] Fix sorting 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 8a5e9536e3 [hb-draw-compare] Simplify sharding; remove non-sharded path 2026-02-12 15:26:19 -07:00
Behdad Esfahbod abb15ee099 [hb-draw-compare] Implement multiprocessing for hb-svg-compare stage 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 8c525f0abe [glyf/path-builder] Don't emit no-op contour-final line-to
Match FT/fontations better.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod aff053af24 [hb-draw-compare] Switch from hb-view to hb-draw
MASSIVE speedup!
2026-02-12 15:26:19 -07:00
Behdad Esfahbod 431502033b [draw/run-tests.py] Use batching 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 8121167f69 [draw/run-tests] Simplify 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 2caa4c22a5 [draw] Change conditional tests 2026-02-12 15:26:19 -07:00
Behdad Esfahbod e6346b63bf [draw] Add VARC tests 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 7bbc027e11 [test/draw] Add more tests / change naming 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 529043f033 [hb-draw] More tests 2026-02-12 15:26:19 -07:00
Behdad Esfahbod bac47189b2 [hb-draw] viewbox only use logical extents
Removes the get_glyph_extents loop completely. Simpler.
2026-02-12 15:26:19 -07:00
Behdad Esfahbod b405bc1724 [hb-draw] Centralize layout math 2026-02-12 15:26:19 -07:00
Behdad Esfahbod 69a4f5f501 [hb-draw] Change subpixel bits to 0 2026-02-12 15:26:19 -07:00