[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] wl/sbix 2030208ed 1/3: [truetype] Fix 'sbix' table handling.
From: |
Werner Lemberg |
Subject: |
[freetype2] wl/sbix 2030208ed 1/3: [truetype] Fix 'sbix' table handling. |
Date: |
Sun, 13 Mar 2022 12:01:16 -0400 (EDT) |
branch: wl/sbix
commit 2030208ed70243662a80f41cd12d269c5a5f4ebd
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>
[truetype] Fix 'sbix' table handling.
* src/sfnt/sfobjs.c (sfnt_load_face): Don't set `has_outline` for 'sbix'
embedded bitmaps.
* src/sfnt/ttsbit.c (tt_face_load_sbix_image): Correct calculation of
'metrics->horiBearingY'.
* src/truetype/ttgload.c (TT_Load_Glyph): For 'sbix' embedded bitmaps, apply
bbox offset and bearing values of the corresponding glyph in the 'glyf'
table if it exists and has a contour.
Fixes issue #998.
---
src/sfnt/sfobjs.c | 6 ------
src/sfnt/ttsbit.c | 2 +-
src/truetype/ttgload.c | 24 ++++++++++++++++++++++++
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index f9d4d3858..864dfa86a 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -851,12 +851,6 @@
is_apple_sbit = 0;
is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
- /* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf'
- * outline rendered on top. We don't support that yet, so just ignore
- * the 'glyf' outline and advertise it as a bitmap-only font. */
- if ( is_apple_sbix )
- has_outline = FALSE;
-
/* if this font doesn't contain outlines, we try to load */
/* a `bhed' table */
if ( !has_outline && sfnt->load_bhed )
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 179e9cc55..c979c27d0 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -1587,7 +1587,7 @@
tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance );
metrics->horiBearingX = (FT_Short)originOffsetX;
- metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
+ metrics->horiBearingY = (FT_Short)( originOffsetY + metrics->height );
metrics->horiAdvance = (FT_UShort)( aadvance *
face->root.size->metrics.x_ppem /
face->header.Units_Per_EM );
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index b19f7a283..7e5d383f9 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -2899,6 +2899,9 @@
{
if ( FT_IS_SCALABLE( glyph->face ) )
{
+ TT_Face face = (TT_Face)glyph->face;
+
+
/* for the bbox we need the header only */
(void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
(void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
@@ -2906,6 +2909,27 @@
glyph->linearHoriAdvance = loader.linear;
glyph->linearVertAdvance = loader.vadvance;
+ /* bitmaps from the `sbix' table need special treatment: */
+ /* if there is a glyph contour, the bitmap origin must be */
+ /* shifted to be relative to the lower left corner of the */
+ /* glyph bounding box, also taking the left-side bearing */
+ /* (or top bearing) into account */
+ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX &&
+ loader.n_contours > 0 )
+ {
+ FT_Int bitmap_left = loader.bbox.xMin;
+ FT_Int bitmap_top = loader.bbox.yMin;
+
+
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
+ bitmap_top += loader.top_bearing;
+ else
+ bitmap_left += loader.left_bearing;
+
+ glyph->bitmap_left += FT_MulFix( bitmap_left, x_scale ) >> 6;
+ glyph->bitmap_top += FT_MulFix( bitmap_top, y_scale ) >> 6;
+ }
+
/* sanity checks: if `xxxAdvance' in the sbit metric */
/* structure isn't set, use `linearXXXAdvance' */
if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] wl/sbix 2030208ed 1/3: [truetype] Fix 'sbix' table handling.,
Werner Lemberg <=