Skip to content

Commit

Permalink
No fallback for line height and font family 0
Browse files Browse the repository at this point in the history
This fixes #289
  • Loading branch information
pgundlach committed Dec 18, 2020
1 parent 4e38e09 commit 71a38b0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
36 changes: 36 additions & 0 deletions qa/paragraph/lineheight/layout.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<Layout xmlns="urn:speedata.de:2009/publisher/en" xmlns:sd="urn:speedata:2009/publisher/functions/en">
<DefineFontfamily name="FF-Tiny" fontsize="5" leading="5">
<Regular fontface="sans" />
</DefineFontfamily>

<SetGrid nx="2" height="12pt" />
<Pageformat width="5cm" height="4cm" />

<Record element="data">
<PlaceObject>
<Textblock width="1">
<Paragraph language="Other" textformat="left" bidi="yes">
<Value>A</Value>
<Br />
<Fontface fontfamily='FF-Tiny'>
<Br />
</Fontface>
<Value>B</Value>
</Paragraph>
</Textblock>
</PlaceObject>
<PlaceObject>
<Textblock width="1">
<Paragraph language="Other" textformat="left" bidi="yes" direction="rtl">
<Value>C</Value>
<Br />
<Fontface fontfamily='FF-Tiny'>
<Br />
</Fontface>
<Value>D</Value>
</Paragraph>
</Textblock>
</PlaceObject>
</Record>
</Layout>
1 change: 1 addition & 0 deletions qa/paragraph/lineheight/publisher.cfg
@@ -0,0 +1 @@
dummy=true
Binary file added qa/paragraph/lineheight/reference.pdf
Binary file not shown.
17 changes: 8 additions & 9 deletions src/lua/publisher.lua
Expand Up @@ -3249,9 +3249,8 @@ function addstrut(nodelist,where,origin)

local fi = fonts.lookup_fontfamily_number_instance[fontfamily]
strutheight = math.max(fi.baselineskip, strutheight)
local strut
-- for debugging purposes set width to 20000:
strut = add_rule(nodelist,"head",{height = 0.75 * strutheight, depth = 0.25 * strutheight, width = 0 })
local strut = add_rule(nodelist,"head",{height = 0.75 * strutheight, depth = 0.25 * strutheight, width = 0 })
if origin then
setprop(strut,"origin",origin)
end
Expand Down Expand Up @@ -3432,9 +3431,10 @@ function hbglyphlist(arguments)
node.set_attribute(dummypenalty,att_newline,1)
list,cur = node.insert_after(list,cur,dummypenalty)

local strut
strut = add_rule(nil,"head",{height = 8 * factor, depth = 3 * factor, width = 0 })
local ht = fonts.lookup_fontfamily_number_instance[fontfamily].size
local strut = add_rule(nil,"head",{height = ht * 0.75, depth = 0.25 * ht, width = 0 })
node.set_attribute(strut,att_newline,1)
setprop(strut,"origin","strut newline hb")
list,cur = node.insert_after(list,cur,strut)

local p1,g,p2
Expand Down Expand Up @@ -3612,8 +3612,9 @@ local function ffglyphlist(arguments)
node.set_attribute(dummypenalty,att_newline,1)
head,last = node.insert_after(head,last,dummypenalty)

local strut
strut = add_rule(nil,"head",{height = 8 * factor, depth = 3 * factor, width = 0 })
local ht = fonts.lookup_fontfamily_number_instance[fontfamily].size
local strut = add_rule(nil,"head",{height = ht * 0.75, depth = ht * 0.25, width = 0 })
setprop(strut,"origin","strut newline ff")
node.set_attribute(strut,att_newline,1)
head,last = node.insert_after(head,last,strut)

Expand Down Expand Up @@ -4365,9 +4366,7 @@ function do_linebreak( nodelist,hsize,parameters )
end
else
fam = node.has_attribute(head_list,att_fontfamily)
if fam then
-- Is this necessary anymore? FIXME
if fam == 0 then fam = 1 end
if fam and fam > 0 then
maxlineheight = math.max(fonts.lookup_fontfamily_number_instance[fam].baselineskip,maxlineheight)
end
end
Expand Down

0 comments on commit 71a38b0

Please sign in to comment.