main
Matthew Butterick 6 years ago
parent 85358635ed
commit 28adeb6e80

@ -32,8 +32,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
(syntax-case stx ()
[(_)
(with-syntax ([(TABLE-TAG ...) (hash-keys table-codecs)])
#'(begin
(define/public (TABLE-TAG) (_getTable 'TABLE-TAG)) ...))]))
#'(begin
(define/public (TABLE-TAG) (_getTable 'TABLE-TAG)) ...))]))
(test-module
@ -215,9 +215,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
;; Returns a Subset for this font.
(define/contract (createSubset this)
(->m (is-a?/c Subset))
(make-object (if (· this has-cff-table?)
CFFSubset
TTFSubset) this))
(make-object
;; no CFF support
#;(if (· this has-cff-table?)
CFFSubset
TTFSubset)
TTFSubset this))

@ -11,7 +11,7 @@
"directory.rkt"
"helper.rkt"
xenomorph)
(provide Subset CFFSubset TTFSubset)
(provide Subset TTFSubset)
#|
approximates
@ -20,9 +20,8 @@ https://github.com/devongovett/fontkit/blob/master/src/subset/Subset.js
(define-subclass object% (Subset font)
(field [glyphs empty] ; list of glyph ids in the subset
[mapping (mhash)] ; mapping of glyph ids to indexes in `glyphs`
)
[mapping (mhash)]) ; mapping of glyph ids to indexes in `glyphs`
(send this includeGlyph 0) ; always include the missing glyph in subset
(define/public (encode-to-port)
@ -33,17 +32,17 @@ https://github.com/devongovett/fontkit/blob/master/src/subset/Subset.js
(as-methods
includeGlyph))
(define/contract (includeGlyph this glyph)
(define/contract (includeGlyph this glyph-or-gid)
((or/c object? index?) . ->m . index?)
(let ([glyph (if (object? glyph) (· glyph id) glyph)])
(hash-ref! (· this mapping) glyph
(λ ()
;; put the new glyph at the end of `glyphs`,
;; and put its index in the mapping
(push-end-field! glyphs this glyph)
(sub1 (length (· this glyphs)))))))
(define glyph (if (object? glyph-or-gid)
(· glyph-or-gid id)
glyph-or-gid))
(hash-ref! (· this mapping) glyph
(λ ()
;; put the new glyph at the end of `glyphs`,
;; and put its index in the mapping
(push-end-field! glyphs this glyph)
(sub1 (length (· this glyphs))))))
#|
approximates
@ -51,6 +50,9 @@ 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_)])
@ -65,7 +67,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/subset/CFFSubset.js
#;createCIDFontdict
#;addString
#;encode))
|#
(define/contract (subsetCharstrings this)
(->m void?)

Loading…
Cancel
Save