bugThe FreeType Project - Bugs: bug #59411, 'sbix' originOffsetY applied in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #59411: 'sbix' originOffsetY applied in wrong direction, need 'glyf' offset applied.

Submitter:  bungeman <bungeman>
Submitted:  Tue 03 Nov 2020 08:42:52 PM UTC
   
 
Severity:  3 - Normal Item Group:  Incorrect behaviour
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Planned Release:  None

Wed 04 Nov 2020 11:04:16 PM UTC, comment #3: 

Attaching colorheads.png which is representative of colorheads.ttf, colorheads-zeroadvance.ttf, and colorheads-lsb.ttf. These should look more or less the same, modulo possible small spacing details.

Also attaching colorheads-emptyglyf.png which is what colorheads-emptyglyf.ttf looks like and, I assume, what colorheads-noglyf.ttf would also look like. CoreText doesn't actually load colorheads-noglyf.ttf since it doesn't have a 'glyf' table. Note that both of these are not entirely well defined edge cases and I'm not sure how important they really are.

Note that these are screenshots of Safari displaying the .html files in the color-font.zip (the name of which is visible in the screenshot) at 50% zoom on a 2x retina display. So these are showing the string "bcdea wxyzv".


bungeman <bungeman>
Wed 04 Nov 2020 08:10:40 PM UTC, comment #2: 

Thanks for the details.  Since I don't have access to a Mac: could you attach one or more screenshots to show how it should look like?

Werner LEMBERG <wl>
Group administrator
Tue 03 Nov 2020 09:06:47 PM UTC, comment #1: 

The first issue seems fairly straight forward:


diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 9dd441971..d91046c83 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -1580,7 +1580,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 );


The second part seems more difficult, since currently TT_Load_Glyph assumes either the bitmap or the outline is needed, but not both. Also, this information is only applicable to 'sbix' and not to other 'sbit' formats. It seems maybe load_sbit_image could return a flag stating that the bearings should be adjusted by the lower left of the 'glyf' entry (should it exist) and TT_Load_Glyph then load that glyph and apply the delta.

Several test fonts were created as part of testing behavior to clarify the specification. These can be had at https://github.com/MicrosoftDocs/typography-issues/files/5209365/color-font.zip . If everything is working right colorheads.ttf, colorheads-zeroadvance.ttf, and colorheads-lsb.ttf should all look more or less the same (with the left "bcdea" looking like the right "wxyzv", which is more or less looking at them in the default view in ftview). The other two (colorheads-emptyglyf.ttf and colorheads-noglyf.ttf) will probably end up looking different but should probably look sane in some way. If you have access to a Mac, opening the html files in Safari shows more or less the canonical way these look (CoreText currently doesn't recognize colorheads-noglyf.ttf as a valid font, though both FreeType and DirectWrite do).

bungeman <bungeman>
Tue 03 Nov 2020 08:42:52 PM UTC, original submission:  

See https://github.com/MicrosoftDocs/typography-issues/issues/191 for background on clarification of the specification.

There are two clarifications:

1. Positive values of the sbix originOffsetY should push the image visually up.

2. If there is a non-empty 'glyf' entry for the glyph id, the lower left of its bounds should be used as the origin for the originOffsetX/Y.

bungeman <bungeman>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #50206:  colorheads.png added by bungeman (328KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by bungeman (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-11-04 bungeman Attached File- Added colorheads.png, #50206
        Attached File- Added colorheads-emptyglyf.png, #50207

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code