|
|
|
@ -1,24 +1,32 @@
|
|
|
|
|
#lang pitfall/racket
|
|
|
|
|
(require racket/runtime-path (for-syntax racket/base racket/path racket/syntax))
|
|
|
|
|
(require racket/runtime-path (for-syntax racket/base racket/path racket/syntax sugar/debug))
|
|
|
|
|
(provide isStandardFont standard-fonts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (isStandardFont name) (hash-ref standard-fonts name #f))
|
|
|
|
|
|
|
|
|
|
(define-syntax (define-afm-table stx)
|
|
|
|
|
(syntax-case stx ()
|
|
|
|
|
[(_ hashid dir)
|
|
|
|
|
(let* ([path-strings (for/list ([p (in-directory (syntax->datum #'dir) #t)]
|
|
|
|
|
#:when (and (file-exists? p) (path-has-extension? p #"afm") p))
|
|
|
|
|
(path->string p))]
|
|
|
|
|
[id-strings (for/list ([pstr (in-list path-strings)])
|
|
|
|
|
(path->string (cadr (explode-path (path-replace-extension pstr #"")))))])
|
|
|
|
|
(with-syntax ([(PATH-STR ...) path-strings]
|
|
|
|
|
[(ID-STR ...) id-strings]
|
|
|
|
|
[(ID ...) (map (λ (id-str) (format-id #'hashid "~a" id-str)) id-strings)])
|
|
|
|
|
#'(begin (define-runtime-path ID PATH-STR) ...
|
|
|
|
|
(define hashid (make-hash (list (cons ID-STR (procedure-rename (λ () (file->string ID)) 'ID)) ...))))))]))
|
|
|
|
|
[(_ HASH-ID FONT-ID ...)
|
|
|
|
|
(with-syntax ([(PATH-STR ...) (map (λ (stx) (format "data/~a.afm" (syntax->datum stx))) (syntax->list #'(FONT-ID ...)))])
|
|
|
|
|
#'(begin (define-runtime-path FONT-ID PATH-STR) ...
|
|
|
|
|
(define HASH-ID (make-hash (list (cons (symbol->string 'FONT-ID) (procedure-rename (λ () (file->string FONT-ID)) 'FONT-ID)) ...)))))]))
|
|
|
|
|
|
|
|
|
|
(define-afm-table standard-fonts "data")
|
|
|
|
|
(define-afm-table standard-fonts
|
|
|
|
|
Courier-Bold
|
|
|
|
|
Courier-BoldOblique
|
|
|
|
|
Courier-Oblique
|
|
|
|
|
Courier
|
|
|
|
|
Helvetica-Bold
|
|
|
|
|
Helvetica-BoldOblique
|
|
|
|
|
Helvetica-Oblique
|
|
|
|
|
Helvetica
|
|
|
|
|
Symbol
|
|
|
|
|
Times-Bold
|
|
|
|
|
Times-BoldItalic
|
|
|
|
|
Times-Italic
|
|
|
|
|
Times-Roman
|
|
|
|
|
ZapfDingbats)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
|