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

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

Loading…
Cancel
Save