You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
Racket
47 lines
1.5 KiB
Racket
#lang fontkit/racket
|
|
(require "ot-processor.rkt")
|
|
(provide (all-defined-out))
|
|
|
|
#|
|
|
approximates
|
|
https://github.com/mbutterick/fontkit/blob/master/src/opentype/GlyphInfo.js
|
|
|#
|
|
|
|
(define-subclass object% (GlyphInfo font-in id-in [codePoints-in empty] [features-in (mhasheq)])
|
|
(field [_font font-in]
|
|
[codePoints codePoints-in]
|
|
[_id id-in]
|
|
[features (mhasheq)])
|
|
|
|
(cond
|
|
[(list? features-in)
|
|
(for ([feature (in-list features-in)])
|
|
(hash-set! features feature #t))]
|
|
[(object? features-in)
|
|
(hash-set! features (· features-in features))])
|
|
|
|
(field [ligatureID #f]
|
|
[ligatureComponent #f]
|
|
[ligated #f]
|
|
[isLigated #f] ;todo: is this deliberate or accidental? see gsub-processor
|
|
[cursiveAttachment #f]
|
|
[markattachment #f]
|
|
[shaperInfo #f]
|
|
[substituted #f])
|
|
|
|
(define/public (id [id-in #f])
|
|
(cond
|
|
[(not id-in) _id]
|
|
[else (set! _id id-in)
|
|
(set! substituted #t)
|
|
|
|
(cond
|
|
[(and (· this _font GDEF) (· this _font GDEF glyphClassDef))
|
|
(define classID (send (+OTProcessor) getClassID id-in (· this _font GDEF glyphClassDef)))
|
|
(set-field! isMark this (= classID 3))
|
|
(set-field! isLigature this (= classID 2))]
|
|
[else
|
|
(set-field! isMark this (andmap is-mark? (· this codePoints)))
|
|
(set-field! isLigature this (> (length (· this codePoints)) 1))])])))
|
|
|