From 1b4a93214c5ff9be0ddaab9d25ee89428e22982f Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 8 Aug 2017 15:17:15 -0700 Subject: [PATCH] add advanceWidth to glyphRun --- pitfall/fontkit/glyphrun.rkt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pitfall/fontkit/glyphrun.rkt b/pitfall/fontkit/glyphrun.rkt index 5fc90eb5..f943fb63 100644 --- a/pitfall/fontkit/glyphrun.rkt +++ b/pitfall/fontkit/glyphrun.rkt @@ -2,9 +2,18 @@ (require "bbox.rkt" (prefix-in Script- "script.rkt")) (provide (all-defined-out)) +#| +approximates +https://github.com/mbutterick/fontkit/blob/master/src/layout/GlyphRun.js +|# + ;; Represents a run of Glyph and GlyphPosition objects. ;; Returned by the font layout method. (define-subclass object% (GlyphRun glyphs ; An array of Glyph objects in the run positions) ; An array of GlyphPosition objects for each glyph in the run - ) \ No newline at end of file + + + (define/public (advanceWidth) + (for/sum ([pos (in-list positions)]) + (ยท pos xAdvance)))) \ No newline at end of file