From b23fc52850c27ae979efa1999917d57958e8df5f Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 3 Mar 2020 09:46:32 -0800 Subject: [PATCH] pdf.canvas: add concept of line-height multiplier. --- extra/pdf/canvas/canvas.factor | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 -- )