OTS解析错误:无法从字体数据实例化字体

时间:2019-01-18 07:44:21

标签: fonts format specifications opentype

我将这些数据用于计算我的cmap表:

{ version: { type: 'USHORT', value: 0 },
  numTables: { type: 'USHORT', value: 1 },
  platformID: { type: 'USHORT', value: 0 },
  encodingID: { type: 'USHORT', value: 6 },
  offset: { type: 'ULONG', value: 12 },
  format: { type: 'USHORT', value: 4 },
  cmap4Length: { type: 'USHORT', value: 34 },
  language: { type: 'USHORT', value: 0 },
  segCountX2: { type: 'USHORT', value: 4 },
  searchRange: { type: 'USHORT', value: 4 },
  entrySelector: { type: 'USHORT', value: 1 },
  rangeShift: { type: 'USHORT', value: 0 },
  end_0: { type: 'USHORT', value: 97 },
  end_1: { type: 'USHORT', value: 65535 },
  reservedPad: { type: 'USHORT', value: 0 },
  start_0: { type: 'USHORT', value: 97 },
  start_1: { type: 'USHORT', value: 65535 },
  idDelta_0: { type: 'SHORT', value: -97 },
  idDelta_1: { type: 'SHORT', value: 1 },
  idRangeOffset_0: { type: 'USHORT', value: 0 },
  idRangeOffset_1: { type: 'USHORT', value: 0 },
  glyph_0: { type: 'USHORT', value: 0 } }

生成的整体字体文件是这样的:

00000000: 4f54 544f 0009 0008 0003 0001 4346 4632  OTTO........CFF2
00000010: 0000 0000 0000 009c 0000 0055 636d 6170  ...........Ucmap
00000020: 0000 0000 0000 00f4 0000 002e 6865 6164  ............head
00000030: 0000 0000 0000 0124 0000 0036 6868 6561  .......$...6hhea
00000040: 0000 0000 0000 015c 0000 0024 686d 7478  .......\...$hmtx
00000050: 0000 0000 0000 0180 0000 0004 6d61 7870  ............maxp
00000060: 0000 0000 0000 0184 0000 0006 6e61 6d65  ............name
00000070: 0000 0000 0000 018c 0000 0006 4f53 2f32  ............OS/2
00000080: 0000 0000 0000 0194 0000 0064 706f 7374  ...........dpost
00000090: 0000 0000 0000 01f8 0000 0020 0200 0500  ........... ....
                                         ^ ^  ^ ^
                                         | |  | |__________________ 0
                                         | |  |____________________ 5
                                         | |_______________________ 0
                                         |_________________________ 2 (start of CFF table)

000000a0: 171e 0a00 1f1e 0f1e 0f1e 0a00 1f1e 0f1e  ................
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 30
           | |  | |  | |  | |  | |  | |  | |  |____________________ 15
           | |  | |  | |  | |  | |  | |  | |_______________________ 30
           | |  | |  | |  | |  | |  | |  |_________________________ 31
           | |  | |  | |  | |  | |  | |____________________________ 0
           | |  | |  | |  | |  | |  |______________________________ 10
           | |  | |  | |  | |  | |_________________________________ 30
           | |  | |  | |  | |  |___________________________________ 15
           | |  | |  | |  | |______________________________________ 30
           | |  | |  | |  |________________________________________ 15
           | |  | |  | |___________________________________________ 30
           | |  | |  |_____________________________________________ 31
           | |  | |________________________________________________ 0
           | |  |__________________________________________________ 10
           | |_____________________________________________________ 30 /cff2/header/fontmatrix
           |_______________________________________________________ 23

000000b0: 0f0c 07aa 11cd 0c24 a818 da0c 2500 0000  .......$....%...
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 0
           | |  | |  | |  | |  | |  | |  | |  |____________________ 0
           | |  | |  | |  | |  | |  | |  | |_______________________ 0 /globalsubr count32
           | |  | |  | |  | |  | |  | |  |_________________________ 37  = op2 \cff2\header
           | |  | |  | |  | |  | |  | |____________________________ 12  = op1
           | |  | |  | |  | |  | |  |______________________________ 218 = 139 + 79
           | |  | |  | |  | |  | |_________________________________ 24  = op
           | |  | |  | |  | |  |___________________________________ 168 = 139 + 29
           | |  | |  | |  | |______________________________________ 36  = op2
           | |  | |  | |  |________________________________________ 12  = op1
           | |  | |  | |___________________________________________ 205 = 139 + 66
           | |  | |  |_____________________________________________ 17  = op
           | |  | |________________________________________________ 170 = 139 + 31
           | |  |__________________________________________________ 7 \cff2\header\fontmatrix
           | |_____________________________________________________ 12
           |_______________________________________________________ 15

000000c0: 0000 0000 0000 0101 011d 95f7 3405 8b77  ............4..w
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 119 = 139 - 20
           | |  | |  | |  | |  | |  | |  | |  |____________________ 139 = 0
           | |  | |  | |  | |  | |  | |  | |_______________________ 5   = op 5
           | |  | |  | |  | |  | |  | |  |_________________________ 52  = 160 - 108
           | |  | |  | |  | |  | |  | |____________________________ 247 = int2
           | |  | |  | |  | |  | |  |______________________________ 149 = 139 + 10
           | |  | |  | |  | |  | |_________________________________ 29 offset
           | |  | |  | |  | |  |___________________________________ 1 /charstring offsets
           | |  | |  | |  | |______________________________________ 1 /charstring offSize
           | |  | |  | |  |________________________________________ 1 
           | |  | |  | |___________________________________________ 0
           | |  | |  |_____________________________________________ 0
           | |  | |________________________________________________ 0 /charstring count
           | |  |__________________________________________________ 0
           | |_____________________________________________________ 0 /vstore length16
           |_______________________________________________________ 0

000000d0: 15db 9f05 3b8b 05db 8b15 3b77 058b c715  ....;.....;w....
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 21 = op 21
           | |  | |  | |  | |  | |  | |  | |  |____________________ 199 = 139 + 60
           | |  | |  | |  | |  | |  | |  | |_______________________ 139 = 139
           | |  | |  | |  | |  | |  | |  |_________________________ 5 = op 5
           | |  | |  | |  | |  | |  | |____________________________ 119 = 139 - 20
           | |  | |  | |  | |  | |  |______________________________ 59 = 139 - 80
           | |  | |  | |  | |  | |_________________________________ 21 = op 21
           | |  | |  | |  | |  |___________________________________ 139 = 139
           | |  | |  | |  | |______________________________________ 219 = 139 + 80
           | |  | |  | |  |________________________________________ 5 = op 5
           | |  | |  | |___________________________________________ 139 = 139
           | |  | |  |_____________________________________________ 59 = 139 - 80
           | |  | |________________________________________________ 5 = op 5
           | |  |__________________________________________________ 159 = 139 + 20
           | |_____________________________________________________ 219 = 139 + 80
           |_______________________________________________________ 21  = op 21 

000000e0: db4f 058b c715 0000 0001 0101 048b 8b12  .O..............
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 18 = op
           | |  | |  | |  | |  | |  | |  | |  |____________________ 139 = 0
           | |  | |  | |  | |  | |  | |  | |_______________________ 139 = 0
           | |  | |  | |  | |  | |  | |  |_________________________ 4 /fontindex offsets
           | |  | |  | |  | |  | |  | |____________________________ 1 /fontindex offsets 
           | |  | |  | |  | |  | |  |______________________________ 1 /fontindex offsize
           | |  | |  | |  | |  | |_________________________________ 1
           | |  | |  | |  | |  |___________________________________ 0
           | |  | |  | |  | |______________________________________ 0
           | |  | |  | |  |________________________________________ 0 /fontindex count
           | |  | |  | |___________________________________________ 21 = op 21 /charstring
           | |  | |  |_____________________________________________ 199 = 139 + 60
           | |  | |________________________________________________ 139 = 139
           | |  |__________________________________________________ 5 = op 5
           | |_____________________________________________________ 79 = 139 - 60
           |_______________________________________________________ 219 = 139 + 80

000000f0: 0000 0000 0000 0001 0000 0006 0000 000c  ................
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 12
           | |  | |  | |  | |  | |  | |  | |  |____________________ 0
           | |  | |  | |  | |  | |  | |  | |_______________________ 0
           | |  | |  | |  | |  | |  | |  |_________________________ 0 /offset
           | |  | |  | |  | |  | |  | |____________________________ 6
           | |  | |  | |  | |  | |  |______________________________ 0 /encodingID
           | |  | |  | |  | |  | |_________________________________ 0
           | |  | |  | |  | |  |___________________________________ 0 /platformID
           | |  | |  | |  | |______________________________________ 1
           | |  | |  | |  |________________________________________ 0 /numTables
           | |  | |  | |___________________________________________ 0
           | |  | |  |_____________________________________________ 0 /version
           | |  | |________________________________________________ 0
           | |  |__________________________________________________ 0
           | |_____________________________________________________ 0
           |_______________________________________________________ 0

00000100: 0004 0022 0000 0004 0004 0001 0000 0061  ..."...........a
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 97
           | |  | |  | |  | |  | |  | |  | |  |____________________ 0 /end_0
           | |  | |  | |  | |  | |  | |  | |_______________________ 0
           | |  | |  | |  | |  | |  | |  |_________________________ 0 /rangeShift
           | |  | |  | |  | |  | |  | |____________________________ 1
           | |  | |  | |  | |  | |  |______________________________ 0 /entrySelector
           | |  | |  | |  | |  | |_________________________________ 4
           | |  | |  | |  | |  |___________________________________ 0 /searchRange
           | |  | |  | |  | |______________________________________ 4
           | |  | |  | |  |________________________________________ 0 /segCountX2
           | |  | |  | |___________________________________________ 0
           | |  | |  |_____________________________________________ 0 /language
           | |  | |________________________________________________ 34
           | |  |__________________________________________________ 0 /cmap4length
           | |_____________________________________________________ 4
           |_______________________________________________________ 0 /format

00000110: ffff 0000 0061 ffff ff9f 0001 0000 0000  .....a..........
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 0
           | |  | |  | |  | |  | |  | |  | |  |____________________ 0 /idRangeOffset_1
           | |  | |  | |  | |  | |  | |  | |_______________________ 0
           | |  | |  | |  | |  | |  | |  |_________________________ 0 /idRangeOffset_0
           | |  | |  | |  | |  | |  | |____________________________ 1
           | |  | |  | |  | |  | |  |______________________________ 0 /delta_1
           | |  | |  | |  | |  | |_________________________________ 159
           | |  | |  | |  | |  |___________________________________ 255 /delta_0
           | |  | |  | |  | |______________________________________ 255
           | |  | |  | |  |________________________________________ 255 /start_1
           | |  | |  | |___________________________________________ 97
           | |  | |  |_____________________________________________ 0 /start_0
           | |  | |________________________________________________ 0
           | |  |__________________________________________________ 0 /reservePad
           | |_____________________________________________________ 255
           |_______________________________________________________ 255 /end_1

00000120: 0000 0000 0001 0000 0001 0000 0000 0000  ................
           ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^  ^ ^
           | |  | |  | |  | |  | |  | |  | |  | |__________________ 0
           | |  | |  | |  | |  | |  | |  | |  |____________________ 0
           | |  | |  | |  | |  | |  | |  | |_______________________ 0
           | |  | |  | |  | |  | |  | |  |_________________________ 0
           | |  | |  | |  | |  | |  | |____________________________ 0
           | |  | |  | |  | |  | |  |______________________________ 0
           | |  | |  | |  | |  | |_________________________________ 1
           | |  | |  | |  | |  |___________________________________ 0
           | |  | |  | |  | |______________________________________ 0
           | |  | |  | |  |________________________________________ 0
           | |  | |  | |___________________________________________ 1
           | |  | |  |_____________________________________________ 0
           | |  | |________________________________________________ 0
           | |  |__________________________________________________ 0 \cmap
           | |_____________________________________________________ 0
           |_______________________________________________________ 0 /glyph_0

00000130: 5f0f 3cf5 0003 03e8 0000 0000 d867 5bd6  _.<..........g[.
00000140: 0000 0000 d867 5bd6 0000 0000 005a 0000  .....g[......Z..
00000150: 0000 0003 0002 0000 0000 0000 0001 0000  ................
00000160: 00c8 0064 0000 005a 0000 0000 0000 0001  ...d...Z........
00000170: 0000 0000 0000 0000 0000 0000 0000 0001  ................
00000180: 005a 0000 0000 5000 0001 0000 0000 0000  .Z....P.........
00000190: 0006 0000 0005 0000 0000 0000 0000 028a  ................
000001a0: 02bb 0000 008c 028a 02bb 0000 01df 0031  ...............1
000001b0: 0102 0000 0000 0000 0000 0000 0000 0000  ................
000001c0: 0000 0000 0000 0000 0000 0000 0000 5858  ..............XX
000001d0: 5858 0000 0000 0000 0000 0000 0000 0000  XX..............
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001f0: 0000 0000 0000 0000 0003 0000 0000 0000  ................
00000200: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000210: 0000 0000 0000 0000                      ........

想知道在第一个JSON中,一切看起来都不错/符合规范。我本质上只是将来自JSON的十进制值连接起来,然后将其放入Buffer并将其写入文件,因此,如果这是准确的,则最终结果应该是准确的。

不确定255个值是否正确,但是否则我看不到任何会使它不正确的东西。想知道您是否能找到任何东西。

如果我在某些地方稍作改动,那么我会得到:

OTS parsing error: cmap: Failed to parse table

但是得到:

OTS parsing error: cmap: Failed to serialize table

不确定哪个距离工作更近或更远。

如果我更改这两个:

platformID: { type: 'USHORT', value: 3 },
encodingID: { type: 'USHORT', value: 1 },

我得到:

OTS parsing error: Unable to instantiate font face from font data.

1 个答案:

答案 0 :(得分:0)

这是一个非常普通的错误,包含许多子错误。可以通过fontbakeryMac Font Validator找到更多信息,它们各自提供的信息略有不同。还有其他项目,例如Microsoft Font Validator和OTS,但这些项目在调试方面提供了显着的改进。

仍然没有解决整个问题,但是了解更好的错误消息有助于重新组织问题。