From 505ad3e3c844abd7e5d45b417cee568b9b203c94 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 22 Jan 2019 12:57:25 -0800 Subject: [PATCH] handle empty string better --- pitfall/pitfall/font-standard.rkt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pitfall/pitfall/font-standard.rkt b/pitfall/pitfall/font-standard.rkt index d8e70221..29757a3c 100644 --- a/pitfall/pitfall/font-standard.rkt +++ b/pitfall/pitfall/font-standard.rkt @@ -29,7 +29,7 @@ (define line-gap (- (third bbox) (first bbox) ascender descender)) (sfont name id ascender descender line-gap bbox #f #f sfont-embed sfont-encode sfont-measure-string - attributes glyph-widths kern-pairs)) + attributes glyph-widths kern-pairs)) (define (sfont-embed sf) (set-$ref-payload! (pdf-font-ref sf) @@ -52,9 +52,11 @@ (hash-ref (sfont-glyph-widths sf) glyph 0)) (define (advances-for-glyphs sf glyphs) - (for/list ([left (in-list glyphs)] - [right (in-list (append (cdr glyphs) (list #\nul)))]) - (+ (glyph-width sf left) (get-kern-pair sf left right)))) + (if (empty? glyphs) + empty + (for/list ([left (in-list glyphs)] + [right (in-list (append (cdr glyphs) (list #\nul)))]) + (+ (glyph-width sf left) (get-kern-pair sf left right))))) (define (get-kern-pair sf left right) (hash-ref (sfont-kern-pairs sf) (make-kern-table-key left right) 0))