gpos achieved

main
Matthew Butterick 8 years ago
parent b2077fba21
commit 2b2e8adc6f

@ -6,4 +6,4 @@
(report 'start-decode)
(define gpos (send GPOS decode (send f _getTableStream 'GPOS)))
(send (dict-ref gpos 'lookupList) get 1)
(send (dict-ref gpos 'lookupList) get 2)

@ -15,10 +15,10 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
'yPlacement int16be
'xAdvance int16be
'yAdvance int16be
'xPlaDevice uint16be ;; pointer
'yPlaDevice uint16be ;; pointer
'xAdvDevice uint16be ;; pointer
'yAdvDevice uint16be)) ;; pointer
'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)
@ -38,7 +38,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
(dictify 'rel (λ _ (dict-ref struct '_startOffset)))
(for/list ([(key val) (in-dict format)]
#:when val)
(cons key (dict-ref types key)))))
(cons key (dict-ref types key)))))
(+Struct fields))))
(define/public (size val ctx)
@ -79,12 +79,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
;; Design units plus Device tables
3 (dictify 'xCoordinate int16be
'yCoordinate int16be
'xDeviceTable uint16be ; pointer
'yDeviceTable uint16be)))) ; pointer
'xDeviceTable (+Pointer uint16be Device)
'yDeviceTable (+Pointer uint16be Device)))))
(define EntryExitRecord (+Struct
(dictify 'entryAnchor uint16be ; pointer
'exitAnchor uint16be))) ; pointer
(dictify 'entryAnchor (+Pointer uint16be Anchor (mhash 'type 'parent))
'exitAnchor (+Pointer uint16be Anchor (mhash 'type 'parent)))))
(define MarkRecord (+Struct
(dictify 'class uint16be
@ -92,13 +92,13 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
(define MarkArray (+Array MarkRecord uint16be))
(define BaseRecord (+Array uint16be)) ; pointer
(define BaseRecord (+Array (+Pointer uint16be Anchor) (λ (t) (ref* t 'parent 'classCount))))
(define BaseArray (+Array BaseRecord uint16be))
(define ComponentRecord (+Array uint16be)) ; pointer
(define ComponentRecord (+Array (+Pointer uint16be Anchor) (λ (t) (ref* t 'parent 'parent 'classCount))))
(define LigatureAttach (+Array ComponentRecord uint16be))
(define LigatureArray (+Array uint16be uint16be)) ; pointer
(define LigatureArray (+Array (+Pointer uint16be LigatureAttach) uint16be))
(define-subclass VersionedStruct (GPOSLookup-VersionedStruct))
(define GPOSLookup
@ -114,7 +114,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
'valueFormat ValueFormat
'value (+ValueRecord))
2 (dictify
'coverage uint16be ; pointer
'coverage (+Pointer uint16be Coverage)
'valueFormat ValueFormat
'valueCount uint16be
'values (+LazyArray (+ValueRecord) 'valueCount))))
@ -123,19 +123,19 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
(dictify
;; Adjustments for glyph pairs
1 (dictify
'coverage uint16be ; pointer
'coverage (+Pointer uint16be Coverage)
'valueFormat1 ValueFormat
'valueFormat2 ValueFormat
'pairSetCount uint16be
'pairSets (+LazyArray uint16be 'pairSetCount)) ; pointer
'pairSets (+LazyArray (+Pointer uint16be PairSet) 'pairSetCount))
;; Class pair adjustment
2 (dictify
'coverage uint16be ; pointer
'coverage (+Pointer uint16be Coverage)
'valueFormat1 ValueFormat
'valueFormat2 ValueFormat
'classDef1 uint16be ; pointer
'classDef2 uint16be ; pointer
'classDef1 (+Pointer uint16be ClassDef)
'classDef2 (+Pointer uint16be ClassDef)
'class1Count uint16be
'class2Count uint16be
'classRecords (+LazyArray (+LazyArray Class2Record 'class2Count) 'class1Count))))
@ -143,36 +143,36 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
;; Cursive Attachment Positioning
3 (dictify
'format uint16be
'coverage uint16be ; pointer
'coverage (+Pointer uint16be Coverage)
'entryExitCount uint16be
'entryExitRecords (+Array EntryExitRecord 'entryExitCount))
;; MarkToBase Attachment Positioning
4 (dictify
'format uint16be
'markCoverage uint16be ; pointer
'baseCoverage uint16be ; pointer
'markCoverage (+Pointer uint16be Coverage)
'baseCoverage (+Pointer uint16be Coverage)
'classCount uint16be
'markArray uint16be ; pointer
'baseArray uint16be) ; pointer
'markArray (+Pointer uint16be MarkArray)
'baseArray (+Pointer uint16be BaseArray))
;; MarkToLigature Attachment Positioning
5 (dictify
'format uint16be
'markCoverage uint16be ; pointer
'ligatureCoverage uint16be ; pointer
'markCoverage (+Pointer uint16be Coverage)
'ligatureCoverage (+Pointer uint16be Coverage)
'classCount uint16be
'markArray uint16be ; pointer
'ligatureArray uint16be)
'markArray (+Pointer uint16be MarkArray)
'ligatureArray (+Pointer uint16be LigatureArray))
;; MarkToMark Attachment Positioning
6 (dictify
'format uint16be
'mark1Coverage uint16be ; pointer
'mark2Coverage uint16be ; pointer
'mark1Coverage (+Pointer uint16be Coverage)
'mark2Coverage (+Pointer uint16be Coverage)
'classCount uint16be
'mark1Array uint16be ; pointer
'mark2Array uint16be) ; pointer
'mark1Array (+Pointer uint16be MarkArray)
'mark2Array (+Pointer uint16be BaseArray))
7 Context ;; Contextual positioning
8 ChainingContext ;; Chaining contextual positioning
@ -181,22 +181,21 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/GPOS.js
9 (dictify
'posFormat uint16be
'lookupType uint16be ;; cannot also be 9
'extension uint32be) ; pointer
'extension (+Pointer uint32be (λ () (error 'circular-reference-unfixed))))
)))
;; Fix circular reference
;; GPOSLookup.versions[9].extension.type = GPOSLookup;
(ref*-set! GPOSLookup 'versions 9 'extension 'type GPOSLookup)
(define gpos-common-dict (dictify 'scriptList (+Pointer uint16be ScriptList)
'featureList (+Pointer uint16be FeatureList)
'lookupList (+Pointer uint16be (LookupList GPOSLookup))
))
'lookupList (+Pointer uint16be (LookupList GPOSLookup))))
(define-subclass VersionedStruct (GPOS-MainVersionedStruct))
(define GPOS (+GPOS-MainVersionedStruct uint32be
(dictify
#x00010000 gpos-common-dict
;; ignore variations
#;#x00010001 #;(append gpos-common-dict (dictify 'featureVariations (+Pointer uint32be FeatureVariations))))))
(dictify
#x00010000 gpos-common-dict
;; ignore variations
#;#x00010001 #;(append gpos-common-dict (dictify 'featureVariations (+Pointer uint32be FeatureVariations))))))
(test-module)

@ -52,8 +52,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/opentype.js
(define-subclass Struct (FeatureRec))
(define-subclass Pointer (FeatureRec-Pointer))
(define FeatureRecord (+FeatureRec (dictify
'tag (+String 4)
'feature (+FeatureRec-Pointer uint16be Feature (mhash 'type 'parent)))))
'tag (+String 4)
'feature (+FeatureRec-Pointer uint16be Feature (mhash 'type 'parent)))))
(define FeatureList (+Array FeatureRecord uint16be))
@ -92,6 +92,38 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/opentype.js
'rangeCount uint16be
'rangeRecords (+Array RangeRecord 'rangeCount)))))
;;#########################
;; Class Definition Table #
;;#########################
(define ClassRangeRecord (+Struct
(dictify
'start uint16be
'end uint16be
'class uint16be)))
(define ClassDef (+VersionedStruct uint16be
(dictify
1 ;; Class array
(dictify
'startGlyph uint16be
'glyphCount uint16be
'classValueArray (+Array uint16be 'glyphCount))
2 ;; Class ranges
(dictify
'classRangeCount uint16be
'classRangeRecord (+Array ClassRangeRecord 'classRangeCount)))))
;;###############
;; Device Table #
;;###############
(define Device (+Struct
(dictify
'startSize uint16be
'endSize uint16be
'deltaFormat uint16be)))
;;#############################################
;; Contextual Substitution/Positioning Tables #

@ -1,6 +1,6 @@
#lang restructure/racket
(require racket/dict "stream.rkt" racket/private/generic-methods racket/struct)
(provide (all-defined-out))
(provide (all-defined-out) ref* ref*-set!)
(require (prefix-in d: racket/dict))
#|

Loading…
Cancel
Save