]> gitweb.factorcode.org Git - factor.git/commitdiff
pdf.canvas: add concept of line-height multiplier.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 3 Mar 2020 17:46:32 +0000 (09:46 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 3 Mar 2020 17:46:32 +0000 (09:46 -0800)
extra/pdf/canvas/canvas.factor

index 61afb3be562a5f90b0049a749cc97b8fd3c586e2..f7356140d451c8b10f77260d8747d31a53d4de71 100644 (file)
@@ -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> margin
@@ -87,11 +89,18 @@ foreground background page-color inset line-height metrics ;
 : inc-y ( canvas n -- )
     '[ _ + ] change-y drop ;
 
+<PRIVATE
+
+: (line-height) ( canvas -- n )
+    line-height>> +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 -- )