我正在编译一种字体,并且遇到了一些错误。我正在学习如何使用十六进制查看器调试二进制文件,但这对我来说仍然是新的。
想知道其中一些数字的含义:
00000000: 4f54 544f 0009 0008 0003 0001 4346 4632 OTTO........CFF2
00000010: 0000 0000 0000 00c2 9c00 0000 1063 6d61 .............cma
00000020: 7000 0000 0000 0000 c2ac 0000 0024 6865 p............$he
00000030: 6164 0000 0000 0000 00c3 9000 0000 3668 ad............6h
00000040: 6865 6100 0000 0000 0001 0800 0000 2468 hea...........$h
00000050: 6d74 7800 0000 0000 0001 2c00 0000 006d mtx.......,....m
00000060: 6178 7000 0000 0000 0001 2c00 0000 066e axp.......,....n
00000070: 616d 6500 0000 0000 0001 3400 0000 064f ame.......4....O
00000080: 532f 3200 0000 0000 0001 3c00 0000 6470 S/2.......<...dp
00000090: 6f73 7400 0000 0000 0001 c2a0 0000 0020 ost............
000000a0: 00c2 b400 c384 00c3 a800 0001 1e01 4201 ..............B.
000000b0: 4200 0001 4800 0001 4e01 c2b2 0200 0400 B...H...N.......
000000c0: 0000 0000 0000 0000 0000 0000 0000 0001 ................
000000d0: 0000 0006 0000 0010 0004 0010 0000 0002 ................
000000e0: 0002 0000 0000 c3bf c3bf 0000 c3bf c3bf ................
000000f0: 0001 0000 0001 0000 0001 0000 0000 0000 ................
00000100: 5f0f 3cc3 b500 0303 c3a8 0000 0000 c398 _.<.............
00000110: 65c2 98c3 8a00 0000 00c3 9865 c298 c38a e..........e....
00000120: 0000 0000 0000 0000 0000 0003 0002 0000 ................
00000130: 0000 0001 0000 00c3 8800 6400 0000 0000 ..........d.....
00000140: 0000 0000 0000 0100 0000 0000 0000 0000 ................
00000150: 0000 0000 0000 0000 0050 0000 0000 0000 .........P......
00000160: 0000 0600 0500 0000 0000 0000 0002 c28a ................
00000170: 02c2 bb00 0000 c28c 02c2 8a02 c2bb 0000 ................
00000180: 01c3 9f00 3101 0200 0000 0000 0000 0000 ....1...........
00000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001a0: 0000 0058 5858 5800 0000 0000 0000 0000 ...XXXX.........
000001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001c0: 0000 0000 0000 0000 0000 0000 0000 0300 ................
000001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001e0: 0000 0000 0000 0000 0000 0000 00 .............
我特别想知道,为什么它们没有以整数或某种形式出现在右侧。我想知道右边的东西是如何显示的,如果只是显示它的“运气”,或者有一些系统可以让我更多地了解它。
基本上,我具有将序列化到此二进制文件中的数据结构:
{
"name": "sfnt",
"fields": {
"scalar": {
"type": "TAG",
"value": "OTTO"
},
"numTables": {
"type": "USHORT",
"value": 9
},
"searchRange": {
"type": "USHORT",
"value": 8
},
"entrySelector": {
"type": "USHORT",
"value": 3
},
"rangeShift": {
"type": "USHORT",
"value": 1
},
"CFF2 Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "CFF2"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 156
},
"length": {
"type": "ULONG",
"value": 16
}
}
}
},
"cmap Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "cmap"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 172
},
"length": {
"type": "ULONG",
"value": 36
}
}
}
},
"head Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "head"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 208
},
"length": {
"type": "ULONG",
"value": 54
}
}
}
},
"hhea Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "hhea"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 264
},
"length": {
"type": "ULONG",
"value": 36
}
}
}
},
"hmtx Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "hmtx"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 300
},
"length": {
"type": "ULONG",
"value": 0
}
}
}
},
"maxp Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "maxp"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 300
},
"length": {
"type": "ULONG",
"value": 6
}
}
}
},
"name Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "name"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 308
},
"length": {
"type": "ULONG",
"value": 6
}
}
}
},
"OS/2 Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "OS/2"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 316
},
"length": {
"type": "ULONG",
"value": 100
}
}
}
},
"post Table Record": {
"type": "RECORD",
"value": {
"name": "Table Record",
"fields": {
"tag": {
"type": "TAG",
"value": "post"
},
"checkSum": {
"type": "ULONG",
"value": 0
},
"offset": {
"type": "ULONG",
"value": 416
},
"length": {
"type": "ULONG",
"value": 32
}
}
}
},
"CFF2 table": {
"type": "RECORD",
"value": {
"name": "CFF2",
"fields": {
"header": {
"type": "RECORD",
"value": {
"name": "Header",
"fields": {
"major": {
"type": "BYTE",
"value": 2
},
"minor": {
"type": "BYTE",
"value": 0
},
"hdrSize": {
"type": "BYTE",
"value": 4
},
"topDictLength": {
"type": "USHORT",
"value": 0
}
}
}
},
"nameIndex": {
"type": "RECORD",
"value": {
"name": "Name INDEX",
"fields": {
"names": {
"type": "INDEX",
"value": []
}
}
}
},
"topDictIndex": {
"type": "RECORD",
"value": {
"name": "Top DICT INDEX",
"fields": {
"topDicts": {
"type": "INDEX",
"value": [
{
"name": "topDict_0",
"type": "TABLE",
"value": {}
}
]
}
}
}
},
"stringIndex": {
"type": "RECORD",
"value": {
"name": "String INDEX",
"fields": {
"strings": {
"type": "INDEX",
"value": []
}
}
}
},
"globalSubrIndex": {
"type": "RECORD",
"value": {
"name": "Global Subr INDEX",
"fields": {
"subrs": {
"type": "INDEX",
"value": []
}
}
}
},
"charsets": {
"type": "RECORD",
"value": {
"name": "Charsets",
"fields": {
"format": {
"type": "Card8",
"value": 0
}
}
}
},
"charStringsIndex": {
"type": "RECORD",
"value": {
"name": "CharStrings INDEX",
"fields": {
"charStrings": {
"type": "INDEX",
"value": []
}
}
}
},
"privateDict": {
"type": "RECORD",
"value": {
"name": "Private DICT",
"fields": {
"dict": {
"type": "DICT",
"value": {}
}
}
}
}
}
}
},
"cmap table": {
"type": "RECORD",
"value": {
"name": "cmap",
"fields": {
"version": {
"type": "USHORT",
"value": 0
},
"numTables": {
"type": "USHORT",
"value": 1
},
"platformID": {
"type": "USHORT",
"value": 0
},
"encodingID": {
"type": "USHORT",
"value": 6
},
"offset": {
"type": "ULONG",
"value": 16
},
"format": {
"type": "USHORT",
"value": 4
},
"cmap4Length": {
"type": "USHORT",
"value": 16
},
"language": {
"type": "USHORT",
"value": 0
},
"segCountX2": {
"type": "USHORT",
"value": 2
},
"searchRange": {
"type": "USHORT",
"value": 2
},
"entrySelector": {
"type": "USHORT",
"value": 0
},
"rangeShift": {
"type": "USHORT",
"value": 0
},
"end_0": {
"type": "USHORT",
"value": 65535
},
"reservedPad": {
"type": "USHORT",
"value": 0
},
"start_0": {
"type": "USHORT",
"value": 65535
},
"idDelta_0": {
"type": "SHORT",
"value": 1
},
"idRangeOffset_0": {
"type": "USHORT",
"value": 0
}
}
}
},
"head table": {
"type": "RECORD",
"value": {
"name": "head",
"fields": {
"version": {
"type": "FIXED",
"value": 65536
},
"fontRevision": {
"type": "FIXED",
"value": 65536
},
"checkSumAdjustment": {
"type": "ULONG",
"value": 0
},
"magicNumber": {
"type": "ULONG",
"value": 1594834165
},
"flags": {
"type": "USHORT",
"value": 3
},
"unitsPerEm": {
"type": "USHORT",
"value": 1000
},
"created": {
"type": "LONGDATETIME",
"value": 3630534741
},
"modified": {
"type": "LONGDATETIME",
"value": 3630534741
},
"xMin": {
"type": "SHORT",
"value": null
},
"yMin": {
"type": "SHORT",
"value": null
},
"xMax": {
"type": "SHORT",
"value": null
},
"yMax": {
"type": "SHORT",
"value": null
},
"macStyle": {
"type": "USHORT",
"value": 0
},
"lowestRecPPEM": {
"type": "USHORT",
"value": 3
},
"fontDirectionHint": {
"type": "SHORT",
"value": 2
},
"indexToLocFormat": {
"type": "SHORT",
"value": 0
},
"glyphDataFormat": {
"type": "SHORT",
"value": 0
}
}
}
},
"padding_0": {
"type": "BYTE",
"value": 0
},
"padding_1": {
"type": "BYTE",
"value": 0
},
"hhea table": {
"type": "RECORD",
"value": {
"name": "hhea",
"fields": {
"version": {
"type": "FIXED",
"value": 65536
},
"ascender": {
"type": "FWORD",
"value": 200
},
"descender": {
"type": "FWORD",
"value": 100
},
"lineGap": {
"type": "FWORD",
"value": 0
},
"advanceWidthMax": {
"type": "UFWORD",
"value": null
},
"minLeftSideBearing": {
"type": "FWORD",
"value": null
},
"minRightSideBearing": {
"type": "FWORD",
"value": null
},
"xMaxExtent": {
"type": "FWORD",
"value": null
},
"caretSlopeRise": {
"type": "SHORT",
"value": 1
},
"caretSlopeRun": {
"type": "SHORT",
"value": 0
},
"caretOffset": {
"type": "SHORT",
"value": 0
},
"reserved1": {
"type": "SHORT",
"value": 0
},
"reserved2": {
"type": "SHORT",
"value": 0
},
"reserved3": {
"type": "SHORT",
"value": 0
},
"reserved4": {
"type": "SHORT",
"value": 0
},
"metricDataFormat": {
"type": "SHORT",
"value": 0
},
"numberOfHMetrics": {
"type": "USHORT",
"value": 0
}
}
}
},
"hmtx table": {
"type": "RECORD",
"value": {
"name": "hmtx",
"fields": {}
}
},
"maxp table": {
"type": "RECORD",
"value": {
"name": "maxp",
"fields": {
"version": {
"type": "FIXED",
"value": 20480
},
"numGlyphs": {
"type": "USHORT",
"value": 0
}
}
}
},
"padding_2": {
"type": "BYTE",
"value": 0
},
"padding_3": {
"type": "BYTE",
"value": 0
},
"name table": {
"type": "RECORD",
"value": {
"name": "name",
"fields": {
"format": {
"type": "USHORT",
"value": 0
},
"count": {
"type": "USHORT",
"value": 0
},
"stringOffset": {
"type": "USHORT",
"value": 6
},
"strings": {
"type": "LITERAL",
"value": []
}
}
}
},
"padding_4": {
"type": "BYTE",
"value": 0
},
"padding_5": {
"type": "BYTE",
"value": 0
},
"OS/2 table": {
"type": "RECORD",
"value": {
"name": "OS/2",
"fields": {
"version": {
"type": "USHORT",
"value": 5
},
"xAvgCharWidth": {
"type": "SHORT",
"value": 0
},
"usWeightClass": {
"type": "USHORT",
"value": 0
},
"usWidthClass": {
"type": "USHORT",
"value": 0
},
"fsType": {
"type": "USHORT",
"value": 0
},
"ySubscriptXSize": {
"type": "SHORT",
"value": 650
},
"ySubscriptYSize": {
"type": "SHORT",
"value": 699
},
"ySubscriptXOffset": {
"type": "SHORT",
"value": 0
},
"ySubscriptYOffset": {
"type": "SHORT",
"value": 140
},
"ySuperscriptXSize": {
"type": "SHORT",
"value": 650
},
"ySuperscriptYSize": {
"type": "SHORT",
"value": 699
},
"ySuperscriptXOffset": {
"type": "SHORT",
"value": 0
},
"ySuperscriptYOffset": {
"type": "SHORT",
"value": 479
},
"yStrikeoutSize": {
"type": "SHORT",
"value": 49
},
"yStrikeoutPosition": {
"type": "SHORT",
"value": 258
},
"sFamilyClass": {
"type": "SHORT",
"value": 0
},
"bFamilyType": {
"type": "BYTE",
"value": 0
},
"bSerifStyle": {
"type": "BYTE",
"value": 0
},
"bWeight": {
"type": "BYTE",
"value": 0
},
"bProportion": {
"type": "BYTE",
"value": 0
},
"bContrast": {
"type": "BYTE",
"value": 0
},
"bStrokeVariation": {
"type": "BYTE",
"value": 0
},
"bArmStyle": {
"type": "BYTE",
"value": 0
},
"bLetterform": {
"type": "BYTE",
"value": 0
},
"bMidline": {
"type": "BYTE",
"value": 0
},
"bXHeight": {
"type": "BYTE",
"value": 0
},
"ulUnicodeRange1": {
"type": "ULONG",
"value": 0
},
"ulUnicodeRange2": {
"type": "ULONG",
"value": 0
},
"ulUnicodeRange3": {
"type": "ULONG",
"value": 0
},
"ulUnicodeRange4": {
"type": "ULONG",
"value": 0
},
"achVendID": {
"type": "CHARARRAY",
"value": "XXXX"
},
"fsSelection": {
"type": "USHORT",
"value": 0
},
"usFirstCharIndex": {
"type": "USHORT",
"value": 0
},
"usLastCharIndex": {
"type": "USHORT",
"value": 0
},
"sTypoAscender": {
"type": "SHORT",
"value": 0
},
"sTypoDescender": {
"type": "SHORT",
"value": 0
},
"sTypoLineGap": {
"type": "SHORT",
"value": 0
},
"usWinAscent": {
"type": "USHORT",
"value": 0
},
"usWinDescent": {
"type": "USHORT",
"value": 0
},
"ulCodePageRange1": {
"type": "ULONG",
"value": 0
},
"ulCodePageRange2": {
"type": "ULONG",
"value": 0
},
"sxHeight": {
"type": "SHORT",
"value": 0
},
"sCapHeight": {
"type": "SHORT",
"value": 0
},
"usDefaultChar": {
"type": "USHORT",
"value": 0
},
"usBreakChar": {
"type": "USHORT",
"value": 0
},
"usMaxContext": {
"type": "USHORT",
"value": 0
},
"usLowerOpticalPointSize": {
"type": "USHORT",
"value": 0
},
"usUpperOpticalPointSize": {
"type": "USHORT",
"value": 0
}
}
}
},
"post table": {
"type": "RECORD",
"value": {
"name": "post",
"fields": {
"version": {
"type": "FIXED",
"value": 196608
},
"italicAngle": {
"type": "FIXED",
"value": 0
},
"underlinePosition": {
"type": "FWORD",
"value": 0
},
"underlineThickness": {
"type": "FWORD",
"value": 0
},
"isFixedPitch": {
"type": "ULONG",
"value": 0
},
"minMemType42": {
"type": "ULONG",
"value": 0
},
"maxMemType42": {
"type": "ULONG",
"value": 0
},
"minMemType1": {
"type": "ULONG",
"value": 0
},
"maxMemType1": {
"type": "ULONG",
"value": 0
}
}
}
}
}
}
基本上所有的value
字段都是串联的,在序列化过程中进行一些轻微的修改。所以这就是可能出现错误的地方,我想调查一下。
通过删除toArrayBuffer
的内容并只做write(new Buffer(bytes))
,我得到了这样的结果:
00000000: 4f54 544f 0009 0008 0003 0001 4346 4632 OTTO........CFF2
00000010: 0000 0000 0000 009c 0000 0010 636d 6170 ............cmap
00000020: 0000 0000 0000 00ac 0000 0024 6865 6164 ...........$head
00000030: 0000 0000 0000 00d0 0000 0036 6868 6561 ...........6hhea
00000040: 0000 0000 0000 0108 0000 0024 686d 7478 ...........$hmtx
00000050: 0000 0000 0000 012c 0000 0000 6d61 7870 .......,....maxp
00000060: 0000 0000 0000 012c 0000 0006 6e61 6d65 .......,....name
00000070: 0000 0000 0000 0134 0000 0006 4f53 2f32 .......4....OS/2
00000080: 0000 0000 0000 013c 0000 0064 706f 7374 .......<...dpost
00000090: 0000 0000 0000 01a0 0000 0020 0200 0400 ........... ....
000000a0: 0000 0000 0000 0000 0000 0000 0000 0001 ................
000000b0: 0000 0006 0000 0010 0004 0010 0000 0002 ................
000000c0: 0002 0000 0000 ffff 0000 ffff 0001 0000 ................
000000d0: 0001 0000 0001 0000 0000 0000 5f0f 3cf5 ............_.<.
000000e0: 0003 03e8 0000 0000 d865 b0f5 0000 0000 .........e......
000000f0: d865 b0f5 0000 0000 0000 0000 0000 0003 .e..............
00000100: 0002 0000 0000 0000 0001 0000 00c8 0064 ...............d
00000110: 0000 0000 0000 0000 0000 0001 0000 0000 ................
00000120: 0000 0000 0000 0000 0000 0000 0000 5000 ..............P.
00000130: 0000 0000 0000 0000 0006 0000 0005 0000 ................
00000140: 0000 0000 0000 028a 02bb 0000 008c 028a ................
00000150: 02bb 0000 01df 0031 0102 0000 0000 0000 .......1........
00000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000170: 0000 0000 0000 5858 5858 0000 0000 0000 ......XXXX......
00000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000001a0: 0003 0000 0000 0000 0000 0000 0000 0000 ................
000001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
但是现在(在添加了一些字形之后)它给了我
OTS parsing error: cmap: Failed to serialize table
不确定从这里开始最好的方法是什么。