Skip to content

Commit 3abfdef

Browse files
committed
set font name, fixes #6
1 parent 79a7c1b commit 3abfdef

File tree

6 files changed

+56
-4
lines changed

6 files changed

+56
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
id 'org.asciidoctor.gradle.asciidoctor' version '1.5.1'
1313
}
1414

15-
String currentVersion = '0.1.9'
15+
String currentVersion = '0.1.10'
1616

1717
version = currentVersion
1818

docs/images/fonts.png

4.61 KB
Loading

docs/index.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ image:borders.png[]
590590

591591
=== Fonts
592592

593-
You can customize the font size and color of the text in the cell. You also can make it `bold`, `italic`, `underline` or
593+
You can customize the font size, name and color of the text in the cell. You also can make it `bold`, `italic`, `underline` or
594594
`strikeout`. See <<Available predefined colors>>.
595595

596596
[source,groovy]
@@ -609,10 +609,11 @@ row {
609609
}
610610
cell {
611611
width auto
612-
value 'Underline'
612+
value 'Underline Courier New'
613613
style {
614614
font {
615615
underline
616+
name 'Courier New'
616617
}
617618
}
618619
}

spreadsheet-builder-api/src/main/java/org/modelcatalogue/builder/spreadsheet/api/Font.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public interface Font extends ProvidesHTMLColors {
66
void color(Color color);
77

88
void size(int size);
9+
void name(String name);
910

1011
Object getItalic();
1112
Object getBold();

spreadsheet-builder-poi/src/main/groovy/org/modelcatalogue/builder/spreadsheet/poi/PoiFont.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class PoiFont extends AbstractHTMLColorProvider implements Font {
3636
font.setFontHeightInPoints(size.shortValue())
3737
}
3838

39+
@Override
40+
void name(String name) {
41+
font.setFontName(name)
42+
}
43+
3944
@Override
4045
Object getItalic() {
4146
font.italic = true

spreadsheet-builder-poi/src/test/groovy/org/modelcatalogue/builder/spreadsheet/poi/PoiExcelBuilderSpec.groovy

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,50 @@ class PoiExcelBuilderSpec extends Specification {
4646
}
4747
}
4848

49+
sheet('Fonts') {
50+
row {
51+
cell {
52+
width auto
53+
value 'Bold Red 22'
54+
style {
55+
font {
56+
bold
57+
color red
58+
size 22
59+
}
60+
}
61+
}
62+
cell {
63+
width auto
64+
value 'Underline Courier New'
65+
style {
66+
font {
67+
underline
68+
name 'Courier New'
69+
}
70+
}
71+
}
72+
cell {
73+
width auto
74+
value 'Italic'
75+
style {
76+
font {
77+
italic
78+
}
79+
}
80+
}
81+
cell {
82+
width auto
83+
value 'Strikeout'
84+
style {
85+
font {
86+
strikeout
87+
}
88+
}
89+
}
90+
}
91+
}
92+
4993
sheet('Rich Text') {
5094
row {
5195
cell {
@@ -54,6 +98,7 @@ class PoiExcelBuilderSpec extends Specification {
5498
text 'Red', {
5599
color red
56100
size 22
101+
name "Times New Roman"
57102
}
58103
text ' '
59104
text 'Riding', {
@@ -123,7 +168,7 @@ class PoiExcelBuilderSpec extends Specification {
123168
}
124169
}
125170

126-
sheet('Cell Adressing') {
171+
sheet('Cell Addressing') {
127172
row(2) {
128173
style {
129174
background whiteSmoke

0 commit comments

Comments
 (0)