Skip to content

Commit

Permalink
Fix vertical metrics of Charter otf/ttf
Browse files Browse the repository at this point in the history
Inconsistent line height on Chrome/Firefox for Android
is due to wrong vertical metrics
of the Charter font files from the link below:
https://practicaltypography.com/charter.html

The font files have positive descender values but those values
should be NEGATIVE. (See References [1], [2] and others.)
- `descender`      field in `hhea` table
- `sTypoDescender` field in `OS/2` table

Table   Field Name      Field Value         Should Be
-----   -------------   -----------------   ---------
head    unitsPerEm      1000
hhea    ascender        980
        descender       236                 -236
        lineGap         0
OS/2    sTypoAscender   760
        sTypoDescender  240                 -240
        sTypoLineGap    216
        usWinAscent     980
        usWinDescent    236
        fsSelection     00000000 01000000

So I've made a program which fixes those values (and checksums)
in Charter otf/ttf file to resolve the line height issue.

References:
[1] https://glyphsapp.com/learn/vertical-metrics
    via https://stackoverflow.com/questions/2854028/mac-vs-windows-browser-font-height-rendering-issue
[2] https://googlefonts.github.io/gf-guide/metrics.html
    via googlefonts/googlefonts.github.io#45
    and source-foundry/font-line#2
[3] 1. https://learn.microsoft.com/en-us/typography/opentype/spec/otff
    2. https://learn.microsoft.com/en-us/typography/opentype/spec/head
    3. https://learn.microsoft.com/en-us/typography/opentype/spec/hhea
    4. https://learn.microsoft.com/en-us/typography/opentype/spec/os2

Terminal output of program:

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Regular.otf
sfntVersion: 4F54544F  numTables: 000B
 - tableTag: 43464620 (CFF )  checksum: EA4DC1AF  offset: 00000BB8  length: 000082A3
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 00009734  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: E82FF7B3  offset: 000091F0  length: 00000542
 - tableTag: 4F532F32 (OS/2)  checksum: 8B297EE1  offset: 00000120  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 0000088C  length: 0000030C
 - tableTag: 68656164 (head)  checksum: 1B64CC47  offset: 000000BC  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 07DC05FC  offset: 000000F4  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: ED592734  offset: 00008E5C  length: 00000394
 - tableTag: 6D617870 (maxp)  checksum: 00E55000  offset: 00000118  length: 00000006
 - tableTag: 6E616D65 (name)  checksum: 619A5B30  offset: 00000180  length: 0000070B
 - tableTag: 706F7374 (post)  checksum: FF6E003A  offset: 00000B98  length: 00000020
offset 000000FA: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 00000166: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 00000070: checksum for 'hhea' table: 07DC05FC --> 07DD0424 (modified)
offset 00000040: checksum for 'OS/2' table: 8B297EE1 --> 8B2A7D01 (modified)
offset 00000060: checksum for 'head' table: 1B64CC47 --> 1B64CC47 (not modified)
offset 000000C4: 'checksumAdjustment' field in 'head' table: 14F57F8B --> 14F186FB (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Italic.otf
sfntVersion: 4F54544F  numTables: 000B
 - tableTag: 43464620 (CFF )  checksum: 5340C605  offset: 00000BD8  length: 000084CE
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 000099B4  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: F28802D2  offset: 0000943C  length: 00000578
 - tableTag: 4F532F32 (OS/2)  checksum: 8C2D7E6C  offset: 00000120  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 000008AC  length: 0000030C
 - tableTag: 68656164 (head)  checksum: 1B13CC53  offset: 000000BC  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 06C709A1  offset: 000000F4  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: E26B1300  offset: 000090A8  length: 00000394
 - tableTag: 6D617870 (maxp)  checksum: 00E55000  offset: 00000118  length: 00000006
 - tableTag: 6E616D65 (name)  checksum: 8CCC2E70  offset: 00000180  length: 0000072C
 - tableTag: 706F7374 (post)  checksum: FF79003A  offset: 00000BB8  length: 00000020
offset 000000FA: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 00000166: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 00000070: checksum for 'hhea' table: 06C709A1 --> 06C807C9 (modified)
offset 00000040: checksum for 'OS/2' table: 8C2D7E6C --> 8C2E7C8C (modified)
offset 00000060: checksum for 'head' table: 1B13CC53 --> 1B13CC53 (not modified)
offset 000000C4: 'checksumAdjustment' field in 'head' table: EE85D217 --> EE81D987 (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Bold.otf
sfntVersion: 4F54544F  numTables: 000B
 - tableTag: 43464620 (CFF )  checksum: D5E91E98  offset: 00000BC0  length: 00008365
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 00009984  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: 1CF31346  offset: 000092BC  length: 000006C8
 - tableTag: 4F532F32 (OS/2)  checksum: 8D5981F5  offset: 00000120  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 00000894  length: 0000030C
 - tableTag: 68656164 (head)  checksum: 1BA6CC3D  offset: 000000BC  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 081D0634  offset: 000000F4  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: FF6324F0  offset: 00008F28  length: 00000394
 - tableTag: 6D617870 (maxp)  checksum: 00E55000  offset: 00000118  length: 00000006
 - tableTag: 6E616D65 (name)  checksum: 3D47C34B  offset: 00000180  length: 00000714
 - tableTag: 706F7374 (post)  checksum: FF950054  offset: 00000BA0  length: 00000020
offset 000000FA: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 00000166: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 00000070: checksum for 'hhea' table: 081D0634 --> 081E045C (modified)
offset 00000040: checksum for 'OS/2' table: 8D5981F5 --> 8D5A8015 (modified)
offset 00000060: checksum for 'head' table: 1BA6CC3D --> 1BA6CC3D (not modified)
offset 000000C4: 'checksumAdjustment' field in 'head' table: F315B5DC --> F311BD4C (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Bold-Italic.otf
sfntVersion: 4F54544F  numTables: 000B
 - tableTag: 43464620 (CFF )  checksum: FAC135F0  offset: 00000C10  length: 000085AA
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 00009C5C  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: 145323A8  offset: 00009550  length: 0000070C
 - tableTag: 4F532F32 (OS/2)  checksum: 8D5E81C9  offset: 00000120  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 000008E4  length: 0000030C
 - tableTag: 68656164 (head)  checksum: 1B7DCC40  offset: 000000BC  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 07300A0A  offset: 000000F4  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: FA0F1322  offset: 000091BC  length: 00000394
 - tableTag: 6D617870 (maxp)  checksum: 00E55000  offset: 00000118  length: 00000006
 - tableTag: 6E616D65 (name)  checksum: 41042CB9  offset: 00000180  length: 00000762
 - tableTag: 706F7374 (post)  checksum: FFA00054  offset: 00000BF0  length: 00000020
offset 000000FA: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 00000166: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 00000070: checksum for 'hhea' table: 07300A0A --> 07310832 (modified)
offset 00000040: checksum for 'OS/2' table: 8D5E81C9 --> 8D5F7FE9 (modified)
offset 00000060: checksum for 'head' table: 1B7DCC40 --> 1B7DCC40 (not modified)
offset 000000C4: 'checksumAdjustment' field in 'head' table: BFE0A407 --> BFDCAB77 (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Regular.ttf
sfntVersion: 00010000  numTables: 0010
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 000088EC  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: E82FF7B3  offset: 0000010C  length: 00000542
 - tableTag: 4F532F32 (OS/2)  checksum: 8B297EE1  offset: 00000650  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 000006B0  length: 0000030C
 - tableTag: 63767420 (cvt )  checksum: 04D710EF  offset: 000079E0  length: 0000004A
 - tableTag: 6670676D (fpgm)  checksum: 622EFD7C  offset: 00007A2C  length: 00000E0C
 - tableTag: 67617370 (gasp)  checksum: 00000010  offset: 000079D8  length: 00000008
 - tableTag: 676C7966 (glyf)  checksum: 6CB82482  offset: 000009BC  length: 000060F0
 - tableTag: 68656164 (head)  checksum: 1B68CC48  offset: 00006AAC  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 07DC05FC  offset: 00006AE4  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: ED592734  offset: 00006B08  length: 00000394
 - tableTag: 6C6F6361 (loca)  checksum: FFCC1806  offset: 00006E9C  length: 000001CC
 - tableTag: 6D617870 (maxp)  checksum: 019E0E83  offset: 00007068  length: 00000020
 - tableTag: 6E616D65 (name)  checksum: E53144D9  offset: 00007088  length: 00000762
 - tableTag: 706F7374 (post)  checksum: 373135EF  offset: 000077EC  length: 000001EC
 - tableTag: 70726570 (prep)  checksum: D4BDD644  offset: 00008838  length: 000000B2
offset 00006AEA: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 00000696: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 000000A0: checksum for 'hhea' table: 07DC05FC --> 07DD0424 (modified)
offset 00000030: checksum for 'OS/2' table: 8B297EE1 --> 8B2A7D01 (modified)
offset 00000090: checksum for 'head' table: 1B68CC48 --> 1B68CC48 (not modified)
offset 00006AB4: 'checksumAdjustment' field in 'head' table: 3DCC5A00 --> 3DC86170 (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Italic.ttf
sfntVersion: 00010000  numTables: 0010
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 00009084  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: F28802D2  offset: 0000010C  length: 00000578
 - tableTag: 4F532F32 (OS/2)  checksum: 8C2D7E6C  offset: 00000684  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 000006E4  length: 0000030C
 - tableTag: 63767420 (cvt )  checksum: 04CF10D9  offset: 00008178  length: 0000004A
 - tableTag: 6670676D (fpgm)  checksum: 622EFD7C  offset: 000081C4  length: 00000E0C
 - tableTag: 67617370 (gasp)  checksum: 00000010  offset: 00008170  length: 00000008
 - tableTag: 676C7966 (glyf)  checksum: ADA4911C  offset: 000009F0  length: 00006846
 - tableTag: 68656164 (head)  checksum: 1B17CC54  offset: 00007238  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 06C709A1  offset: 00007270  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: E26B1300  offset: 00007294  length: 00000394
 - tableTag: 6C6F6361 (loca)  checksum: CD3CE745  offset: 00007628  length: 000001CC
 - tableTag: 6D617870 (maxp)  checksum: 019E0E87  offset: 000077F4  length: 00000020
 - tableTag: 6E616D65 (name)  checksum: E8A738C7  offset: 00007814  length: 0000076E
 - tableTag: 706F7374 (post)  checksum: 373C35EF  offset: 00007F84  length: 000001EC
 - tableTag: 70726570 (prep)  checksum: AABDD644  offset: 00008FD0  length: 000000B2
offset 00007276: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 000006CA: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 000000A0: checksum for 'hhea' table: 06C709A1 --> 06C807C9 (modified)
offset 00000030: checksum for 'OS/2' table: 8C2D7E6C --> 8C2E7C8C (modified)
offset 00000090: checksum for 'head' table: 1B17CC54 --> 1B17CC54 (not modified)
offset 00007240: 'checksumAdjustment' field in 'head' table: 700FA33C --> 700BAAAC (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Bold.ttf
sfntVersion: 00010000  numTables: 0010
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 00008A2C  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: 1CF31346  offset: 0000010C  length: 000006C8
 - tableTag: 4F532F32 (OS/2)  checksum: 8D5981F5  offset: 000007D4  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 00000834  length: 0000030C
 - tableTag: 63767420 (cvt )  checksum: 051E1134  offset: 00007B20  length: 0000004A
 - tableTag: 6670676D (fpgm)  checksum: 622EFD7C  offset: 00007B6C  length: 00000E0C
 - tableTag: 67617370 (gasp)  checksum: 00000010  offset: 00007B18  length: 00000008
 - tableTag: 676C7966 (glyf)  checksum: 72F17DAD  offset: 00000B40  length: 000060B6
 - tableTag: 68656164 (head)  checksum: 1BAACC3E  offset: 00006BF8  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 081D0634  offset: 00006C30  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: FF6324F0  offset: 00006C54  length: 00000394
 - tableTag: 6C6F6361 (loca)  checksum: FEA216EB  offset: 00006FE8  length: 000001CC
 - tableTag: 6D617870 (maxp)  checksum: 019E0E83  offset: 000071B4  length: 00000020
 - tableTag: 6E616D65 (name)  checksum: C22FA494  offset: 000071D4  length: 00000756
 - tableTag: 706F7374 (post)  checksum: 37583609  offset: 0000792C  length: 000001EC
 - tableTag: 70726570 (prep)  checksum: D4BDD644  offset: 00008978  length: 000000B2
offset 00006C36: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 0000081A: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 000000A0: checksum for 'hhea' table: 081D0634 --> 081E045C (modified)
offset 00000030: checksum for 'OS/2' table: 8D5981F5 --> 8D5A8015 (modified)
offset 00000090: checksum for 'head' table: 1BAACC3E --> 1BAACC3E (not modified)
offset 00006C00: 'checksumAdjustment' field in 'head' table: E5D49B76 --> E5D0A2E6 (modified)

nooriro@xps:/mnt/c/Users/nooriro/CLionProjects/untitled6/cmake-build-release-wsl$ ./untitled6 Charter-Bold-Italic.ttf
sfntVersion: 00010000  numTables: 0010
 - tableTag: 44534947 (DSIG)  checksum: 00000001  offset: 00009268  length: 00000008
 - tableTag: 47504F53 (GPOS)  checksum: 145323A8  offset: 0000010C  length: 0000070C
 - tableTag: 4F532F32 (OS/2)  checksum: 8D5E81C9  offset: 00000818  length: 00000060
 - tableTag: 636D6170 (cmap)  checksum: 52F054E4  offset: 00000878  length: 0000030C
 - tableTag: 63767420 (cvt )  checksum: 051A1127  offset: 0000835C  length: 0000004A
 - tableTag: 6670676D (fpgm)  checksum: 622EFD7C  offset: 000083A8  length: 00000E0C
 - tableTag: 67617370 (gasp)  checksum: 00000010  offset: 00008354  length: 00000008
 - tableTag: 676C7966 (glyf)  checksum: D1D1DDF2  offset: 00000B84  length: 00006864
 - tableTag: 68656164 (head)  checksum: 1B81CC40  offset: 000073E8  length: 00000036
 - tableTag: 68686561 (hhea)  checksum: 07300A0A  offset: 00007420  length: 00000024
 - tableTag: 686D7478 (hmtx)  checksum: FA0F1322  offset: 00007444  length: 00000394
 - tableTag: 6C6F6361 (loca)  checksum: C41ADE38  offset: 000077D8  length: 000001CC
 - tableTag: 6D617870 (maxp)  checksum: 019E0E86  offset: 000079A4  length: 00000020
 - tableTag: 6E616D65 (name)  checksum: 75795E75  offset: 000079C4  length: 000007A4
 - tableTag: 706F7374 (post)  checksum: 37633609  offset: 00008168  length: 000001EC
 - tableTag: 70726570 (prep)  checksum: AABDD644  offset: 000091B4  length: 000000B2
offset 00007426: 'descender'      field in 'hhea' table: 00EC (236) --> FF14 (-236) (modified)
offset 0000085E: 'sTypoDescender' field in 'OS/2' table: 00F0 (240) --> FF10 (-240) (modified)
offset 000000A0: checksum for 'hhea' table: 07300A0A --> 07310832 (modified)
offset 00000030: checksum for 'OS/2' table: 8D5E81C9 --> 8D5F7FE9 (modified)
offset 00000090: checksum for 'head' table: 1B81CC40 --> 1B81CC40 (not modified)
offset 000073F0: 'checksumAdjustment' field in 'head' table: A88A6A10 --> A8867180 (modified)
  • Loading branch information
nooriro committed Apr 4, 2023
1 parent 3935d7e commit 2787e25
Show file tree
Hide file tree
Showing 17 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions _sass/minima.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
font-style: normal;
font-weight: normal;
font-stretch: normal;
src: local('Charter'), local('CharterRegular'), url('charter_regular.woff2') format('woff2');
src: local('Charter'), local('CharterRegular'), url('otf/Charter-Regular-fixed.otf') format('opentype');
}

@font-face {
font-family: Charter;
font-style: italic;
font-weight: normal;
font-stretch: normal;
src: local('Charter Italic'), local('CharterItalic'), url('charter_italic.woff2') format('woff2');
src: local('Charter Italic'), local('CharterItalic'), url('otf/Charter-Italic-fixed.otf') format('opentype');
}

@font-face {
font-family: Charter;
font-style: normal;
font-weight: bold;
font-stretch: normal;
src: local('Charter Bold'), local('CharterBold'), url('charter_bold.woff2') format('woff2');
src: local('Charter Bold'), local('CharterBold'), url('otf/Charter-Bold-fixed.otf') format('opentype');
}

@font-face {
font-family: Charter;
font-style: italic;
font-weight: bold;
font-stretch: normal;
src: local('Charter Bold Italic'), local('CharterBoldItalic'), url('charter_bold_italic.woff2') format('woff2');
src: local('Charter Bold Italic'), local('CharterBoldItalic'), url('otf/Charter-Bold-Italic-fixed.otf') format('opentype');
}


Expand Down
Binary file added assets/otf/Charter-Bold-Italic-fixed.otf
Binary file not shown.
Binary file added assets/otf/Charter-Bold-Italic.otf
Binary file not shown.
Binary file added assets/otf/Charter-Bold-fixed.otf
Binary file not shown.
Binary file added assets/otf/Charter-Bold.otf
Binary file not shown.
Binary file added assets/otf/Charter-Italic-fixed.otf
Binary file not shown.
Binary file added assets/otf/Charter-Italic.otf
Binary file not shown.
Binary file added assets/otf/Charter-Regular-fixed.otf
Binary file not shown.
Binary file added assets/otf/Charter-Regular.otf
Binary file not shown.
Binary file added assets/ttf/Charter-Bold-Italic-fixed.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Bold-Italic.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Bold-fixed.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Bold.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Italic-fixed.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Italic.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Regular-fixed.ttf
Binary file not shown.
Binary file added assets/ttf/Charter-Regular.ttf
Binary file not shown.

0 comments on commit 2787e25

Please sign in to comment.