next: structify font

main
Matthew Butterick 6 years ago
parent 08d10ceb7b
commit 89f694351e

@ -1,20 +0,0 @@
#lang racket/base
#|
approximates
https://github.com/mbutterick/fontkit/blob/master/src/glyph/CFFGlyph.js
|#
#;(define-subclass Glyph (CFFGlyph)
(error 'cff-glyph-unimplemented)
#;(define/override (_getName this)
(->m any/c)
(if (send (· this _font) _getTable 'CFF2)
(super _getName)
(send (send (· this _font) _getTable 'CFF_) getGlyphName (· this id))))
(as-methods
#;_getName
#;bias
#;_getPath))

@ -53,39 +53,6 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/CFFSubset.js
|#
#|
;; no CFF font support for now
(define-subclass Subset (CFFSubset)
#R (· this font)
(field [cff (send (· this font) _getTable 'CFF_)])
(unless (· this cff) (error 'not-a-cff-font))
(field [charStrings #f]
[subrs #f])
(as-methods
subsetCharstrings
#;subsetSubrs
#;subsetFontdict
#;createCIDFontdict
#;addString
#;encode))
(define/contract (subsetCharstrings this)
(->m void?)
(set-field! charStrings this null)
(define gsubrs (make-hash))
(for ([gid (in-list (· this glyphs))])
(push-end-field! charStrings this (· this cff getCharString gid))
(define glyph (· this font getGlyph gid))
(define path (· glyph path)) ; this causes the glyph to be parsed
(for ([subr (in-list (· glyph _usedGsubrs))])
(hash-set! gsubrs subr #true)))
(set-field! this gsubrs (send this subsetSubrs (· this cff globalSubrIndex) gsubrs))
(void))
|#
#|
approximates

Loading…
Cancel
Save