pdf.canvas: add concept of line-height multiplier.

master
John Benediktsson 2020-03-03 09:46:32 -08:00
parent ab81a957c9
commit b23fc52850
1 changed files with 13 additions and 4 deletions

View 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 -- )