question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yMax and usWinAscent calculation error

See original GitHub issue

This will cause the line height in Windows to be too large. https://github.com/thx/iconfont-plus/issues/1953#issuecomment-834044570

image

I guess it is a problem introduced by(v2.1.0) https://github.com/fontello/svg2ttf/issues/25 , and there is a problem with the conversion of the cubic2quad module.

In the result returned by cubic2quad, 32147.26312251112 is abnormal.

[ 'Q', 566.970047, 32147.26312251112, 567.27723, 693.5669409999996 ]

https://github.com/fontello/svg2ttf/blob/df30be9043ccb9d00e1c9087b21f084a8fface4f/lib/svg.js#L96-L111

Test file and test case in:

https://github.com/fontello/svg2ttf/pull/102/commits/ae425be18907eb9e93ceca2ecfd8ac73dcba77fd

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg>
    <metadata>
        iconfont
    </metadata>
    <defs>
        <font id="iconfont" horiz-adv-x="1024">
            <font-face font-family="iconfont" font-weight="500" font-stretch="normal" units-per-em="1024" ascent="896" descent="-128" />
            <missing-glyph />
            <glyph glyph-name="up" unicode="&#58880;" d="M566.970047-68.244874V693.362153c0 0.204788 0.307182 0.307182 0.307183 0.204788l259.773733-287.42013c13.61841-14.949533 33.79004-21.195571 52.835335-16.178261a56.521522 56.521522 0 0 1 39.524108 40.548048 61.02686 61.02686 0 0 1-13.208834 56.623916L552.634879 878.285827A53.654488 53.654488 0 0 1 513.110771 896a53.654488 53.654488 0 0 1-39.524107-17.816567L117.767301 485.092633A60.207708 60.207708 0 0 1 102.408192 443.41825a59.798132 59.798132 0 0 1 16.89502-40.957625c21.912329-22.219511 56.521522-21.502753 77.614698 1.638305L456.691644 691.314272h0.307182v-760.787875c0-31.230189 22.833876-56.521522 51.401818-58.364614 15.359109-0.819152 30.308642 5.119703 41.367201 16.383049a61.231649 61.231649 0 0 1 17.099808 43.210294z" horiz-adv-x="1024" />
        </font>
    </defs>
</svg>

TTX file

<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.22">
  <GlyphOrder>
    <GlyphID id="0" name="glyph00000"/>
    <GlyphID id="1" name="up"/>
  </GlyphOrder>

  <head>
    <tableVersion value="1.0"/>
    <fontRevision value="1.0"/>
    <checkSumAdjustment value="0xd03dc53e"/>
    <magicNumber value="0x5f0f3cf5"/>
    <flags value="00000000 00001011"/>
    <unitsPerEm value="1024"/>
    <created value="Sat May  8 11:35:08 2021"/>
    <modified value="Sat May  8 11:35:08 2021"/>
    <xMin value="0"/>
    <yMin value="-130"/>
    <xMax value="1024"/>
    <yMax value="32148"/>
    <macStyle value="00000000 00000000"/>
    <lowestRecPPEM value="8"/>
    <fontDirectionHint value="2"/>
    <indexToLocFormat value="0"/>
    <glyphDataFormat value="0"/>
  </head>

  <hhea>
    <tableVersion value="0x00010000"/>
    <ascent value="896"/>
    <descent value="-128"/>
    <lineGap value="0"/>
    <advanceWidthMax value="1024"/>
    <minLeftSideBearing value="0"/>
    <minRightSideBearing value="0"/>
    <xMaxExtent value="1024"/>
    <caretSlopeRise value="1"/>
    <caretSlopeRun value="0"/>
    <caretOffset value="0"/>
    <reserved0 value="0"/>
    <reserved1 value="0"/>
    <reserved2 value="0"/>
    <reserved3 value="0"/>
    <metricDataFormat value="0"/>
    <numberOfHMetrics value="2"/>
  </hhea>

  <OS_2>
    <version value="1"/>
    <xAvgCharWidth value="1024"/>
    <usWeightClass value="400"/>
    <usWidthClass value="5"/>
    <fsType value="00000000 00000000"/>
    <ySubscriptXSize value="649"/>
    <ySubscriptYSize value="716"/>
    <ySubscriptXOffset value="0"/>
    <ySubscriptYOffset value="143"/>
    <ySuperscriptXSize value="649"/>
    <ySuperscriptYSize value="716"/>
    <ySuperscriptXOffset value="0"/>
    <ySuperscriptYOffset value="491"/>
    <yStrikeoutSize value="50"/>
    <yStrikeoutPosition value="264"/>
    <sFamilyClass value="0"/>
    <panose>
      <bFamilyType value="2"/>
      <bSerifStyle value="0"/>
      <bWeight value="5"/>
      <bProportion value="3"/>
      <bContrast value="0"/>
      <bStrokeVariation value="0"/>
      <bArmStyle value="0"/>
      <bLetterForm value="0"/>
      <bMidline value="0"/>
      <bXHeight value="0"/>
    </panose>
    <ulUnicodeRange1 value="00000000 00000000 00000000 00000000"/>
    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
    <achVendID value="PfEd"/>
    <fsSelection value="00000000 01000000"/>
    <usFirstCharIndex value="58880"/>
    <usLastCharIndex value="58880"/>
    <sTypoAscender value="896"/>
    <sTypoDescender value="-128"/>
    <sTypoLineGap value="92"/>
    <usWinAscent value="32148"/>
    <usWinDescent value="130"/>
    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
  </OS_2>
  <glyf>
    <TTGlyph name="glyph00000"/><!-- contains no outline data -->
    <TTGlyph name="up" xMin="0" yMin="-130" xMax="924" yMax="32148">
      <contour>
        <pt x="567" y="-68" on="1"/>
        <pt x="567" y="693" on="1"/>
        <pt x="567" y="32147" on="0"/>
        <pt x="567" y="694" on="1"/>
        <pt x="827" y="406" on="1"/>
        <pt x="837" y="395" on="0"/>
        <pt x="866" y="386" on="0"/>
        <pt x="894" y="394" on="0"/>
        <pt x="916" y="416" on="0"/>
        <pt x="923" y="445" on="0"/>
        <pt x="916" y="476" on="0"/>
        <pt x="906" y="487" on="1"/>
        <pt x="553" y="878" on="1"/>
        <pt x="537" y="896" on="0"/>
        <pt x="489" y="896" on="0"/>
        <pt x="474" y="878" on="1"/>
        <pt x="118" y="485" on="1"/>
        <pt x="102" y="467" on="0"/>
        <pt x="103" y="420" on="0"/>
        <pt x="136" y="386" on="0"/>
        <pt x="181" y="387" on="0"/>
        <pt x="197" y="404" on="1"/>
        <pt x="457" y="691" on="1"/>
        <pt x="457" y="-69" on="1"/>
        <pt x="457" y="-93" on="0"/>
        <pt x="487" y="-126" on="0"/>
        <pt x="508" y="-128" on="1"/>
        <pt x="532" y="-129" on="0"/>
        <pt x="567" y="-93" on="0"/>
      </contour>
      <instructions/>
    </TTGlyph>
  </glyf>
</ttFont>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:31 (31 by maintainers)

github_iconTop GitHub Comments

0reactions
yisiblcommented, Jun 18, 2021

Thank you very much for your summary, let us discuss it in a separate issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set usWinAscent and usWinDescent values?
From the Font menu, Font Information dialog, click on the Y Max/Min values to locate the glyphs that define the WinAscent and WinDecent ......
Read more >
Font Development Best Practices: Line Metrics - GitHub Pages
Begin by setting the usWinAscent and usWinDescent values based on the yMax and yMin values as in the Minimal strategy. This will eliminate...
Read more >
'OS/2' table - TrueType Reference Manual - Apple Developer
usWinAscent is computed as the yMax for all characters in the Windows ANSI ... The average character width is calculated according to this...
Read more >
TrueType Tables - FreeType-2.12.1 API Reference
The length of the SFNT table (or the number of SFNT tables, depending on tag ). return. FreeType error code. 0 means success....
Read more >
OpenType Specification Change Log - Microsoft Learn
Clarified meaning of unitsPerEm, xMin, yMin, xMax and yMax values. ... Include details for legacy calculation of xAvgCharWidth in OS/2 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found