From eeb23310033d08863f523cb2087553f8f2d3c754 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 27 Nov 2018 13:10:18 -0800 Subject: [PATCH] cachier --- fontland/fontland/font.rkt | 18 ++++++++++++++++-- fontland/fontland/glyphrun.rkt | 13 ++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/fontland/fontland/font.rkt b/fontland/fontland/font.rkt index 30fd23c0..2355e112 100644 --- a/fontland/fontland/font.rkt +++ b/fontland/fontland/font.rkt @@ -233,14 +233,28 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js CFFGlyph TTFGlyph) glyph characters this)) +(define current-layout-caching (make-parameter #false)) +(define layout-cache (make-hash)) ;; Returns a GlyphRun object, which includes an array of Glyphs and GlyphPositions for the given string. (define/contract (layout this string [userFeatures #f] [script #f] [language #f]) ((string?) ((option/c (listof symbol?)) (option/c symbol?) (option/c symbol?)) . ->*m . GlyphRun?) (unless (· this _layoutEngine) (set-field! _layoutEngine this (+LayoutEngine this))) - #;(report*/file 'in-layout (· this _layoutEngine)) - (send (· this _layoutEngine) layout string userFeatures script language)) + (define (get-layout string) + (define key (list string (and userFeatures (sort userFeatures symbol