shithub: fnt

Download patch

ref: c313af9d46984f3315d402eb0583f96db0b4d7a1
parent: a73cbb099ae671c0d68709a96876b0940370e37d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Jun 18 20:54:11 EDT 2024

add cmap subtables and sprinkle FIXMEs

--- a/otf.rkt
+++ b/otf.rkt
@@ -409,6 +409,99 @@
 (mkcmplx EncodingRecord
          (mkfields {uint16 platformID (<= 4)} {uint16 encodingID} {Offset32 subtableOffset}))
 
+(mkcmplx SubHeader
+         (mkfields {uint16 firstCode} {uint16 entryCode} {int16 idDelta} {uint16 idRangeOffset}))
+
+; same type for Sequential and Constant
+(mkcmplx MapGroup (mkfields {uint32 startCharCode} {uint32 endCharCode} {uint32 startGlyphID}))
+
+(mkcmplx SubtableCmap0 (mkfields {uint16 length} {uint16 language} {uint8 glyphIdArray [256]}))
+
+; FIXME
+#;(mkcmplx SubtableCmap2
+           (mkfields {uint16 length}
+                     {uint16 language}
+                     {uint16 subHeaderKeys [256]}
+                     {SubHeader subHeaders (count ?)}
+                     {uint16 glyphIdArray (count ?)}))
+
+; FIXME
+#;(mkcmplx SubtableCmap4
+           (mkfields {uint16 length}
+                     {uint16 language}
+                     {uint16 segCountX2}
+                     {uint16 searchRange}
+                     {uint16 entrySelector}
+                     {uint16 rangeShift}
+                     {uint16 endCode (count (/ segCountX2 2))}
+                     {uint16 reservedPad unused}
+                     {uint16 startCode (count (/ segCountX2 2))}
+                     {int16 idDelta (count (/ segCountX2 2))}
+                     {int16 idRangeOffset (count (/ segCountX2 2))}
+                     {uint16 glyphIdArray (count ?)}))
+
+(mkcmplx SubtableCmap6
+         (mkfields {uint16 length}
+                   {uint16 language}
+                   {uint16 firstCode}
+                   {uint16 entryCount}
+                   {uint16 glyphIdArray (count entryCount)}))
+
+(mkcmplx SubtableCmap8
+         (mkfields {uint16 length}
+                   {uint16 language}
+                   ; FIXME this crosses an uncomfortable threshold - allocate dynamically
+                   {uint8 is32 [8192]}
+                   {uint32 numGroups}
+                   {MapGroup groups (count numGroups)}))
+
+; FIXME
+#;(mkcmplx SubtableCmap10
+           (mkfields {uint16 reserved}
+                     {uint32 length}
+                     {uint32 language}
+                     {uint32 startCharCode}
+                     {uint32 numChars}
+                     {uint16 glyphIdArray (count ?)}))
+
+(mkcmplx SubtableCmap12or13
+         (mkfields {uint16 reserved}
+                   {uint32 length}
+                   {uint32 language}
+                   {uint32 numGroups}
+                   {MapGroup groups (count numGroups)}))
+
+(mkcmplx UnicodeRange (mkfields {uint24 startUnicodeValue} {uint8 additionalCount}))
+
+(mkcmplx DefaultUVS
+         (mkfields {uint32 numUnicodeValueRanges}
+                   {UnicodeRange ranges (count numUnicodeValueRanges)}))
+
+(mkcmplx UVSMapping (mkfields {uint24 unicodeValue} {uint16 glyphID}))
+
+(mkcmplx NonDefaultUVS
+         (mkfields {uint32 numUVSMappings} {UVSMapping uvsMappings (count numUVSMappings)}))
+
+(mkcmplx VariationSelector
+         (mkfields {uint24 varSelector} {Offset32 defaultUVSOffset} {Offset32 nonDefaultUVSOffset}))
+
+(mkcmplx SubtableCmap14
+         (mkfields {uint32 length}
+                   {uint32 numVarSelectorRecords}
+                   {VariationSelector varSelector (count numVarSelectorRecords)}))
+
+(mkcmplx SubtableCmap
+         (mkfields {uint16 format (== 0 #|2 4|# 6 8 #|10|# 12 13 14)}
+                   ; FIXME these fields should be put into a union automatically
+                   {SubtableCmap0 sub0 (== format 0)}
+                   ;{SubtableCmap2 sub2 (== format 2)}
+                   ;{SubtableCmap4 sub4 (== format 4)}
+                   {SubtableCmap6 sub6 (== format 6)}
+                   {SubtableCmap8 sub8 (== format 8)}
+                   ;{SubtableCmap10 sub10 (== format 10)}
+                   {SubtableCmap12or13 sub12or13 (== format 12 13)}
+                   {SubtableCmap14 sub14 (== format 14)}))
+
 (mkcmplx TableCmap
          (mkfields {uint16 version unused (== 0)}
                    {uint16 numTables}