diff options
| author | Po Lu | 2023-12-29 14:58:19 +0800 |
|---|---|---|
| committer | Po Lu | 2023-12-29 14:58:41 +0800 |
| commit | ea3d211f3f7ecc5b59d5affc1aed812a2ded62b0 (patch) | |
| tree | bd83822c8a517b4ed6aca9e84cfd3d2e7486d9c3 /src/sfntfont.c | |
| parent | 714942b1c3767ee6c70a5644d6a4460dedbe4422 (diff) | |
| download | emacs-ea3d211f3f7ecc5b59d5affc1aed812a2ded62b0.tar.gz emacs-ea3d211f3f7ecc5b59d5affc1aed812a2ded62b0.zip | |
Obey USE_MY_METRICS in compound glyphs
* src/sfnt.c (struct sfnt_compound_glyph_context): New fields
holding the positions of both phantom points.
(sfnt_decompose_compound_glyph): New argument METRICS_RETURN;
return the metrics of components with USE_MY_METRICS within this
field.
(sfnt_decompose_glyph): New argument METRICS_RETURN, which
serves the same purpose.
(sfnt_build_glyph_outline): Apply glyph advance and origin
distortion to METRICS, and return the metrics as altered by
compound glyphs in there.
(sfnt_lookup_glyph_metrics): Trim away two unused parameters,
PIXEL_SIZE and HEAD, whose functionality has been superseeded by
sfnt_scale_metrics and the implicit scaling the interpreter
performs.
(sfnt_interpret_compound_glyph_2): Save phantom points within
fields provided to that end in CONTEXT.
(sfnt_interpret_compound_glyph_1): Save and source phantom
points for each glyph to and from the context.
(sfnt_test_get_metrics, main): Adjust tests correspondingly.
* src/sfnt.h: Update prototypes.
* src/sfntfont.c (sfntfont_get_metrics): Remove obsolete
parameters.
(sfntfont_get_glyph_outline): Don't change temp by the metrics
distortions, which is now the task of sfnt_decompose_glyph.
Diffstat (limited to 'src/sfntfont.c')
| -rw-r--r-- | src/sfntfont.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/sfntfont.c b/src/sfntfont.c index b20a7c91115..04caf77e72a 100644 --- a/src/sfntfont.c +++ b/src/sfntfont.c | |||
| @@ -2115,9 +2115,8 @@ sfntfont_get_metrics (sfnt_glyph glyph, struct sfnt_glyph_metrics *metrics, | |||
| 2115 | struct sfntfont_get_glyph_outline_dcontext *tables; | 2115 | struct sfntfont_get_glyph_outline_dcontext *tables; |
| 2116 | 2116 | ||
| 2117 | tables = dcontext; | 2117 | tables = dcontext; |
| 2118 | return sfnt_lookup_glyph_metrics (glyph, -1, metrics, | 2118 | return sfnt_lookup_glyph_metrics (glyph, metrics, tables->hmtx, |
| 2119 | tables->hmtx, tables->hhea, | 2119 | tables->hhea, tables->maxp); |
| 2120 | NULL, tables->maxp); | ||
| 2121 | } | 2120 | } |
| 2122 | 2121 | ||
| 2123 | /* Dereference the outline OUTLINE. Free it once refcount reaches | 2122 | /* Dereference the outline OUTLINE. Free it once refcount reaches |
| @@ -2253,8 +2252,7 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, | |||
| 2253 | 2252 | ||
| 2254 | /* Now load the glyph's unscaled metrics into TEMP. */ | 2253 | /* Now load the glyph's unscaled metrics into TEMP. */ |
| 2255 | 2254 | ||
| 2256 | if (sfnt_lookup_glyph_metrics (glyph_code, -1, &temp, hmtx, hhea, | 2255 | if (sfnt_lookup_glyph_metrics (glyph_code, &temp, hmtx, hhea, maxp)) |
| 2257 | head, maxp)) | ||
| 2258 | goto fail; | 2256 | goto fail; |
| 2259 | 2257 | ||
| 2260 | if (interpreter) | 2258 | if (interpreter) |
| @@ -2312,6 +2310,8 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, | |||
| 2312 | 2310 | ||
| 2313 | if (!outline) | 2311 | if (!outline) |
| 2314 | { | 2312 | { |
| 2313 | /* Build the outline. This will apply GX offsets within *GLYPH | ||
| 2314 | to TEMP. */ | ||
| 2315 | outline = sfnt_build_glyph_outline (glyph, scale, | 2315 | outline = sfnt_build_glyph_outline (glyph, scale, |
| 2316 | &temp, | 2316 | &temp, |
| 2317 | sfntfont_get_glyph, | 2317 | sfntfont_get_glyph, |
| @@ -2319,22 +2319,9 @@ sfntfont_get_glyph_outline (sfnt_glyph glyph_code, | |||
| 2319 | sfntfont_get_metrics, | 2319 | sfntfont_get_metrics, |
| 2320 | &dcontext); | 2320 | &dcontext); |
| 2321 | 2321 | ||
| 2322 | /* Add the advance width distortion, which is not applied to | ||
| 2323 | glyph metrics in advance of their being instructed, and thus | ||
| 2324 | has to be applied before the metrics are. */ | ||
| 2325 | temp.advance += distortion.advance; | ||
| 2326 | |||
| 2327 | /* At this point, the glyph metrics are unscaled. Scale them | 2322 | /* At this point, the glyph metrics are unscaled. Scale them |
| 2328 | up. If INTERPRETER is set, use the scale placed within. */ | 2323 | up. If INTERPRETER is set, use the scale placed within. */ |
| 2329 | sfnt_scale_metrics (&temp, scale); | 2324 | sfnt_scale_metrics (&temp, scale); |
| 2330 | |||
| 2331 | /* Finally, adjust the left side bearing of the glyph metrics by | ||
| 2332 | the origin point of the outline, should a transformation have | ||
| 2333 | been applied by either instruction code or glyph variation. | ||
| 2334 | The left side bearing is the distance from the origin point | ||
| 2335 | to the left most point on the X axis. */ | ||
| 2336 | if (index != -1) | ||
| 2337 | temp.lbearing = outline->xmin - outline->origin; | ||
| 2338 | } | 2325 | } |
| 2339 | 2326 | ||
| 2340 | fail: | 2327 | fail: |