diff options
| author | eunhhu <[email protected]> | 2026-09-28 12:48:45 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-28 12:48:45 +0100 |
| commit | c38380464d29c4502c98d996236ccf890392fe86 (patch) | |
| tree | 2c510e29207427fd105f5bd87425deb5b01b208e /text/shape-build.h | |
| parent | 16d84b2530e154795a825fbf2b7e028e2f209b71 (diff) | |
| download | vega-c38380464d29c4502c98d996236ccf890392fe86.tar.gz vega-c38380464d29c4502c98d996236ccf890392fe86.zip | |
Shape text as HarfBuzz does, from a symbol file, checked against HarfBuzz
The build tool compiles a font's shaping plans the way HarfBuzz's planner
does (features, stages, masks, lookups per script and direction) and
carries them with the font's character map, advances and GDEF, GSUB and
GPOS tables in a section of the symbol file (VEGASYM4); glyphs shaping
reaches become symbols of their own. A small engine ports HarfBuzz 10's
default, Arabic and Hebrew shaping step for step and reads the tables in
place, every read bounds-checked. The build refuses a file whose shaping
differs from HarfBuzz's on random runs: DejaVu Sans agrees on 600,000
runs in six scripts both ways, and every installed font the tool accepts
agrees too, at 1.05-1.18 times HarfBuzz's time.
Diffstat (limited to 'text/shape-build.h')
| -rw-r--r-- | text/shape-build.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/text/shape-build.h b/text/shape-build.h new file mode 100644 index 0000000..dd93177 --- /dev/null +++ b/text/shape-build.h @@ -0,0 +1,31 @@ +#ifndef VEGA_SHAPE_BUILD_H +#define VEGA_SHAPE_BUILD_H +#include "shape.h" +#include <hb.h> +#include <stdio.h> + +/* Building a shaping section (text/shape.h), and checking it, with + * HarfBuzz: only the build tool links this. */ + +typedef struct { unsigned char *bytes; size_t size; } VegaSection; + +/* A section for face: plans for each script (ISO 15924 tags) and both + * directions, compiled as + * HarfBuzz's planner compiles it. Refuses a script HarfBuzz shapes with a + * shaper other than the default, Arabic and Hebrew ones, or a font that + * needs what those do without GPOS (fallback positioning, 'kern' tables, + * AAT). glyphs, when given, gets every glyph shaping can reach from codes + * (for their outlines). */ +bool vega_shaping_compile(hb_face_t *face, const uint32_t *scripts, size_t script_count, const uint32_t *codes, + size_t code_count, VegaSection *out, hb_set_t *glyphs, char *error, size_t error_size); + +typedef struct { + size_t runs, characters, glyphs, differences; + double vega_seconds, harfbuzz_seconds; /* shaping alone, each */ +} VegaShapeCheck; +/* Shape runs random runs of script (in its plan's direction) made of codes + * with both the section and HarfBuzz, and count the runs that differ (the + * first few are written to report). */ +void vega_shaping_check(hb_font_t *font, const VegaShaping *s, uint32_t script, int direction, const uint32_t *codes, + size_t code_count, uint64_t seed, size_t runs, VegaShapeCheck *out, FILE *report); +#endif |
