From ee85254a771410e92c6956cd246b3cd95f72d1ff Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 20 Jun 2016 23:50:16 -0700 Subject: [PATCH] notes --- quad/quad/atomize.rkt | 1 + quad/quad/kafka.rkt | 4 ++-- quad/quad/measure.rkt | 13 ++++++++----- quad/quad/quads.rkt | 2 ++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/quad/quad/atomize.rkt b/quad/quad/atomize.rkt index 7e595420..b9d533b0 100644 --- a/quad/quad/atomize.rkt +++ b/quad/quad/atomize.rkt @@ -12,6 +12,7 @@ [(symbol? x) ($hard empty-attrs x #f)] [(string? x) ;; consolidate consecutive whitespaces into single word space + ;; todo: hyphenate here? then they are in the quad stream (for/list ([c (in-string x)]) (cons ($hard empty-attrs #f #f) ;; todo: is it feasible to box or otherwise object-ize a char diff --git a/quad/quad/kafka.rkt b/quad/quad/kafka.rkt index 6600d97f..38c0f1e7 100644 --- a/quad/quad/kafka.rkt +++ b/quad/quad/kafka.rkt @@ -1,14 +1,14 @@ #lang quad/text #:fit 300 150 Produces a list of three-element lists, where each three-element list represents a set of consecutive code points for which the Unicode standard specifies character properties. Each three-element list contains two integers and a boolean; the first integer is a starting code-point value (inclusive), the second integer is an ending code-point value (inclusive), and the boolean is #t when all characters in the code-point range have identical results for all of the character predicates above. The three-element lists are ordered in the overall result list such that later lists represent larger code-point values, and all three-element lists are separated from every other by at least one code-point value that is not specified by Unicode. -One morning, when Gregor Samsa woke from troubled dreams, he found +@quad[(make-attrs #:size 7)]{One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he -looked. +looked.} "What's happened to me?" he thought. It wasn't a dream. His room, a proper human room although a little too small, lay peacefully diff --git a/quad/quad/measure.rkt b/quad/quad/measure.rkt index 37fe9bd0..fc951912 100644 --- a/quad/quad/measure.rkt +++ b/quad/quad/measure.rkt @@ -4,10 +4,10 @@ (define (measure! q) (quad-dim-set! q - (cond - [(or ($black? q) ($soft? q)) - (* (measure-char (quad-font q) (quad-val q)) (quad-font-size q))] - [else 0]))) + (cond + [(or ($black? q) ($soft? q)) + (* (measure-char (quad-font q) (quad-val q)) (quad-font-size q))] + [else 0]))) (module+ test (require rackunit) @@ -23,7 +23,10 @@ [ft-face-cache (make-hash)]) (λ (font-pathstring char) (define (do-measure) - (define ft-face (hash-ref! ft-face-cache font-pathstring (λ () (FT_New_Face ft-library font-pathstring 0)))) + (define ft-face (hash-ref! ft-face-cache font-pathstring + (λ () (unless (file-exists? font-pathstring) + (error 'measure-char (format "font path ~v does not exist" font-pathstring))) + (FT_New_Face ft-library font-pathstring 0)))) (define width (let ([glyph-idx (hash-ref! glyph-idx-cache (cons char font-pathstring) (λ () (FT_Get_Char_Index ft-face (char->integer char))))]) diff --git a/quad/quad/quads.rkt b/quad/quad/quads.rkt index ea3b8051..b3050016 100644 --- a/quad/quad/quads.rkt +++ b/quad/quad/quads.rkt @@ -35,6 +35,8 @@ measure (line width) (define (merge-strings xs) ;; merge consecutive strings + ;; todo: only trim remove space between string and a hard break. + ;; space between a string and a subquad is ok (let loop ([xs xs]) (cond [(empty? xs) empty]