Commit Graph
21309 Commits
Author SHA1 Message Date
Behdad EsfahbodandClaude Opus 4.7 d3a1de25e3 [array] Replace std::sort with internal sort_r_simple
std::sort instantiates several internal STL helpers
(__introsort_loop, __insertion_sort, __adjust_heap, __heap_select,
__unguarded_linear_insert) as weak symbols in the std:: namespace.
These leaked into libharfbuzz.so for every distinct (T, Compar)
pair, polluting the public ABI surface.

Route hb_array_t::qsort(Compar) through our existing templated
sort_r_simple instead.  The comparator is still inlined into the
sort body (sort_r_simple has been comparator-templated since
05762b2fac).

Drop the bool-returning comparator overload in favor of a single
int-sign convention; convert the call sites added during the
std::sort migration back to int-sign comparators.

Step 1 of two: this restores ABI hygiene at the cost of typed-
element swap (sort_r_simple swaps byte-by-byte).  A follow-up
will introduce a typed sort to recover that perf.

Tested: 240/240 tests pass; nm -D libharfbuzz.so shows zero
remaining _ZSt sort weak symbols.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 11:32:17 -06:00
Qunxin Liu 209a7237b9 [repacker] fuzzer fix: duplicate shared liga_sets before splitting (#5972)
fix for: https://oss-fuzz.com/testcase-detail/5291844211900416
2026-05-01 14:50:05 -06:00
Sergei Lopatin ef1b37502a [ft] Bump minimum freetype version to 2.8.0 (20.0.14)
e31ea830c8 added use of FT_Set_Default_Properties,
which was introduced in FreeType 2.8.

Reference: https://freetype.org/freetype2/docs/reference/ft2-module_management.html#ft_set_default_properties
2026-04-30 19:29:02 +03:00
Andrew Tribick ab6aa4f449 Allow line-ending changes in gen-gpu-shader-artifacts.py (#5968) 2026-04-28 13:59:28 -06:00
Behdad Esfahbod e6741e2205 [harfbuzz-world] Fix macros
Fixes https://github.com/harfbuzz/uharfbuzz/pull/289#discussion_r3149665614
2026-04-28 15:52:29 +03:00
dependabot[bot] 79784ef4db Bump meson from 1.11.0 to 1.11.1 in /.ci
Bumps [meson](https://github.com/mesonbuild/meson) from 1.11.0 to 1.11.1.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.11.0...1.11.1)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.11.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-27 19:10:07 +03:00
dependabot[bot] 00cbd9850a Bump hendrikmuhs/ccache-action from 1.2.22 to 1.2.23
Bumps [hendrikmuhs/ccache-action](https://github.com/hendrikmuhs/ccache-action) from 1.2.22 to 1.2.23.
- [Release notes](https://github.com/hendrikmuhs/ccache-action/releases)
- [Commits](https://github.com/hendrikmuhs/ccache-action/compare/33522472633dbd32578e909b315f5ee43ba878ce...d62db5f07c26379fc4b4e0916f098a92573c3b03)

---
updated-dependencies:
- dependency-name: hendrikmuhs/ccache-action
  dependency-version: 1.2.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-27 19:09:33 +03:00
Behdad Esfahbod 73db8cc1a5 [gpu] Fix HLSL paint fragment compile error
At least on wine this was needed.
2026-04-23 03:18:15 -06:00
Behdad Esfahbod f7511709ee [gpu] Remove outdated comment 2026-04-23 02:40:49 -06:00
Behdad Esfahbod 1b9c0c9dd6 [subset/gvar] Protect against overflow on 32bit systems 2026-04-22 13:17:59 -06:00
璀境石 74396731ad [cmake] Fix missing hb-static.cc in gpu target (#5960) 2026-04-21 21:33:16 -06:00
Behdad Esfahbod 0091ae360e [hb-config.hh] Tweak HB_TINY / HB_NO_DRAW / HB_NO_CFF relationship
Fixes https://github.com/harfbuzz/harfbuzz/issues/5955
2026-04-22 00:30:35 +02:00
璀境石 14d1d035cc [cmake] Add a .gitignore file to build directory (inspired by Meson) (#5957) 2026-04-21 08:56:46 -06:00
dependabot[bot] d25e930364 Bump meson from 1.10.2 to 1.11.0 in /.ci
Bumps [meson](https://github.com/mesonbuild/meson) from 1.10.2 to 1.11.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.10.2...1.11.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-21 02:09:46 +02:00
dependabot[bot] e8fbf406c4 Bump github/codeql-action from 4.35.1 to 4.35.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.35.1 to 4.35.2.
- [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/c10b8064de6f491fea524254123dbe5e09572f13...95e58e9a2cdfd71adc6e0353d5c52f41a045d225)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-20 15:27:05 +02:00
Khaled Hosny b0ffab42d4 14.2.0 14.2.0 2026-04-20 05:10:48 +02:00
Behdad Esfahbod 6988bda8ac [gpu] Move blob-recycling from gpu to blob.hh 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 98202cd72f [gpu-paint] Cosmetic 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 90ba85bebc [gpu-draw] Cosmetic 2026-04-20 01:29:49 +02:00
Behdad Esfahbod d26e90c6c8 [gpu] Add HB_GPU_SHADER_LANG_INVALID 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 521d7b2e99 [vector] Approximate a couple of Porter-Duff modes
The rest need structural change.
2026-04-20 01:29:49 +02:00
Behdad Esfahbod 1ae32fb6a7 [vector-pdf] Clean up color-stop passing around 2026-04-20 01:29:49 +02:00
Behdad Esfahbod f433a59dac [vector-svg] Cosmetic 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 0b718a9f09 [raster/vector/gpu] Streamline color-stop fetching 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 74514fc7d6 [vector-svg] Streamline set_svg_prefix() 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 6ef43b340d [hb-vector] Touchups 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 067539a45d [raster] Rename hb-raster-utils.hh to hb-raster.hh 2026-04-20 01:29:49 +02:00
Behdad Esfahbod 7a7fbdd173 [NEWS] Typos 2026-04-19 13:08:19 -06:00
Behdad Esfahbod a7bcaac21a Merge pull request #5948 from harfbuzz/vector-no-reuse-no-pen
[vector/raster] Simplify draw/paint API
2026-04-19 12:55:24 -06:00
Behdad Esfahbod e5755c8274 [raster/vector] Address review feedback 2026-04-19 12:52:17 -06:00
parasol-aserandjeffhuang 1ea68a9f57 [fontations] Fix OOB write on glyph-name callback with size == 0 (#5946) (#5947)
* [fontations] Fix OOB write on glyph-name callback with size == 0

The Rust `_hb_fontations_glyph_name()` callback computed
`glyph_name.len().min(size as usize - 1)`. When a caller passed
`size == 0`, `size as usize - 1` underflowed a `usize` to
`usize::MAX`, the `min()` clamp collapsed to `glyph_name.len()`,
and the subsequent `copy_nonoverlapping` / trailing NUL wrote
`glyph_name.len() + 1` bytes into a zero-capacity caller buffer.
This is an out-of-bounds write reachable from the public API
whenever the build was configured with `-Dfontations=enabled`
and the application had called `hb_fontations_font_set_funcs()`.

Short-circuit the `size == 0` case before the subtraction.
Return `true` in that case to match the existing post and CFF1
backends (`hb-ot-post-table.hh`, `hb-ot-cff1-table.hh`), which
both early-out with `return true` on `!buf_len` — the glyph
does have a name; we simply had no buffer to write it into.

Regression tests added in `test/api/test-glyph-names.c` cover
the zero-size path on post and CFF1 backends, a sub-font, a
NULL buffer, and `size == 1` / small-buffer / exact-fit cases
so the truncation path does not silently regress.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/5946
Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [font] Reject glyph-name lookups with size == 0 at the wrapper

`hb_font_t::get_glyph_name()` previously pre-wrote the trailing
NUL only when `size != 0` but still dispatched to the backend
callback with `size == 0`. Every current glyph-name backend has
to re-validate that argument: `post` and `cff1` short-circuit
with `return true`, the new Rust `fontations` callback now
short-circuits too (prior commit), and the CoreText callback in
`hb-coretext-font.cc` has a structurally similar `(CFIndex)size
- 1` pattern.

Normalize this at the wrapper layer: return `false` immediately
on `size == 0`, before any backend dispatch and before the
`*name = '\0'` write. This makes the zero-size case a single,
auditable no-op for every glyph-name provider (native or Rust,
current or future) and removes the CoreText underflow from the
reachable surface through the same chokepoint.

Observable change: callers that invoked
`hb_font_get_glyph_name(font, gid, buf, 0)` on post/cff1 backed
fonts used to get `true` back; they now get `false`. `size == 0`
queries carry no useful information for the caller, so this is
considered a safe hardening rather than a contract break.

Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [font] Preserve glyph-name zero-size probe semantics

Keep `hb_font_get_glyph_name(..., NULL, 0)` as a valid
return-value-only probe instead of rejecting `size == 0` in the
wrapper.

Fix the remaining backend-specific zero-size paths in hb-ft and
hb-coretext-font so they answer the probe without dereferencing the
caller buffer, and update the API tests to assert the preserved
behavior.

Testing: CCACHE_DISABLE=1 meson test -C build test-glyph-names
Testing: CCACHE_DISABLE=1 meson test -C build test-ft
Assisted-by: OpenAI Codex <codex@openai.com>

---------

Co-authored-by: jeffhuang <jeff@docker.xydrsucermoubd24xgo33yhsgd.bx.internal.cloudapp.net>
2026-04-18 19:54:54 -06:00
David Corbett 27f1be922e [indic] Categorize U+1CF5 and U+1CF6 as CS (#5949) 2026-04-18 19:54:27 -06:00
Behdad Esfahbod e134bb760e [vector] Strip clip-glyph dedup in SVG paint
push_clip_glyph kept a hash + linear-scan cache of emitted
clip paths to dedup repeated clip-glyph uses within a single
COLRv1 paint tree.  With paint contexts being one-glyph per
use, the cache mostly churned; it also made hb_memcmp trip
on sanitizer-null when an empty path matched an equally-empty
existing entry (fuzzer-reached null-deref).

Drop the cache: always emit a fresh <path> + <clipPath> pair
per push_clip_glyph.  Removes defined_paths / content_entry_t
from the paint struct.

Regenerate the two handwriting COLR expected SVGs whose
clip-reuse now produces distinct path defs.

Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 13:07:05 -06:00
Behdad Esfahbod e5c87cf042 [util/vector] Produce Y-up extents for auto-fit box
include_point used to flip Y so the computed line-box extents
matched the old Y-down internal model.  With the library now
tracking extents in Y-up (font) space and wrapping SVG body
in <g transform="scale(1,-1)">, that flip sent the auto-fit
viewBox above the glyph ink instead of around it.

Regenerate the vector expected SVGs that had captured the
shifted viewBox.

Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 12:48:23 -06:00
Behdad Esfahbod 99ffe47b10 [vector] Normalize extents in set_extents
Accept caller-supplied extents in any orientation and
normalize to min-corner origin with positive width/height.
Lets callers use the glyph-extents-style {top, -height} form
matching hb_glyph_extents_t convention, and brings set_extents
in line with the Y-up internal model the paint/draw contexts
now use.

Assisted-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 12:48:13 -06:00
Behdad Esfahbod b3c3e6a818 [vector] Add public hb_vector_draw_new_path() API
Exposes the path separation as a public function so callers
using the draw funcs directly can separate glyph outlines.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:41:44 -06:00
Behdad Esfahbod 750df72e2b [NEWS/docs] Update for vector API changes
- Remove draw svg_prefix from New API list and sections.txt
- Document pen_x/pen_y removal, dedup removal, _glyph
  simplification in the Vector library section

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:36:05 -06:00
Behdad Esfahbod 31c518df7a [raster] Push/pop transform in paint _glyph_impl, not ensure_initialized
Remove the initial base_transform push from ensure_initialized.
Instead, _glyph_impl pushes/pops the positioning transform via
the paint funcs, matching the vector paint model.

current_transform() returns identity when the stack is empty.
pop_transform allows popping to empty (for the final glyph-level
pop).

This makes changing set_transform between glyph calls work
correctly — the transform is applied fresh for each glyph.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:31:12 -06:00
Behdad Esfahbod 36174584ba [vector/raster/gpu] Document _glyph functions as convenience
Each _glyph_or_fail function now documents what it is
equivalent to in terms of the underlying font draw/paint
API + the context's own funcs.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:19:55 -06:00
Behdad Esfahbod cf57fa72a7 [vector] Unify ensure_initialized, remove PDF duplicate
Remove hb_pdf_paint_ensure_initialized — it was identical to
paint->ensure_initialized().  All PDF callbacks now call the
common method.  Remove redundant call from _glyph_impl since
paint callbacks handle it.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:13:12 -06:00
Behdad Esfahbod 127f060681 [raster] Move decl around 2026-04-18 10:58:44 -06:00
Behdad Esfahbod 57e056a22c [vector] Return nullptr from paint get_funcs for invalid format
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 10:58:31 -06:00
Behdad Esfahbod dfef3f33ae [vector] Global Y-flip in SVG render, eliminate per-glyph flips
SVG render now wraps all body content in a single
<g transform="scale(1,-1)">.  All coordinates inside are
in Y-up (font) space.  The viewBox maps the flipped range.

This eliminates:
- Per-path scale(1,-1) wrappers in draw flush_path_svg
- Per-glyph Y-flip in paint _glyph_impl's push_transform
- The {-xy, -yy, -ty} negation in extents transforms
- Format switch in paint _glyph_impl

paint _glyph_impl now passes the raw transform to
push_transform — no format knowledge needed.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 04:50:21 -06:00
Behdad Esfahbod 2be60ac235 [vector] Strip paint SVG dedup, simplify paint _glyph_impl
Remove content-based color glyph dedup from paint — no more
<defs>/<use> for color glyphs.  Each glyph's paint output is
emitted inline, wrapped by push_transform/pop_transform from
the paint funcs (which emit <g transform="..."> for SVG and
q cm ... Q for PDF).

_glyph_impl is now format-agnostic: extend extents,
push_transform, paint, pop_transform.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 04:40:39 -06:00
Behdad Esfahbod bc3713f5f5 [vector] Add new_path(), make _glyph_or_fail trivially thin
_glyph_or_fail is now: extend extents, new_path, draw.
No format switch, no flush — just accumulate.

new_path() flushes any pending path and starts a fresh one,
separating glyph outlines so they don't interact under fill
rules.

Flush also happens on foreground change and at render time,
so the last pending path is always emitted.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 04:14:34 -06:00
Behdad Esfahbod 82734f4ce5 [vector] Simplify draw _glyph_or_fail to just draw + flush
Remove format switch from _glyph_or_fail — it now just extends
extents, calls hb_font_draw_glyph with the context's own funcs,
and flushes.  All format-specific work is in flush_path() and
the draw callbacks.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 04:06:26 -06:00
Behdad Esfahbod 992835a182 [vector] Strip SVG dedup from draw, remove svg_prefix API
Draw SVG output is now flat inline <path> elements — no
<defs>, no <use>, no id references.  Each glyph is an
independent <path d="..." transform="..." fill="..."/>.

Remove hb_vector_draw_set_svg_prefix / get_svg_prefix since
draw output no longer emits any ids.  Paint keeps svg_prefix
for gradient and clip ids which SVG requires.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 03:56:32 -06:00
Behdad Esfahbod 786bf59b95 [vector] Remove global transform wrapper from SVG paint render
The transform is transient per _glyph call, not a global
state for the entire document.  Each glyph's <use> already
carries its own transform from the caller's set_transform.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 03:46:30 -06:00
Behdad Esfahbod f469f05a40 [vector/raster] Remove pen_x/pen_y from _glyph APIs
These are convenience APIs, not typesetting APIs — positioning
is the caller's responsibility via set_transform().  This
matches the GPU API which never had pen parameters.

All callers updated to use set_transform with pen position
before each _glyph call.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 03:32:33 -06:00
Behdad Esfahbod c76b3a29a9 [vector] Content-based dedup, remove font reference caching
Replace glyph-ID-based dedup with content-based dedup for SVG
path definitions and color glyph groups.  Path/paint output is
hashed and compared byte-for-byte against existing defs;
identical content reuses the same def regardless of glyph ID.

This eliminates the font reference held by draw/paint contexts
(cached_font + hb_font_reference), which was keeping the font
and its face alive longer than the caller expected.  No font
pointer is stored at all now.

Also removes changed() — with content-based dedup, foreground
and palette changes produce different content that naturally
won't match cached entries.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 03:09:35 -06:00