Skip to content

Commit 1c7bfe7

Browse files
committed
Can set font size per line part
1 parent ccd660d commit 1c7bfe7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/mudbrick/text_block/output.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ defmodule Mudbrick.TextBlock.Output do
133133
end
134134

135135
def with_font(output, op, part) do
136-
if part.font == nil or output.font == part.font do
136+
if part.font in [nil, output.font] and part.font_size == nil do
137137
add(output, op)
138138
else
139139
output
140140
|> add(%Tf{font: output.font, size: output.font_size})
141141
|> add(op)
142-
|> add(%Tf{font: part.font, size: output.font_size})
142+
|> add(%Tf{font: part.font || output.font, size: part.font_size || output.font_size})
143143
end
144144
end
145145

test/mudbrick/text_block_test.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ defmodule Mudbrick.TextBlockTest do
117117
"12.0 TL",
118118
"400 500 Td",
119119
"0 0 0 rg",
120+
"/F1 14 Tf",
120121
"<011D00D500D9011601B700D9011601B7> Tj",
122+
"/F1 10 Tf",
121123
"/F2 10 Tf",
122124
"<00B400FC00ED00BB01B7> Tj",
123125
"/F1 10 Tf",
@@ -133,7 +135,7 @@ defmodule Mudbrick.TextBlockTest do
133135
font_size: 10,
134136
position: {400, 500}
135137
)
136-
|> TextBlock.write("this is ")
138+
|> TextBlock.write("this is ", font_size: 14)
137139
|> TextBlock.write("bold ", font: bold)
138140
|> TextBlock.write("but this isn't ")
139141
|> TextBlock.write("this is franklin", font: franklin)

0 commit comments

Comments
 (0)