TrueType Font cmap table Format 0 not serializing

0

Here is the data I am using to construct the table:

{ version: { type: 'USHORT', value: 0 },
  numTables: { type: 'USHORT', value: 1 },
  platformID: { type: 'USHORT', value: 0 },
  encodingID: { type: 'USHORT', value: 0 },
  offset: { type: 'ULONG', value: 12 },
  format: { type: 'USHORT', value: 0 },
  length: { type: 'USHORT', value: 262 },
  language: { type: 'USHORT', value: 0 },
  glyphIdArray_0: { type: 'BYTE', value: 97 },
  glyphIdArray_1: { type: 'BYTE', value: 98 },
  glyphIdArray_2: { type: 'BYTE', value: 100 },
  glyphIdArray_3: { type: 'BYTE', value: 0 },
  glyphIdArray_4: { type: 'BYTE', value: 0 },
  ...
  glyphIdArray_253: { type: 'BYTE', value: 0 },
  glyphIdArray_254: { type: 'BYTE', value: 0 },
  glyphIdArray_255: { type: 'BYTE', value: 0 } }

I have played with all of these variables:

  • number of glyphIdArray items, from the 3 characters at the beginning, to 262 as specified in the docs.
  • platformID and encodingID, tried 3/4, 1/0, 1/4, 3/1
  • length: tried 3, 256, 262
  • offset: tried 0, 12, 18

The format is 0 in this example, trying to just have a basic font.

Wondering what the correct format is for format: 0 TrueType font cmap table, or why this isn't working.

The two specs I'm looking at are Microsoft's and Apple's.

Not sure if this has anything to do with it, can't really interpret this.

Not sure why the cmap docs say 262 length while the post docs say 258.

Also I tried this:

$ ttfdump Regular.otf
True Type Font File Dumper: v 0.5.5
Copyright 1996-1998 ollie@ms1.hinet.net
Dumping File:Regular.otf


Offset Table
------------
   sfnt version: 'true'
   number of tables: 10
   0. 'OS/2' - checksum = 0x00000000, offset = 0x000000ac, len =       100
   1. 'cmap' - checksum = 0x00000000, offset = 0x00000110, len =       274
   2. 'glyf' - checksum = 0x00000000, offset = 0x00000224, len =        87
   3. 'head' - checksum = 0x00000000, offset = 0x0000027c, len =        54
   4. 'hhea' - checksum = 0x00000000, offset = 0x000002b4, len =        36
   5. 'hmtx' - checksum = 0x00000000, offset = 0x000002d8, len =        12
   6. 'loca' - checksum = 0x00000000, offset = 0x000002e4, len =        16
   7. 'maxp' - checksum = 0x00000000, offset = 0x000002f4, len =        32
   8. 'name' - checksum = 0x00000000, offset = 0x00000314, len =       173
   9. 'post' - checksum = 0x00000000, offset = 0x000003c4, len =        32

'cmap' Table - Character to Glyph Index Mapping Table
-----------------------------------------------------
   'cmap' version: 0
   number of encodings: 1
   number of subtables: 1

Encoding   0.  PlatformID:  0
     EcodingID:   4
     SubTable: 0, Offset: 0x0000000c

SubTable   0.  Format 0 - Byte encoding table
     Length:     256
     Version:      0
     Char   0 -> Index    0
     Char   1 -> Index    0
     Char   2 -> Index    0
     Char   3 -> Index   98
     Char   4 -> Index   98
     Char   5 -> Index   98
     Char   6 -> Index   98
     Char   7 -> Index   98
     Char   8 -> Index   98
     Char   9 -> Index   98
     Char  10 -> Index   98
     Char  11 -> Index   98
     Char  12 -> Index   98
     Char  13 -> Index   98
     Char  14 -> Index   98
     Char  15 -> Index   98
     Char  16 -> Index   98
     Char  17 -> Index   98
     Char  18 -> Index   98
     Char  19 -> Index   98
     Char  20 -> Index   98
     Char  21 -> Index   98
     Char  22 -> Index   98
     Char  23 -> Index   98
     Char  24 -> Index   98
     Char  25 -> Index   98
     Char  26 -> Index   98
     Char  27 -> Index   98
     Char  28 -> Index   98
     Char  29 -> Index   98
     Char  30 -> Index   98
     Char  31 -> Index   98
     Char  32 -> Index   98
     Char  33 -> Index   98
     Char  34 -> Index   98
     Char  35 -> Index   98
     Char  36 -> Index   98
     Char  37 -> Index   98
     Char  38 -> Index   98
     Char  39 -> Index   98
     Char  40 -> Index   98
     Char  41 -> Index   98
     Char  42 -> Index   98
     Char  43 -> Index   98
     Char  44 -> Index   98
     Char  45 -> Index   98
     Char  46 -> Index   98
     Char  47 -> Index   98
     Char  48 -> Index   98
     Char  49 -> Index   98
     Char  50 -> Index   98
     Char  51 -> Index   98
     Char  52 -> Index   98
     Char  53 -> Index   98
     Char  54 -> Index   98
     Char  55 -> Index   98
     Char  56 -> Index   98
     Char  57 -> Index   98
     Char  58 -> Index   98
     Char  59 -> Index   98
     Char  60 -> Index   98
     Char  61 -> Index   98
     Char  62 -> Index   98
     Char  63 -> Index   98
     Char  64 -> Index   98
     Char  65 -> Index   98
     Char  66 -> Index   98
     Char  67 -> Index   98
     Char  68 -> Index   98
     Char  69 -> Index   98
     Char  70 -> Index   98
     Char  71 -> Index   98
     Char  72 -> Index   98
     Char  73 -> Index   98
     Char  74 -> Index   98
     Char  75 -> Index   98
     Char  76 -> Index   98
     Char  77 -> Index   98
     Char  78 -> Index   98
     Char  79 -> Index   98
     Char  80 -> Index   98
     Char  81 -> Index   98
     Char  82 -> Index   98
     Char  83 -> Index   98
     Char  84 -> Index   98
     Char  85 -> Index   98
     Char  86 -> Index   98
     Char  87 -> Index   98
     Char  88 -> Index   98
     Char  89 -> Index   98
     Char  90 -> Index   98
     Char  91 -> Index   98
     Char  92 -> Index   98
     Char  93 -> Index   98
     Char  94 -> Index   98
     Char  95 -> Index   98
     Char  96 -> Index   98
     Char  97 -> Index   98
     Char  98 -> Index   98
     Char  99 -> Index   98
     Char 100 -> Index   98
     Char 101 -> Index   98
     Char 102 -> Index   98
     Char 103 -> Index   98
     Char 104 -> Index   98
     Char 105 -> Index   98
     Char 106 -> Index   98
     Char 107 -> Index   98
     Char 108 -> Index   98
     Char 109 -> Index   98
     Char 110 -> Index   98
     Char 111 -> Index   98
     Char 112 -> Index   98
     Char 113 -> Index   98
     Char 114 -> Index   98
     Char 115 -> Index   98
     Char 116 -> Index   98
     Char 117 -> Index   98
     Char 118 -> Index   98
     Char 119 -> Index   98
     Char 120 -> Index   98
     Char 121 -> Index   98
     Char 122 -> Index   98
     Char 123 -> Index   98
     Char 124 -> Index   98
     Char 125 -> Index   98
     Char 126 -> Index   98
     Char 127 -> Index   98
     Char 128 -> Index   98
     Char 129 -> Index   98
     Char 130 -> Index   98
     Char 131 -> Index   98
     Char 132 -> Index   98
     Char 133 -> Index   98
     Char 134 -> Index   98
     Char 135 -> Index   98
     Char 136 -> Index   98
     Char 137 -> Index   98
     Char 138 -> Index   98
     Char 139 -> Index   98
     Char 140 -> Index   98
     Char 141 -> Index   98
     Char 142 -> Index   98
     Char 143 -> Index   98
     Char 144 -> Index   98
     Char 145 -> Index   98
     Char 146 -> Index   98
     Char 147 -> Index   98
     Char 148 -> Index   98
     Char 149 -> Index   98
     Char 150 -> Index   98
     Char 151 -> Index   98
     Char 152 -> Index   98
     Char 153 -> Index   98
     Char 154 -> Index   98
     Char 155 -> Index   98
     Char 156 -> Index   98
     Char 157 -> Index   98
     Char 158 -> Index   98
     Char 159 -> Index   98
     Char 160 -> Index   98
     Char 161 -> Index   98
     Char 162 -> Index   98
     Char 163 -> Index   98
     Char 164 -> Index   98
     Char 165 -> Index   98
     Char 166 -> Index   98
     Char 167 -> Index   98
     Char 168 -> Index   98
     Char 169 -> Index   98
     Char 170 -> Index   98
     Char 171 -> Index   98
     Char 172 -> Index   98
     Char 173 -> Index   98
     Char 174 -> Index   98
     Char 175 -> Index   98
     Char 176 -> Index   98
     Char 177 -> Index   98
     Char 178 -> Index   98
     Char 179 -> Index   98
     Char 180 -> Index   98
     Char 181 -> Index   98
     Char 182 -> Index   98
     Char 183 -> Index   98
     Char 184 -> Index   98
     Char 185 -> Index   98
     Char 186 -> Index   98
     Char 187 -> Index   98
     Char 188 -> Index   98
     Char 189 -> Index   98
     Char 190 -> Index   98
     Char 191 -> Index   98
     Char 192 -> Index   98
     Char 193 -> Index   98
     Char 194 -> Index   98
     Char 195 -> Index   98
     Char 196 -> Index   98
     Char 197 -> Index   98
     Char 198 -> Index   98
     Char 199 -> Index   98
     Char 200 -> Index   98
     Char 201 -> Index   98
     Char 202 -> Index   98
     Char 203 -> Index   98
     Char 204 -> Index   98
     Char 205 -> Index   98
     Char 206 -> Index   98
     Char 207 -> Index   98
     Char 208 -> Index   98
     Char 209 -> Index   98
     Char 210 -> Index   98
     Char 211 -> Index   98
     Char 212 -> Index   98
     Char 213 -> Index   98
     Char 214 -> Index   98
     Char 215 -> Index   98
     Char 216 -> Index   98
     Char 217 -> Index   98
     Char 218 -> Index   98
     Char 219 -> Index   98
     Char 220 -> Index   98
     Char 221 -> Index   98
     Char 222 -> Index   98
     Char 223 -> Index   98
     Char 224 -> Index   98
     Char 225 -> Index   98
     Char 226 -> Index   98
     Char 227 -> Index   98
     Char 228 -> Index   98
     Char 229 -> Index   98
     Char 230 -> Index   98
     Char 231 -> Index   98
     Char 232 -> Index   98
     Char 233 -> Index   98
     Char 234 -> Index   98
     Char 235 -> Index   98
     Char 236 -> Index   98
     Char 237 -> Index   98
     Char 238 -> Index   98
     Char 239 -> Index   98
     Char 240 -> Index   98
     Char 241 -> Index   98
     Char 242 -> Index   98
     Char 243 -> Index   98
     Char 244 -> Index   98
     Char 245 -> Index   98
     Char 246 -> Index   98
     Char 247 -> Index   98
     Char 248 -> Index   98
     Char 249 -> Index   98
     Char 250 -> Index   98
     Char 251 -> Index   98
     Char 252 -> Index   98
     Char 253 -> Index   98
     Char 254 -> Index   98
     Char 255 -> Index   98


'head' Table - Font Header
--------------------------
   'head' version:   1.0
   fontReversion:    1.4352
   checkSumAdjustment:   0x00000000
   magicNumber:    0x5f0f3cf5
   flags:      0x0003
   unitsPerEm:     2048
   created:    0x00000000d86cebf5
   modified:     0x00000000d86cebf5
   xMin:       10
   yMin:       10
   xMax:       90
   yMax:       90
   macStyle bits:    0x0000
   lowestRecPPEM:    3
   fontDirectionHint:  2
   indexToLocFormat:   1
   glyphDataFormat:  0


'hhea' Table - Horizontal Header
--------------------------
   'hhea' version:   1.0
   yAscender:    200
   yDescender:     100
   yLineGap:     0
   advanceWidthMax:  90
   minLeftSideBearing:   0
   minRightSideBearing:  10
   xMaxExtent:     80
   caretSlopeRise:   1
   caretSlopeRun:    0
   reserved0:    0
   reserved1:    0
   reserved2:    0
   reserved3:    0
   reserved4:    0
   metricDataFormat:   0
   numberOfHMetrics:   3

'hmtx' Table - Horizontal Metrics
---------------------------------
      0. advWid:   90, LSBear:   10
      1. advWid:   90, LSBear:   10
      2. advWid:   90, LSBear:   10

'loca' Table - Index to Location
--------------------------------
   Idx      0 -> GlyphOffset 0x00000000
   Idx      1 -> GlyphOffset 0x0000001d
   Idx      2 -> GlyphOffset 0x0000003a
   Ended at 0x00000057

'maxp' Table - Maximum Profile
------------------------------
   'maxp' version:   1.0
   numGlyphs:    3
   maxPoints:    5
   maxContours:    1
   maxCompositePoints:   0
   maxCompositeContours:   0
   maxZones:     1
   maxTwilightPoints:  0
   maxStorage:     0
   maxFunctionDefs:  0
   maxInstructionDefs:   0
   maxStackElements:   0
   maxSizeOfInstructions:  0
   maxComponentElements:   0
   maxCompoenetDepth:  0

'name' Table - Naming Table
---------------------------
   Format:     0
   Number of Record:   7
   Storage offset:   90
Name table   0.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   6
     Length:   3
     Offset:   0
     46 6f 6f                       > Foo
Name table   1.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   1
     Length:   3
     Offset:   0
     46 6f 6f                       > Foo
Name table   2.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   2
     Length:   7
     Offset:   3
     52 65 67 75 6c 61 72           > Regular
Name table   3.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   3
     Length:   3
     Offset:   10
     66 6f 6f                       > foo
Name table   4.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   4
     Length:   11
     Offset:   13
     46 6f 6f 20 52 65 67 75 6c 61  >  Foo Regula
     72                             > r
Name table   5.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   13
     Length:   46
     Offset:   24
     4c 69 63 65 6e 73 65 64 20 75  >  Licensed u
     6e 64 65 72 20 74 68 65 20 41  >  nder the A
     70 61 63 68 65 20 4c 69 63 65  >  pache Lice
     6e 73 65 2c 20 56 65 72 73 69  >  nse, Versi
     6f 6e 20 32 2e 30              > on 2.0
Name table   6.  PlatformID:   1
     EncodingID:   0
     LanguageID:   0
     NameID:   5
     Length:   13
     Offset:   70
     56 65 72 73 69 6f 6e 20 31 2e  >  Version 1.
     30 30 30                       > 000

'post' Table - PostScript
-------------------------
   'post' format:    1.0
   italicAngle:    0.0
   underlinePosition:  0
   underlineThichness:   0
   isFixedPitch:     1d
   minMemType42:     0d
   maxMemType42:     0d
   minMemType1:    0d
   maxMemType1:    0d
'OS/2' Table - OS/2 and Windows Metrics
---------------------------------------
   'OS/2' version:   5
   xAvgCharWidth:    90
   usWeightClass:    500   'Medium'
   usWidthClass:     5   'Medium'
   fsType:     0
   ySubscriptXSize:  650
   ySubscriptYSize:  699
   ySubscriptXOffset:  0
   ySubscriptYOffset:  140
   ySuperscriptXSize:  650
   ySuperscriptYSize:  699
   ySuperscriptXOffset:  0
   ySuperscriptYOffset:  479
   yStrikeoutSize:   49
   yStrikeoutPosition  258
   sFamilyClass:   0   subclass = 0
   PANOSE:
     Family Kind:  0   'Any'
     Serif Style:  0   'Any'
     Weight:   0   'Any'
     Proportion:   9   'Monospaced'
     Contrast:   0   'Any'
     Stroke:   0   'Any'
     Arm Style:  0   'Any'
     Lettreform:   0   'Any'
     Midline:  0   'Any'
     X-height:   0   'Any'
   Unicode Range 1( Bits 0 - 31 ):   0x00000000
   Unicode Range 2( Bits 32 - 63 ):    0x00000000
   Unicode Range 3( Bits 64 - 95 ):    0x00000000
   Unicode Range 4( Bits 96 - 128 ):   0x00000000
   achVendID:    'XXXX'
   fsSelection:    0x0040    'Regular '
   usFirstCharIndex:   0x0061
   usLastCharIndex:  0x0064
   sTypoAscender:    200
   sTypoDescender:   100
   sTypoLineGap:     0
   usWinAscent:    90
   usWinDescent:     10
   CodePage Range 1( Bits 0 - 31 ):  0x00000001
   CodePage Range 2( Bits 32- 63 ):  0x00000000
   sxHeight:     100
   sCapHeight:     40
   usDefaultChar:    0x0000
   usBreakChar:    0x0000
   usMaxContext:     0
Glyph      0.
   numberOfContours:   1
   xMin:       10
   yMin:       10
   xMax:       90
   yMax:       90

   EndPoints
   ---------
    0:  4

   Length of Instructions:  0

   Flags
   -----
    0: YDual  XDual           Y-Short X-Short On
    1: YDual  XDual           Y-Short X-Short On
    2: YDual  XDual           Y-Short X-Short On
    3: YDual                  Y-Short X-Short On
    4:        XDual           Y-Short X-Short On

   Coordinates
   -----------
    0 Rel (     10,     10) -> Abs (     10,     10)
    1 Rel (     80,      0) -> Abs (     90,     10)
    2 Rel (      0,     80) -> Abs (     90,     90)
    3 Rel (    -80,      0) -> Abs (     10,     90)
    4 Rel (      0,    -80) -> Abs (     10,     10)

Glyph      1.
   numberOfContours:   1
   xMin:       10
   yMin:       10
   xMax:       90
   yMax:       90

   EndPoints
   ---------
    0:  4

   Length of Instructions:  0

   Flags
   -----
    0: YDual  XDual           Y-Short X-Short On
    1: YDual  XDual           Y-Short X-Short On
    2: YDual  XDual           Y-Short X-Short On
    3: YDual                  Y-Short X-Short On
    4:        XDual           Y-Short X-Short On

   Coordinates
   -----------
    0 Rel (     10,     10) -> Abs (     10,     10)
    1 Rel (     80,      0) -> Abs (     90,     10)
    2 Rel (      0,     80) -> Abs (     90,     90)
    3 Rel (    -80,      0) -> Abs (     10,     90)
    4 Rel (      0,    -80) -> Abs (     10,     10)

Glyph      2.
   numberOfContours:   1
   xMin:       10
   yMin:       10
   xMax:       90
   yMax:       90

   EndPoints
   ---------
    0:  4

   Length of Instructions:  0

   Flags
   -----
    0: YDual  XDual           Y-Short X-Short On
    1: YDual  XDual           Y-Short X-Short On
    2: YDual  XDual           Y-Short X-Short On
    3: YDual                  Y-Short X-Short On
    4:        XDual           Y-Short X-Short On

   Coordinates
   -----------
    0 Rel (     10,     10) -> Abs (     10,     10)
    1 Rel (     80,      0) -> Abs (     90,     10)
    2 Rel (      0,     80) -> Abs (     90,     90)
    3 Rel (    -80,      0) -> Abs (     10,     90)
    4 Rel (      0,    -80) -> Abs (     10,     10)

But still says this in Chrome:

OTS parsing error: cmap: Failed to serialize table

It looks like OTS just fails for some unknown reason:

>> com.google.fonts/check/036 with (('font[0]', 'Regular.otf'),)
   Checking with ots-sanitize.
 * FAIL: ots-sanitize returned an error code (1). Output follows:

WARNING: bad search range
WARNING: bad range shift
WARNING: name: name records are not sorted.
WARNING: name: name records are not sorted.
ERROR: cmap: no supported subtables were found
ERROR: cmap: Failed to serialize table
Failed to sanitize file!

But ttfdump and ttx both work fine.

<cmap>
  <tableVersion version="0"/>
  <cmap_format_4 platformID="3" platEncID="1" language="0">
    <map code="0x62" name=".null"/><!-- LATIN SMALL LETTER B -->
    <map code="0x64" name="nonmarkingreturn"/><!-- LATIN SMALL LETTER D -->
  </cmap_format_4>
</cmap>

Maybe this will help.

fonts
truetype
asked on Stack Overflow Jan 22, 2019 by user10869858 • edited Jan 22, 2019 by user10869858

1 Answer

0

It looks like Chrome, which uses OTS, doesn't support format 0.

// We only support a subset of the possible character map tables. Microsoft
// 'strongly recommends' that everyone supports the Unicode BMP table with
// the UCS-4 table for non-BMP glyphs. We'll pass the following subtables:
//   Platform ID   Encoding ID  Format
//   0             0            4       (Unicode Default)
//   0             1            4       (Unicode 1.1)
//   0             3            4       (Unicode BMP)
//   0             3            12      (Unicode UCS-4)
//   0             5            14      (Unicode Variation Sequences)
//   1             0            0       (Mac Roman)
//   3             0            4       (MS Symbol)
//   3             1            4       (MS Unicode BMP)
//   3             10           12      (MS Unicode UCS-4)
//   3             10           13      (MS UCS-4 Fallback mapping)
//
// Note:
//  * 0-0-4 and 0-1-4 tables are (usually) written as a 3-1-4 table. If 3-1-4 table
//    also exists, the 0-0-4 or 0-1-4 tables are ignored.
//  * Unlike 0-0-4 table, 0-3-4 table is written as a 0-3-4 table.
//    Some fonts which include 0-5-14 table seems to be required 0-3-4
//    table. The 0-3-4 table will be wriiten even if 3-1-4 table also exists.
//  * 0-3-12 table is written as a 3-10-12 table. If 3-10-12 table also
//    exists, the 0-3-12 table is ignored.
//

https://chromium.googlesource.com/external/ots/+/master/src/cmap.cc#728

answered on Stack Overflow Jan 22, 2019 by user10869858

User contributions licensed under CC BY-SA 3.0