+
Skip to content

[ttLib] Ignore component bounds if empty #3799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

cmyr
Copy link
Contributor

@cmyr cmyr commented Apr 9, 2025

That is, if the bounds of a component have zero area, do not consider it when computing the bounds of the parent.

This handles the case of a composite glyph where all the components are themselves empty, which if it sounds weird you're probably new around here.

That is, if the bounds of a component have zero area, do not consider it
when computing the bounds of the parent.

This handles the case of a composite glyph where all the components are
themselves empty, which if it sounds weird you're probably new around
here.
@behdad behdad requested a review from anthrotype April 9, 2025 23:14
@behdad
Copy link
Member

behdad commented Apr 9, 2025

@qxliu76 Is this something HB needs fixing as well?

@qxliu76
Copy link
Contributor

qxliu76 commented Apr 10, 2025

do we have a testcase that shows the problem?

@qxliu76
Copy link
Contributor

qxliu76 commented Apr 10, 2025

I'd like a test case so I can take a look:)

@anthrotype
Copy link
Member

good catch! thanks

@anthrotype anthrotype merged commit 04a55f5 into fonttools:main Apr 22, 2025
11 checks passed
@anthrotype
Copy link
Member

@qxliu76 @behdad I have just distilled a test font from @cmyr's unit test, you'll find it attached below:

RecalcBoundsEmptyComponentsNested-Regular.ttf.zip

If you rountrip the font through ttx (with this PR merged on main), you'll notice that the bounds of glyph "bar" have been updated (i.e. inheriting the bounds of its non-empty component, ignoring the empty one)

ttx -q -o - "/Users/clupo/oss/fonttools/master_ttf/RecalcBoundsEmptyComponentsNested-Regular.ttf" 2>/dev/null
ttx -q -o - "/Users/clupo/oss/fonttools/master_ttf/RecalcBoundsEmptyComponentsNested-Regular#1.ttf" 2>/dev/null
--- /dev/fd/63  2025-04-22 15:01:11
+++ /dev/fd/62  2025-04-22 15:01:11
@@ -14,12 +14,12 @@
     <!-- Most of this table will be recalculated by the compiler -->
     <tableVersion value="1.0"/>
     <fontRevision value="1.0"/>
-    <checkSumAdjustment value="0xf5e5411a"/>
+    <checkSumAdjustment value="0xf5df4094"/>
     <magicNumber value="0x5f0f3cf5"/>
-    <flags value="00000000 00000011"/>
+    <flags value="00000000 00000001"/>
     <unitsPerEm value="1000"/>
     <created value="Tue Apr 22 13:50:52 2025"/>
-    <modified value="Tue Apr 22 13:59:53 2025"/>
+    <modified value="Tue Apr 22 14:00:55 2025"/>
     <xMin value="0"/>
     <yMin value="-200"/>
     <xMax value="450"/>
@@ -166,7 +166,7 @@
       <instructions/>
     </TTGlyph>

-    <TTGlyph name="bar" xMin="0" yMin="0" xMax="10" yMax="10">
+    <TTGlyph name="bar" xMin="5" yMin="5" xMax="10" yMax="10">
       <component glyphName="foofoo" x="0" y="0" flags="0x4"/>
       <component glyphName="doo" x="0" y="0" flags="0x4"/>
     </TTGlyph>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载