Skip to content

Commit 3bcace9

Browse files
committed
Fix setting fonts
1 parent fe2f425 commit 3bcace9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/docx/elements/style.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def self.attribute(name, *selectors, required: false, converter: Converters::Def
4242
if encoded_value.nil?
4343
existing_attribute.remove
4444
else
45-
existing_attribute.value = encoded_value
45+
existing_attribute.value = encoded_value.to_s
4646
end
4747

4848
next encoded_value

spec/docx/elements/style_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@
9797
it "should change underlying XML when attributes are changed" do
9898
style.id = "blue"
9999
style.name = "Blue"
100+
style.font_size = 20
100101

101102
expect(style.to_xml).to eq(node.to_xml)
102103
expect(style.to_xml).to include('<w:style w:type="paragraph" w:styleId="blue">')
103104
expect(style.to_xml).to include('<w:name w:val="Blue"/>')
104105
expect(style.to_xml).to include('<w:next w:val="Blue"/>')
106+
expect(style.to_xml).to include('<w:sz w:val="40"/>')
107+
expect(style.to_xml).to include('<w:szCs w:val="40"/>')
105108
end
106109
end
107110

0 commit comments

Comments
 (0)