From: John Benediktsson Date: Tue, 3 Mar 2020 17:46:32 +0000 (-0800) Subject: pdf.canvas: add concept of line-height multiplier. X-Git-Tag: 0.99~3398 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=b23fc52850c27ae979efa1999917d57958e8df5f pdf.canvas: add concept of line-height multiplier. --- diff --git a/extra/pdf/canvas/canvas.factor b/extra/pdf/canvas/canvas.factor index 61afb3be56..f7356140d4 100644 --- a/extra/pdf/canvas/canvas.factor +++ b/extra/pdf/canvas/canvas.factor @@ -2,11 +2,13 @@ ! See http://factorcode.org/license.txt for BSD license USING: accessors assocs colors.constants combinators fonts fry -io io.styles kernel math math.order pdf.text pdf.wrap sequences -ui.text ; +io io.styles kernel math math.order namespaces pdf.text pdf.wrap +sequences ui.text ; IN: pdf.canvas +SYMBOL: +line-height+ + TUPLE: margin left right top bottom ; C: margin @@ -87,11 +89,18 @@ foreground background page-color inset line-height metrics ; : inc-y ( canvas n -- ) '[ _ + ] change-y drop ; +> +line-height+ get [ * >integer ] when* ; + +PRIVATE> + : line-height ( canvas -- n ) - [ line-height>> ] [ inset>> first 2 * ] bi + ; + [ (line-height) ] [ inset>> first 2 * ] bi + ; : line-break ( canvas -- ) - [ line-height>> ] keep [ + ] change-y 0 >>x + [ (line-height) ] keep [ + ] change-y 0 >>x dup metrics>> height>> >>line-height drop ; : ?line-break ( canvas -- )