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