microsoft / VisualTrueType

Microsoft Visual TrueType(VTT) command line compile tool and Python interface.
MIT License
48 stars 17 forks source link

different outcomes between vttcompile and vttshell, on vttdemo.ttf #23

Closed HinTak closed 3 years ago

HinTak commented 3 years ago

-g0 -r100:

@@ -471,7 +471,7 @@
   </OS_2>

   <hmtx>
-    <mtx name=".notdef" width="1322" lsb="0"/>
+    <mtx name=".notdef" width="197" lsb="0"/>
     <mtx name="A" width="1321" lsb="24"/>
     <mtx name="AE" width="1762" lsb="24"/>
     <mtx name="Aacute" width="1321" lsb="24"/>
@@ -747,7 +747,7 @@
     <mtx name="seven" width="1104" lsb="98"/>
     <mtx name="six" width="1104" lsb="111"/>
     <mtx name="slash" width="798" lsb="1"/>
-    <mtx name="space" width="561" lsb="0"/>
+    <mtx name="space" width="197" lsb="0"/>
     <mtx name="sterling" width="1104" lsb="120"/>
     <mtx name="t" width="694" lsb="43"/>
     <mtx name="tbar" width="694" lsb="43"/>

-g200 -r300:

@@ -767,7 +767,7 @@
     <mtx name="uhungarumlaut" width="1159" lsb="144"/>
     <mtx name="umacron" width="1159" lsb="144"/>
     <mtx name="underscore" width="850" lsb="50"/>
-    <mtx name="uni000D" width="199" lsb="0"/>
+    <mtx name="uni000D" width="156" lsb="0"/>
     <mtx name="uni00AD" width="819" lsb="144"/>
     <mtx name="uni00B2" width="995" lsb="0"/>
     <mtx name="uni00B3" width="995" lsb="0"/>

-b, -c, -s, and also no arguments:

@@ -471,7 +471,7 @@
   </OS_2>

   <hmtx>
-    <mtx name=".notdef" width="1322" lsb="0"/>
+    <mtx name=".notdef" width="197" lsb="0"/>
     <mtx name="A" width="1321" lsb="24"/>
     <mtx name="AE" width="1762" lsb="24"/>
     <mtx name="Aacute" width="1321" lsb="24"/>

So the summary is that -a gives identical results (other than checksums and dates), most other switches (including no passing any) disgrees by the width of .notdef, and with -g... -r..., not only .notdef, but also space and uni000D (carriage return). @paullinnerud : this looks like another issue along the line of "rasterizer removal"?

paullinnerud commented 3 years ago

Possibly, I'll have a look. One other issue with the codebase is is there are two code paths for writing font file data. The original allows random access and can be used to write any number of glyphs but this path is slow since it finalizes the state of the font after each glyph is written. The other faster path is only used when all glyphs will be written. The -a option uses the faster path but all other options use slower path. Thanks.

HinTak commented 3 years ago

It sounds like it might be combination of two issues - a difference between the fast path and the slow path gives difference in the width of .notdef, and some rasterizer-related issues affecting glyphs with no ink markings (.notdef, space, and uni000D/carriage return) when -g -r are specified. Since people outside of microsoft don't have source-level access to vttshell, this issue needs to be looked at by microsoft staff...

paullinnerud commented 3 years ago

Yes, it was an issue introduced with rasterizer removal. Phantom point calculation for empty glyphs. Integrated a fix. How hopefully it works for simple glyphs, composite glyphs and empty glyphs. Thanks.

HinTak commented 3 years ago

Fixed with https://github.com/microsoft/VisualTrueType/commit/efa60c645e7009af9005034743f20f3cdaefa885