From 5a10976df7c36bb8625a96d960f804d2c6fc1c11 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 12 Mar 2019 15:31:45 -0700 Subject: [PATCH] font counter --- pitfall/pitfall/core.rkt | 1 + pitfall/pitfall/font.rkt | 3 ++- pitfall/pitfall/pdf.rkt | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pitfall/pitfall/core.rkt b/pitfall/pitfall/core.rkt index 8fada01d..495418f4 100644 --- a/pitfall/pitfall/core.rkt +++ b/pitfall/pitfall/core.rkt @@ -19,6 +19,7 @@ current-font-size current-font registered-fonts + font-count line-gap x y diff --git a/pitfall/pitfall/font.rkt b/pitfall/pitfall/font.rkt index 70640318..1441ebd5 100644 --- a/pitfall/pitfall/font.rkt +++ b/pitfall/pitfall/font.rkt @@ -56,7 +56,8 @@ (match (hash-ref (pdf-font-families doc) cache-key #f) ; check if the font is already in the PDF [(? values val) (set-pdf-current-font! doc val)] [_ ; if not, load the font - (define font-index (add1 (length (hash-keys (pdf-font-families doc))))) + (define font-index (add1 (pdf-font-count doc))) + (set-pdf-font-count! doc font-index) (define id (string->symbol (format "F~a" font-index))) (set-pdf-current-font! doc (open-pdf-font src id)) ;; check for existing font families with the same name already in the PDF diff --git a/pitfall/pitfall/pdf.rkt b/pitfall/pitfall/pdf.rkt index e80a44c5..1c1fd9ce 100644 --- a/pitfall/pitfall/pdf.rkt +++ b/pitfall/pitfall/pdf.rkt @@ -47,6 +47,7 @@ (define current-font-size 12) (define current-font #false) (define registered-fonts (make-hash)) + (define font-count 0) (define line-gap 0) (define x 0) (define y 0) @@ -66,6 +67,7 @@ current-font-size current-font registered-fonts + font-count line-gap x y