goodbye GPOS & GSUB
parent
160b9398b9
commit
aa8fee22b1
@ -1,224 +0,0 @@
|
||||
fontkit = require '../pdfkit/node_modules/fontkit'
|
||||
|
||||
fira_path = "../pitfall/test/assets/fira.ttf"
|
||||
f = fontkit.openSync(fira_path)
|
||||
console.log "*************************** start decode"
|
||||
thing = f.GPOS.lookupList.get(1)
|
||||
console.log thing
|
||||
|
||||
###
|
||||
{ version: 65536,
|
||||
scriptList:
|
||||
[ { tag: 'DFLT', script: [Object] },
|
||||
{ tag: 'cyrl', script: [Object] },
|
||||
{ tag: 'grek', script: [Object] },
|
||||
{ tag: 'latn', script: [Object] } ],
|
||||
featureList:
|
||||
[ { tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'cpsp', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'kern', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mark', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] },
|
||||
{ tag: 'mkmk', feature: [Object] } ],
|
||||
lookupList:
|
||||
[ { lookupType: 1,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 2 },
|
||||
{ lookupType: 2,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 6,
|
||||
subTables: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
|
||||
markFilteringSet: 2 },
|
||||
{ lookupType: 2,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 7,
|
||||
subTables:
|
||||
[ [Object],
|
||||
[Object],
|
||||
[Object],
|
||||
[Object],
|
||||
[Object],
|
||||
[Object],
|
||||
[Object] ],
|
||||
markFilteringSet: 2 },
|
||||
{ lookupType: 2,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 6,
|
||||
subTables: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
|
||||
markFilteringSet: 2 },
|
||||
{ lookupType: 2,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 2,
|
||||
subTables: [ [Object], [Object] ],
|
||||
markFilteringSet: 4 },
|
||||
{ lookupType: 4,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 4 },
|
||||
{ lookupType: 4,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 4 },
|
||||
{ lookupType: 4,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 6 },
|
||||
{ lookupType: 6,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 6 },
|
||||
{ lookupType: 6,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 6 },
|
||||
{ lookupType: 6,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 6 },
|
||||
{ lookupType: 6,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 6 },
|
||||
{ lookupType: 6,
|
||||
flags:
|
||||
{ rightToLeft: false,
|
||||
ignoreBaseGlyphs: false,
|
||||
ignoreLigatures: false,
|
||||
ignoreMarks: false,
|
||||
useMarkFilteringSet: false,
|
||||
markAttachmentType: false },
|
||||
subTableCount: 1,
|
||||
subTables: [ [Object] ],
|
||||
markFilteringSet: 1 } ] }
|
||||
###
|
@ -1,15 +0,0 @@
|
||||
#lang racket/base
|
||||
(require "racket.rkt")
|
||||
|
||||
(require fontland fontland/gpos-processor "subset.rkt" rackunit xenomorph racket/serialize)
|
||||
|
||||
(define fira-path "../pitfall/test/assets/fira.ttf")
|
||||
(define f (openSync fira-path))
|
||||
(define gpos (· f GPOS))
|
||||
#;(get (· gpos lookupList) 11)
|
||||
|
||||
(define gp (+GPOSProcessor f gpos))
|
||||
|
||||
(· gpos scriptList)
|
||||
(send gp selectScript 'cyrl)
|
||||
|
@ -1,199 +0,0 @@
|
||||
#lang racket/base
|
||||
(require "racket.rkt")
|
||||
|
||||
(require xenomorph br/cond "opentype.rkt")
|
||||
(provide (all-defined-out))
|
||||
|
||||
#|
|
||||
approximates
|
||||
https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
|
||||
|#
|
||||
|
||||
(define ValueFormat (+Bitfield uint16be '(xPlacement yPlacement xAdvance yAdvance xPlaDevice yPlaDevice xAdvDevice yAdvDevice)))
|
||||
|
||||
(define types
|
||||
(mhash
|
||||
'xPlacement int16be
|
||||
'yPlacement int16be
|
||||
'xAdvance int16be
|
||||
'yAdvance int16be
|
||||
'xPlaDevice (+Pointer uint16be Device (mhash 'type 'global 'relativeTo 'rel))
|
||||
'yPlaDevice (+Pointer uint16be Device (mhash 'type 'global 'relativeTo 'rel))
|
||||
'xAdvDevice (+Pointer uint16be Device (mhash 'type 'global 'relativeTo 'rel))
|
||||
'yAdvDevice (+Pointer uint16be Device (mhash 'type 'global 'relativeTo 'rel))))
|
||||
|
||||
(define-subclass object% (ValueRecord [key 'valueFormat])
|
||||
(define/public (buildStruct parent)
|
||||
;; set `struct` to the first dict in the chain of ancestors
|
||||
;; with the target key
|
||||
(define struct (let loop ([x parent])
|
||||
(cond
|
||||
[(and x (dict? x) (dict-ref x key #f)) x]
|
||||
[(· x parent) => loop]
|
||||
[else #f])))
|
||||
(and struct
|
||||
(let ()
|
||||
(define format (dict-ref struct key))
|
||||
(define fields
|
||||
(append
|
||||
(dictify 'rel (λ _ (dict-ref struct '_startOffset)))
|
||||
(for/list ([(key val) (in-dict format)]
|
||||
#:when val)
|
||||
(cons key (dict-ref types key)))))
|
||||
(+Struct fields))))
|
||||
|
||||
(define/public (size val ctx)
|
||||
(send (buildStruct ctx) size val ctx))
|
||||
|
||||
(define/public (decode port parent)
|
||||
(define res (send (buildStruct parent) decode port parent))
|
||||
(dict-remove! res 'rel)
|
||||
res)
|
||||
|
||||
(define/public (encode . args)
|
||||
(error 'GPOS-encode-not-implemented)))
|
||||
|
||||
(define PairValueRecord (+Struct
|
||||
(dictify
|
||||
'secondGlyph uint16be
|
||||
'value1 (+ValueRecord 'valueFormat1)
|
||||
'value2 (+ValueRecord 'valueFormat2))))
|
||||
|
||||
(define PairSet (+Array PairValueRecord uint16be))
|
||||
|
||||
(define Class2Record (+Struct
|
||||
(dictify
|
||||
'value1 (+ValueRecord 'valueFormat1)
|
||||
'value2 (+ValueRecord 'valueFormat2))))
|
||||
|
||||
(define Anchor (+VersionedStruct uint16be
|
||||
(dictify
|
||||
;; Design units only
|
||||
1 (dictify 'xCoordinate int16be
|
||||
'yCoordinate int16be)
|
||||
|
||||
;; Design units plus contour point
|
||||
2 (dictify 'xCoordinate int16be
|
||||
'yCoordinate int16be
|
||||
'anchorPoint uint16be)
|
||||
;; Design units plus Device tables
|
||||
3 (dictify 'xCoordinate int16be
|
||||
'yCoordinate int16be
|
||||
'xDeviceTable (+Pointer uint16be Device)
|
||||
'yDeviceTable (+Pointer uint16be Device)))))
|
||||
|
||||
(define EntryExitRecord (+Struct
|
||||
(dictify 'entryAnchor (+Pointer uint16be Anchor (mhash 'type 'parent))
|
||||
'exitAnchor (+Pointer uint16be Anchor (mhash 'type 'parent)))))
|
||||
|
||||
(define MarkRecord (+Struct
|
||||
(dictify 'class uint16be
|
||||
'markAnchor uint16be)))
|
||||
|
||||
(define MarkArray (+Array MarkRecord uint16be))
|
||||
|
||||
(define BaseRecord (+Array (+Pointer uint16be Anchor) (λ (t) (ref* t 'parent 'classCount))))
|
||||
|
||||
(define BaseArray (+Array BaseRecord uint16be))
|
||||
|
||||
(define ComponentRecord (+Array (+Pointer uint16be Anchor) (λ (t) (ref* t 'parent 'parent 'classCount))))
|
||||
(define LigatureAttach (+Array ComponentRecord uint16be))
|
||||
(define LigatureArray (+Array (+Pointer uint16be LigatureAttach) uint16be))
|
||||
|
||||
(define-subclass VersionedStruct (GPOSLookup-VersionedStruct))
|
||||
(define GPOSLookup
|
||||
(+GPOSLookup-VersionedStruct
|
||||
'lookupType
|
||||
(dictify
|
||||
;; Single Adjustment
|
||||
1 (+VersionedStruct uint16be
|
||||
(dictify
|
||||
;; Single positioning value
|
||||
1 (dictify
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'valueFormat ValueFormat
|
||||
'value (+ValueRecord))
|
||||
2 (dictify
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'valueFormat ValueFormat
|
||||
'valueCount uint16be
|
||||
'values (+LazyArray (+ValueRecord) 'valueCount))))
|
||||
;; Pair Adjustment Positioning
|
||||
2 (+VersionedStruct uint16be
|
||||
(dictify
|
||||
;; Adjustments for glyph pairs
|
||||
1 (dictify
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'valueFormat1 ValueFormat
|
||||
'valueFormat2 ValueFormat
|
||||
'pairSetCount uint16be
|
||||
'pairSets (+LazyArray (+Pointer uint16be PairSet) 'pairSetCount))
|
||||
|
||||
;; Class pair adjustment
|
||||
2 (dictify
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'valueFormat1 ValueFormat
|
||||
'valueFormat2 ValueFormat
|
||||
'classDef1 (+Pointer uint16be ClassDef)
|
||||
'classDef2 (+Pointer uint16be ClassDef)
|
||||
'class1Count uint16be
|
||||
'class2Count uint16be
|
||||
'classRecords (+LazyArray (+LazyArray Class2Record 'class2Count) 'class1Count))))
|
||||
|
||||
;; Cursive Attachment Positioning
|
||||
3 (dictify
|
||||
'format uint16be
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'entryExitCount uint16be
|
||||
'entryExitRecords (+Array EntryExitRecord 'entryExitCount))
|
||||
|
||||
;; MarkToBase Attachment Positioning
|
||||
4 (dictify
|
||||
'format uint16be
|
||||
'markCoverage (+Pointer uint16be Coverage)
|
||||
'baseCoverage (+Pointer uint16be Coverage)
|
||||
'classCount uint16be
|
||||
'markArray (+Pointer uint16be MarkArray)
|
||||
'baseArray (+Pointer uint16be BaseArray))
|
||||
|
||||
;; MarkToLigature Attachment Positioning
|
||||
5 (dictify
|
||||
'format uint16be
|
||||
'markCoverage (+Pointer uint16be Coverage)
|
||||
'ligatureCoverage (+Pointer uint16be Coverage)
|
||||
'classCount uint16be
|
||||
'markArray (+Pointer uint16be MarkArray)
|
||||
'ligatureArray (+Pointer uint16be LigatureArray))
|
||||
|
||||
;; MarkToMark Attachment Positioning
|
||||
6 (dictify
|
||||
'format uint16be
|
||||
'mark1Coverage (+Pointer uint16be Coverage)
|
||||
'mark2Coverage (+Pointer uint16be Coverage)
|
||||
'classCount uint16be
|
||||
'mark1Array (+Pointer uint16be MarkArray)
|
||||
'mark2Array (+Pointer uint16be BaseArray))
|
||||
|
||||
7 Context ;; Contextual positioning
|
||||
8 ChainingContext ;; Chaining contextual positioning
|
||||
|
||||
;; Extension positioning
|
||||
9 (dictify
|
||||
'posFormat uint16be
|
||||
'lookupType uint16be ;; cannot also be 9
|
||||
'extension (+Pointer uint32be (λ () (error 'circular-reference-unfixed))))
|
||||
)))
|
||||
|
||||
;; Fix circular reference
|
||||
(ref*-set! GPOSLookup 'versions 9 'extension 'type GPOSLookup)
|
||||
|
||||
(define-subclass VersionedStruct (GPOS-MainVersionedStruct))
|
||||
(define GPOS (+GPOS-MainVersionedStruct uint32be
|
||||
(dictify
|
||||
'header (dictify 'scriptList (+Pointer uint16be ScriptList)
|
||||
'featureList (+Pointer uint16be FeatureList)
|
||||
'lookupList (+Pointer uint16be (LookupList GPOSLookup)))
|
||||
#x00010000 (dictify)
|
||||
#;#x00010001 #;(+Pointer uint32be FeatureVariations))))
|
||||
|
||||
(test-module)
|
@ -1,6 +0,0 @@
|
||||
fontkit = require '../pdfkit/node_modules/fontkit'
|
||||
|
||||
fira_path = "../pitfall/test/assets/fira.ttf"
|
||||
f = fontkit.openSync(fira_path)
|
||||
console.log f.GSUB.lookupList.get(30).subTables
|
||||
console.log f.GSUB.lookupList.get(30).subTables[0].ligatureSets.get(0)
|
@ -1,91 +0,0 @@
|
||||
#lang racket/base
|
||||
(require "racket.rkt")
|
||||
|
||||
(require xenomorph br/cond "opentype.rkt")
|
||||
(provide (all-defined-out))
|
||||
|
||||
#|
|
||||
approximates
|
||||
https://github.com/mbutterick/fontkit/blob/master/src/tables/GSUB.js
|
||||
|#
|
||||
|
||||
(define Sequence (+Array uint16be uint16be))
|
||||
(define AlternateSet Sequence)
|
||||
|
||||
(define Ligature (+Struct
|
||||
(dictify
|
||||
'glyph uint16be
|
||||
'compCount uint16be
|
||||
'components (+Array uint16be (λ (t) (sub1 (· t compCount)))))))
|
||||
|
||||
(define LigatureSet (+Array (+Pointer uint16be Ligature) uint16be))
|
||||
|
||||
(define-subclass VersionedStruct (GSUBLookup-VersionedStruct))
|
||||
(define GSUBLookup
|
||||
(+GSUBLookup-VersionedStruct
|
||||
'lookupType
|
||||
(dictify
|
||||
;; Single Substitution
|
||||
1 (+VersionedStruct uint16be
|
||||
(dictify
|
||||
1 (dictify
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'deltaGlyphID int16be)
|
||||
2 (dictify
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'glyphCount uint16be
|
||||
'substitute (+LazyArray uint16be 'glyphCount))))
|
||||
2 ;; Multiple Substitution
|
||||
(dictify
|
||||
'substFormat uint16be
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'count uint16be
|
||||
'sequences (+LazyArray (+Pointer uint16be Sequence) 'count))
|
||||
|
||||
3 ;; Alternate Substitution
|
||||
(dictify
|
||||
'substFormat uint16be
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'count uint16be
|
||||
'alternateSet (+LazyArray (+Pointer uint16be AlternateSet) 'count))
|
||||
|
||||
4 ;; Ligature Substitution
|
||||
(dictify
|
||||
'substFormat uint16be
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'count uint16be
|
||||
'ligatureSets (+LazyArray (+Pointer uint16be LigatureSet) 'count))
|
||||
|
||||
5 Context ;; Contextual Substitution
|
||||
6 ChainingContext ;; Chaining Contextual Substitution
|
||||
|
||||
7 ;; Extension Substitution
|
||||
(dictify
|
||||
'substFormat uint16be
|
||||
'lookupType uint16be ; cannot also be 7
|
||||
'extension (+Pointer uint32be (λ () (error 'circular-reference-unfixed))))
|
||||
|
||||
8 ;; Reverse Chaining Contextual Single Substitution
|
||||
(dictify
|
||||
'substFormat uint16be
|
||||
'coverage (+Pointer uint16be Coverage)
|
||||
'backTrackCoverage (+Array (+Pointer uint16be Coverage) 'backtrackGlyphCount)
|
||||
'lookaheadGlyphCount uint16be
|
||||
'lookaheadCoverage (+Array (+Pointer uint16be Coverage) 'lookaheadGlyphCount)
|
||||
'glyphCount uint16be
|
||||
'substitute (+Array uint16be 'glyphCount)))))
|
||||
|
||||
;; Fix circular reference
|
||||
(ref*-set! GSUBLookup 'versions 7 'extension 'type GSUBLookup)
|
||||
|
||||
(define-subclass VersionedStruct (GSUB-MainVersionedStruct))
|
||||
(define GSUB (+GSUB-MainVersionedStruct uint32be
|
||||
(dictify
|
||||
'header (dictify 'scriptList (+Pointer uint16be ScriptList)
|
||||
'featureList (+Pointer uint16be FeatureList)
|
||||
'lookupList (+Pointer uint16be (LookupList GSUBLookup))
|
||||
)
|
||||
#x00010000 (dictify)
|
||||
#;#x00010001 #;(+Pointer uint32be FeatureVariations))))
|
||||
|
||||
(test-module)
|
@ -1,49 +0,0 @@
|
||||
#lang racket/base
|
||||
(require "racket.rkt")
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
(define VARIATION_FEATURES '(rvrn))
|
||||
(define COMMON_FEATURES '(ccmp locl rlig mark mkmk))
|
||||
(define FRACTIONAL_FEATURES '(frac numr dnom))
|
||||
(define HORIZONTAL_FEATURES '(calt clig liga rclt curs kern))
|
||||
(define VERTICAL_FEATURES '(vert))
|
||||
(define DIRECTIONAL_FEATURES (mhasheq
|
||||
'ltr '(ltra ltrm)
|
||||
'rtl '(rtla rtlm)))
|
||||
|
||||
(define zeroMarkWidths 'AFTER_GPOS)
|
||||
|
||||
(define-subclass object% (DefaultShaper)
|
||||
|
||||
(define/public (plan plan_ glyphs features)
|
||||
#;(report*/file plan_ glyphs features)
|
||||
;; Plan the features we want to apply
|
||||
(planPreprocessing plan_)
|
||||
(planFeatures plan_)
|
||||
(planPostprocessing plan_ features)
|
||||
|
||||
;; Assign the global features to all the glyphs
|
||||
(send plan_ assignGlobalFeatures glyphs)
|
||||
|
||||
;; Assign local features to glyphs
|
||||
(assignFeatures plan_ glyphs))
|
||||
|
||||
(define/public (planPreprocessing plan)
|
||||
(send plan add (mhasheq
|
||||
'global (append VARIATION_FEATURES (dict-ref DIRECTIONAL_FEATURES (· plan direction)))
|
||||
'local FRACTIONAL_FEATURES)))
|
||||
|
||||
(define/public (planFeatures plan)
|
||||
;; Do nothing by default. Let subclasses override this.
|
||||
(void))
|
||||
|
||||
(define/public (planPostprocessing plan userFeatures)
|
||||
(when userFeatures
|
||||
(unless (and (list? userFeatures) (andmap symbol? userFeatures))
|
||||
(raise-argument-error 'DefaultShaper:planPostprocessing "list of features" userFeatures)))
|
||||
(send plan add (append COMMON_FEATURES HORIZONTAL_FEATURES (or userFeatures empty))))
|
||||
|
||||
(define/public (assignFeatures plan glyphs)
|
||||
;; todo: Enable contextual fractions
|
||||
(void)))
|
Loading…
Reference in New Issue