Sigrid Solveig Haflínudóttirdefine COLR and CPALf711b442 years agoHistory
1238 lines · 44.9 KB · Text
RawDownload
; types allowed to be used as index(define-for-syntax (type-index? type) (member type '(uint16 uint32))) ; types allowed to be used as offset(define-for-syntax (type-offset? type) (member type '(Offset16 Offset24 Offset32))) ; types allowed to be used in comparisons(define-for-syntax (type-comparable? type)  (member type '(uint8 int8 uint16 int16 uint24 uint32 int32 Version16Dot16))) ; types allowed to be used in comparisons(define-for-syntax (type-number? type)  (member type          '(uint8 int8 uint16 int16 uint24 uint32 int32 Version16Dot16 Offset16 Offset24 Offset32))) (mktype String 8 char "%s")(mktype String-UTF16 8 char "%s")(mktype uint8 8 u8int (verb-unsigned 8))(mktype int8 8 s8int "%d")(mktype uint16 16 u16int (verb-unsigned 16))(mktype int16 16 s16int "%d")(mktype uint24 24 u32int (verb-unsigned 32))(mktype uint32 32 u32int (verb-unsigned 32))(mktype int32 32 s32int "%d")(mktype FWORD 16 s16int "%d")(mktype UFWORD 16 u16int (verb-unsigned 16))(mktype LONGDATETIME        64        s64int        (cons (if (for-posix?) "%s" "%τ") (λ (v) (~a "fmttime(" v ")")))        (λ (b index [offset #f]) (~a "(" ((autoparse 64 's64int) b index offset) ") - 2082844800LL")))(mktype Tag 32 u32int (cons "%c%c%c%c" (λ (v) (~a v ">>24, " v ">>16, " v ">>8, " v ">>0"))))(mktype Offset16 16 u16int (verb-unsigned 16))(mktype Offset24 24 u32int (verb-unsigned 32))(mktype Offset32 32 u32int (verb-unsigned 32))(mktype Version16Dot16 32 u32int (cons "%d.%d" (λ (v) (~a v ">>16, " v "&0xffff"))))(mktype Fixed        32        double        "%g"        (λ (b index [offset #f]) (~a "(" ((type-parse int32) b index offset) ")/65536.0f")))(mktype F2DOT14        16        double        "%g"        (λ (b index [offset #f])          (define x (~a ((type-parse int16) b index offset)))          (~a "(" x ">>14)+(" x "&((1<<14)-1))/16384.0"))) (mkcmplx SubHeader {uint16 firstCode} {uint16 entryCode} {int16 idDelta} {uint16 idRangeOffset}) ; same type for Sequential and Constant(mkcmplx MapGroup {uint32 startCharCode} {uint32 endCharCode} {uint32 startGlyphID}) (mkcmplx SubtableCmap0 {uint16 length} {uint16 language} {uint8 glyphIdArray [256]}) ; FIXME(mkcmplx SubtableCmap2         {uint16 length}         {uint16 language}         #;{uint16 subHeaderKeys [256]}         #;{SubHeader subHeaders [?]}         #;{uint16 glyphIdArray [?]}) (mkcmplx SubtableCmap4         {uint16 length}         {uint16 language}         {uint16 segCountX2 (> 0)}         {uint16 searchRange}         {uint16 entrySelector}         {uint16 rangeShift}         {uint16 endCode [/ segCountX2 2]}         {uint16 reservedPad unused}         {uint16 startCode [/ segCountX2 2]}         {int16 idDelta [/ segCountX2 2]}         {int16 idRangeOffset [/ segCountX2 2]}         {uint16 glyphIdArray [/ (- length (+ (* 8 2) (* segCountX2 4))) 2]}) (mkcmplx SubtableCmap6         {uint16 length}         {uint16 language}         {uint16 firstCode}         {uint16 entryCount}         {uint16 glyphIdArray [entryCount]}) (mkcmplx SubtableCmap8         {uint16 length}         {uint16 language}         {uint8 is32 [8192]}         {uint32 numGroups}         {MapGroup groups [numGroups]}) (mkcmplx SubtableCmap10         {uint16 reserved}         {uint32 length}         {uint32 language}         {uint32 startCharCode}         {uint32 numChars}         {uint16 glyphIdArray [/ (- length (+ (* 2 2) (* 4 4))) 2]}) (mkcmplx SubtableCmap12or13         {uint16 reserved}         {uint32 length}         {uint32 language}         {uint32 numGroups}         {MapGroup groups [numGroups]}) (mkcmplx UnicodeRange {uint24 startUnicodeValue} {uint8 additionalCount}) (mkcmplx DefaultUVS {uint32 numUnicodeValueRanges} {UnicodeRange ranges [numUnicodeValueRanges]}) (mkcmplx UVSMapping {uint24 unicodeValue} {uint16 glyphID}) (mkcmplx NonDefaultUVS {uint32 numUVSMappings} {UVSMapping uvsMappings [numUVSMappings]}) (mkcmplx VariationSelector         {uint24 varSelector}         {Offset32 defaultUVSOffset}         {Offset32 nonDefaultUVSOffset}         {DefaultUVS defaultUVS (at defaultUVSOffset)}         {NonDefaultUVS nonDefaultUVS (at nonDefaultUVSOffset)}) (mkcmplx SubtableCmap14         {uint32 length}         {uint32 numVarSelectorRecords}         {VariationSelector varSelector [numVarSelectorRecords]}) (mkcmplx SubtableCmap         {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 EncodingRecord         {uint16 platformID (<= 4)}         {uint16 encodingID}         {Offset32 subtableOffset}         {SubtableCmap subtable (at subtableOffset)}) (mkcmplx TableCmap         {uint16 version unused (== 0)}         {uint16 numTables}         {EncodingRecord encodingRecords [numTables]}         #:tag "cmap"         #:extra (list (cons 'read (list (~a "if(otfcmap(v) < 0)") (~a "	goto err;")))                       (cons 'field (list (~a "RuneMapper mappers[8];") (~a "int numMappers;"))))) (define headFlags  #hash((0 . HEAD_FL_BASELINE_Y_0)        (1 . HEAD_FL_LEFT_SIDEBEARING_X_0)        (2 . HEAD_FL_INSTR_DEP_POINT_SZ)        (3 . HEAD_FL_FORCE_PPEM_INT)        (4 . HEAD_FL_INSTR_ALT_ADVANCE_WIDTH)        (11 . HEAD_FL_LOSSLESS)        (12 . HEAD_FL_CONVERTED)        (13 . HEAD_FL_CLEARTYPE)        (14 . HEAD_FL_LAST_RESORT))) (mkcmplx TableHead         {uint16 majorVersion unused (== 1)}         {uint16 minorVersion unused (== 0)}         {Fixed fontRevision unused}         {uint32 checksumAdjustment unused}         {uint32 magicNumber unused (== #x5f0f3cf5)}         {uint16 flags hex (bits headFlags)}         {uint16 unitsPerEm (>= 16) (<= 16384)}         {LONGDATETIME created}         {LONGDATETIME modified}         {int16 xMin}         {int16 yMin}         {int16 xMax}         {int16 yMax}         {uint16 macStyle}         {uint16 lowestRecPPEM}         {int16 fontDirectionHint (>= -2) (<= 2) unused}         {int16 indexToLocFormat ->o (<= 1)}         {int16 glyphDataFormat unused (== 0)}         #:tag "head") (mkcmplx TableHhea         {uint16 majorVersion (== 1)}         {uint16 minorVersion (== 0)}         {FWORD ascender}         {FWORD descender}         {FWORD lineGap}         {UFWORD advanceWidthMax}         {FWORD minLeftSideBearing}         {FWORD minRightSideBearing}         {FWORD xMaxExtent}         {int16 caretSlopeRise}         {int16 caretSlopeRun}         {int16 caretOffset}         {int16 reserved [4] unused}         {int16 metricDataFormat (== 0)}         {uint16 numberOfHMetrics ->o}         #:tag "hhea") (mkcmplx EbdtComponent {uint16 glyphID} {int8 xOffset} {int8 yOffset}) (mkcmplx Glyf         {int16 numberOfContours ->o}         {int16 xMin}         {int16 yMin}         {int16 xMax}         {int16 yMax}         #:extra         (list (cons 'field                     (list (~a "int index;")                           (~a "int type;")                           (~a "union {") ;                           (~a "	ComponentGlyph *component;")                           (~a "	SimpleGlyph *simple;")                           (~a "	BitmapGlyph *bitmap;")                           (~a "};")))               (cons 'read                     (list (~a "if(v->numberOfContours < 0){")                           (~a "	if(read_ComponentGlyph(o, &v->component, 0) < 0)")                           (~a "		goto err;")                           (~a "	v->type = GLYPH_COMPONENT;")                           (~a "}else if(v->numberOfContours > 0){")                           (~a "	if(read_SimpleGlyph(o, &v->simple) < 0)")                           (~a "		goto err;")                           (~a "	v->type = GLYPH_SIMPLE;")                           (~a "}else if(o->td.eblc != nil && o->td.ebdt != nil)")                           (~a "	v->type = GLYPH_BITMAP;")                           (~a "else")                           (~a "	v->type = GLYPH_EMPTY;")))               (cons 'print                     (list (~a "if(v->type == GLYPH_BITMAP){")                           (~a "	f->print(f->aux, \"%*s%s:\\n\", indent, \"\", \"bitmap\");")                           (~a "	print_BitmapGlyph(f, indent+indentΔ, o, v->bitmap);")                           (~a "}else if(v->type == GLYPH_COMPONENT){")                           (~a "	f->print(f->aux, \"%*s%s:\\n\", indent, \"\", \"component\");")                           (~a "	print_ComponentGlyph(f, indent+indentΔ, o, v->component);")                           (~a "}else if(v->type == GLYPH_SIMPLE){")                           (~a "	f->print(f->aux, \"%*s%s:\\n\", indent, \"\", \"simple\");")                           (~a "	print_SimpleGlyph(f, indent+indentΔ, o, v->simple);")                           (~a "}"))))) (mkcmplx LongHorMetric {UFWORD advanceWidth} {FWORD lsb}) (mkcmplx TableMaxp         {Version16Dot16 version (== #x05000 #x10000) unused}         {uint16 numGlyphs ->o}         ; a bunch of fields ignored here         #:tag "maxp") (mkcmplx TableHmtx         {LongHorMetric hMetrics [o->numberOfHMetrics]}         {FWORD leftSideBearings [- o->numGlyphs o->numberOfHMetrics]}         #:tag "hmtx"         #:after (list TableHhea TableMaxp)) (mkcmplx TablePost         {Version16Dot16 version (== #x10000 #x20000 #x25000 #x30000) unused}         {Fixed italicAngle}         {FWORD underlinePosition}         {FWORD underlineThickness}         {uint32 isFixedPitch}         ; a bunch of fields ignored here         #:tag "post") (mkcmplx NameRecord         {uint16 platformID ->o}         {uint16 encodingID ->o}         {uint16 languageID}         {uint16 nameID}         {uint16 stringLength}         {Offset16 stringOffset}         {String string [stringLength] (at (+ o->storageOffset stringOffset))}) (mkcmplx LangTagRecord         {uint16 length}         {Offset16 langTagOffset}         {String-UTF16 langTag [length] (at (+ o->storageOffset langTagOffset))}) (mkcmplx TableName         {uint16 version (== 0 1)}         {uint16 count}         {Offset16 storageOffset ->o}         {NameRecord nameRecord [count]}         {uint16 langTagCount (>= version 1)}         {LangTagRecord langTagRecord [langTagCount] (>= version 1)}         #:tag "name") (mkcmplx BigGlyphMetrics         {uint8 height}         {uint8 width}         {int8 horiBearingX}         {int8 horiBearingY}         {uint8 horiAdvance}         {int8 vertBearingX}         {int8 vertBearingY}         {uint8 vertAdvance}) (mkcmplx SmallGlyphMetrics         {uint8 height}         {uint8 width}         {int8 bearingX}         {int8 bearingY}         {uint8 advance}) (mkcmplx SbitLineMetrics         {int8 ascender}         {int8 descender}         {uint8 widthMax}         {int8 caretSlopeNumerator}         {int8 caretSlopeDenumerator}         {int8 caretOffset}         {int8 minOriginSB}         {int8 minAdvanceSB}         {int8 maxBeforeBL}         {int8 minAfterBL}         {int8 pad [2] unused}) (mkcmplx IndexSubtable1 {Offset32 sbitOffsets [+ (- o->lastGlyphIndex o->firstGlyphIndex) 2]}) (mkcmplx IndexSubtable2 {uint32 imageSize} {BigGlyphMetrics bigMetrics}) (mkcmplx IndexSubtable3 {Offset16 sbitOffsets [+ (- o->lastGlyphIndex o->firstGlyphIndex) 2]}) (mkcmplx GlyphIdOffsetPair {uint16 glyphID} {Offset16 sbitOffset}) (mkcmplx IndexSubtable4 {uint32 numGlyphs} {GlyphIdOffsetPair glyphArray [+ numGlyphs 1]}) (mkcmplx IndexSubtable5         {uint32 imageSize}         {BigGlyphMetrics bigMetrics}         {uint32 numGlyphs}         {uint16 glyphIdArray [numGlyphs]}) (mkcmplx IndexSubtable         {uint16 indexFormat (>= 1) (<= 5)}         {uint16 imageFormat}         {Offset32 imageDataOffset}         {IndexSubtable1 sub1 (== indexFormat 1)}         {IndexSubtable2 sub2 (== indexFormat 2)}         {IndexSubtable3 sub3 (== indexFormat 3)}         {IndexSubtable4 sub4 (== indexFormat 4)}         {IndexSubtable5 sub5 (== indexFormat 5)}) (mkcmplx IndexSubtableRecord         {uint16 firstGlyphIndex ->o}         {uint16 lastGlyphIndex ->o}         {Offset32 indexSubtableOffset}         {IndexSubtable indexSubtable (at indexSubtableOffset)}) (define bitmapSizeFlags  #hash((0 . BITMAPSIZE_FL_HORIZONTAL_METRICS) (1 . BITMAPSIZE_FL_VERTICAL_METRICS))) (mkcmplx BitmapSize {Offset32 indexSubtableListOffset} {uint32 indexSubtableListSize} {uint32 numberOfIndexSubtables} {uint32 colorRef unused} {SbitLineMetrics hori} {SbitLineMetrics vert} {uint16 startGlyphIndex} {uint16 endGlyphIndex} {uint8 ppemX} {uint8 ppemY} {uint8 bitDepth (== 1 2 4 8)} {int8 flags hex (bits bitmapSizeFlags)} {IndexSubtableRecord indexSubtableList [numberOfIndexSubtables] (at indexSubtableListOffset)}) (mkcmplx TableEBDT {uint16 majorVersion (== 2)} {uint16 minorVersion (== 0) unused} #:tag "EBDT") (mkcmplx TableEBLC         {uint16 majorVersion (== 2) unused}         {uint16 minorVersion (== 0) unused}         {uint32 numSizes}         {BitmapSize bitmapSizes [numSizes]}         #:tag "EBLC") (mkcmplx AttachList         {Offset16 coverageOffset}         {uint16 glyphCount}         {Offset16 attachPointOffsets [glyphCount]}) (mkcmplx AttachPoint {uint16 pointCount} {uint16 pointIndices [pointCount]}) (mkcmplx LigCaretList         {Offset16 coverageOffset}         {uint16 ligGlyphCount}         {Offset16 ligGlyphOffsets [ligGlyphCount]}) (mkcmplx LigGlyph {uint16 caretCount} {Offset16 caretValueOffsets [caretCount]}) (mkcmplx CaretValue         {uint16 format (>= 1) (<= 3)}         {int16 coordinate (== format 1 3)}         {uint16 caretValuePointIndex (== format 2)}         {Offset16 deviceOffset (== format 3)}) (mkcmplx ValueRecord         {int16 xPlacement}         {int16 yPlacement}         {int16 xAdvance}         {int16 yAdvance}         {Offset16 xPlaDeviceOffset}         {Offset16 yPlaDeviceOffset}         {Offset16 xAdvDeviceOffset}         {Offset16 yAdvDeviceOffset}) (mkcmplx SinglePos         {uint16 format (== 1 2)}         {Offset16 coverageOffset}         {uint16 valueFormat}         {ValueRecord valueRecord (== format 1)}         {uint16 valueCount (== format 2)}         {ValueRecord valueRecords [valueCount] (== format 2)}) (mkcmplx TableGDEF         {uint16 majorVersion (== 1) unused}         {uint16 minorVersion (== 0 2 3)}         {Offset16 glyphClassDefOffset}         {Offset16 attachListOffset}         {Offset16 ligCaretListOffset}         {Offset16 markAttachClassDefOffset}         {Offset16 markGlyphSetsDefOffset (>= minorVersion 2)}         {Offset32 itemVarStoreOffset (>= minorVersion 3)}         #:tag "GDEF") (mkcmplx LangSys         {Offset16 lookupOrderOffset unused}         {uint16 requiredFeatureIndex}         {uint16 featureIndexCount}         {uint16 featureIndices [featureIndexCount]}) (mkcmplx LangSysRecord {Tag langSysTag} {Offset16 langSysOffset} {LangSys langSys (at langSysOffset)}) (mkcmplx Script         {Offset16 defaultLangSysOffset}         {uint16 langSysCount}         {LangSysRecord langSysRecords [langSysCount]}         {LangSys defaultLangSys (at defaultLangSysOffset)}) (mkcmplx ScriptRecord {Tag scriptTag} {Offset16 scriptOffset} {Script script (at scriptOffset)}) (mkcmplx ScriptList {uint16 scriptCount} {ScriptRecord scriptRecords [scriptCount]}) (mkcmplx Feature         {Offset16 featureParamsOffset}         {uint16 lookupIndexCount}         {uint16 lookupListIndices [lookupIndexCount]}) (mkcmplx FeatureRecord {Tag featureTag} {Offset16 featureOffset} {Feature feature (at featureOffset)}) (mkcmplx FeatureList {uint16 featureCount} {FeatureRecord featureRecords [featureCount]}) (mkcmplx SequenceLookup {uint16 sequenceIndex} {uint16 lookupListIndex}) (mkcmplx ChainedSequenceRule         {uint16 backtrackGlyphCount}         {uint16 backtrackSequence [backtrackGlyphCount]}         {uint16 inputGlyphCount}         {uint16 inputSequence [- inputGlyphCount 1]}         {uint16 lookaheadGlyphCount}         {uint16 lookaheadSequence [lookaheadGlyphCount]}         {uint16 seqLookupCount}         {SequenceLookup seqLookupRecords [seqLookupCount]}) (mkcmplx ChainedSequenceRuleSet         {uint16 chainedSeqRuleCount}         {Offset16 chainedSeqRuleOffsets [chainedSeqRuleCount]}         {ChainedSequenceRule chainedSeqRule [chainedSeqRuleCount] (at chainedSeqRuleOffsets)}) (mkcmplx ChainedSequenceContextFormat1 {Offset16 coverageOffset} {uint16 chainedSeqRuleSetCount} {Offset16 chainedSeqRuleSetOffsets [chainedSeqRuleSetCount]} {ChainedSequenceRuleSet chainedSeqRuleSet [chainedSeqRuleSetCount] (at chainedSeqRuleSetOffsets)}) (mkcmplx ChainedClassSequenceRuleSet         {uint16 chainedClassSeqRuleCount}         {Offset16 chainedClassSeqRuleOffsets [chainedClassSeqRuleCount]}         {ChainedSequenceRule          chainedClassSeqRules          [chainedClassSeqRuleCount]          (at chainedClassSeqRuleOffsets)}) (mkcmplx ChainedSequenceContextFormat2         {Offset16 coverageOffset}         {Offset16 backtrackClassDefOffset}         {Offset16 inputClassDefOffset}         {Offset16 lookaheadClassDefOffset}         {uint16 chainedClassSeqRuleSetCount}         {Offset16 chainedClassSeqRuleSetOffsets [chainedClassSeqRuleSetCount]}         {ChainedClassSequenceRuleSet          chainedClassSequenceRuleSets          [chainedClassSeqRuleSetCount]          (at chainedClassSeqRuleSetOffsets)})

Lines 1–500 of 1238.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t