diff --git a/fontland/fontland/font.rkt b/fontland/fontland/font.rkt index 02408966..3a327a98 100644 --- a/fontland/fontland/font.rkt +++ b/fontland/fontland/font.rkt @@ -49,7 +49,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js (define ft-library (delay (FT_Init_FreeType))) -(define (+TTFFont _port [_decoded-tables (mhash)] +(define (+ttf-font _port [_decoded-tables (mhash)] [_src (path->string (object-name _port))] [_directory (delay (decode Directory _port #:parent (mhash '_startOffset 0)))] [_ft-face (delay (and _src (FT_New_Face (force ft-library) _src)))] @@ -58,20 +58,20 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js [_crc (begin0 (crc32c-input-port _port) (pos _port 0))] [_get-head-table #f]) (unless (input-port? _port) - (raise-argument-error '+TTFFont "input port" _port)) + (raise-argument-error '+ttf-font "input port" _port)) (unless (member (peek-bytes 4 0 _port) (list #"true" #"OTTO" (bytes 0 1 0 0))) (raise 'probe-fail)) (define f - (TTFFont _port _decoded-tables _src _directory _ft-face _hb-font _hb-buf _crc _get-head-table)) + (ttf-font _port _decoded-tables _src _directory _ft-face _hb-font _hb-buf _crc _get-head-table)) ;; needed for `loca` table decoding cross-reference - (set-TTFFont-_get-head-table! f (λ () (get-head-table f))) + (set-ttf-font-get-head-table-proc! f (λ () (get-head-table f))) f) (define (directory this) (force (· this _directory))) -(define (hb-font this) (or (force (TTFFont-_hb-font this)) (error 'hb-font-not-available))) -(define (hb-buf this) (force (TTFFont-_hb-buf this))) +(define (hb-font this) (or (force (ttf-font-hb-font this)) (error 'hb-font-not-available))) +(define (hb-buf this) (force (ttf-font-hb-buf this))) (require "table-stream.rkt") @@ -219,12 +219,12 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js ;; Returns a GlyphRun object, which includes an array of Glyphs and GlyphPositions for the given string. -(define (layout this string [userFeatures #f] [script #f] [language #f] #:debug [debug #f]) +(define (layout this string [user-features #f] [script #f] [language #f] #:debug [debug #f]) #;((string?) ((option/c (listof symbol?)) (option/c symbol?) (option/c symbol?)) . ->*m . GlyphRun?) (define (get-layout string) (define codepoints (map char->integer (string->list string))) - (define args (list codepoints (if userFeatures (sort userFeatures symbolm . boolean?) - (define directory (force (TTFFont-_directory this))) + (define directory (force (ttf-font-directory this))) (hash-has-key? (· directory tables) (match tag [(? bytes?) (string->symbol (bytes->string/latin-1 tag))] [_ tag]))) @@ -27,23 +27,23 @@ (define (get-table this table-tag) (unless (has-table? this table-tag) (raise-argument-error 'get-table "table that exists in font" table-tag)) - (hash-ref! (TTFFont-_decoded-tables this) table-tag (λ () (decode-table this table-tag)))) + (hash-ref! (ttf-font-decoded-tables this) table-tag (λ () (decode-table this table-tag)))) (define-table-getters) (define (get-table-stream this tag) - (define directory (force (TTFFont-_directory this))) + (define directory (force (ttf-font-directory this))) (define table (hash-ref (· directory tables) tag)) - (and table (pos (TTFFont-_port this) (· table offset)) (TTFFont-_port this))) + (and table (pos (ttf-font-port this) (· table offset)) (ttf-font-port this))) (define (decode-table this table-tag) (unless (hash-has-key? table-codecs table-tag) (raise-argument-error 'decode-table "decodable table" table-tag)) - (define directory (force (TTFFont-_directory this))) + (define directory (force (ttf-font-directory this))) (define table (hash-ref (· directory tables) table-tag)) ;; todo: possible to avoid copying the bytes here? - (pos (TTFFont-_port this) (· table offset)) - (define table-bytes (open-input-bytes (peek-bytes (· table length) 0 (TTFFont-_port this)))) + (pos (ttf-font-port this) (· table offset)) + (define table-bytes (open-input-bytes (peek-bytes (· table length) 0 (ttf-font-port this)))) (define table-decoder (hash-ref table-codecs table-tag)) (decode table-decoder table-bytes #:parent this)) diff --git a/fontland/fontland/table/loca.rkt b/fontland/fontland/table/loca.rkt index b7428a09..7ded01cd 100644 --- a/fontland/fontland/table/loca.rkt +++ b/fontland/fontland/table/loca.rkt @@ -45,7 +45,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/loca.js (define loca (+Rloca ;; todo: address ugliness to cross-ref head table from ttffont - (λ (o) (hash-ref (dump ((TTFFont-_get-head-table o))) 'indexToLocFormat)) + (λ (o) (hash-ref (dump ((ttf-font-get-head-table-proc o))) 'indexToLocFormat)) (dictify 0 (dictify 'offsets (+Array uint16be)) 1 (dictify 'offsets (+Array uint32be)))))