Skip to content

Commit a0db9b1

Browse files
committed
feat(graphical engine): boldness java side
1 parent e852888 commit a0db9b1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Serializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Serializer {
4848
keys.put("strokeColor", "sc");
4949
keys.put("fontFamily", "ff");
5050
keys.put("fontSize", "s");
51+
keys.put("fontWeight", "fw");
5152
keys.put("text", "T");
5253
keys.put("children", "ch");
5354
keys.put("scaleX", "sx");

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Text.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@
77
*/
88
public class Text extends TextureBasedEntity<Text> {
99

10+
/**
11+
* The list of supported font weight.
12+
*
13+
*/
14+
public static enum FontWeight {
15+
NORMAL, BOLD, BOLDER, LIGHTER;
16+
17+
public String toString() {
18+
return super.toString().toLowerCase();
19+
}
20+
}
21+
1022
private String text = "";
1123
private int strokeColor = 0;
1224
private double strokeThickness = 0;
1325
private int fillColor = 0;
1426
private int fontSize = 26;
1527
private String fontFamily = "Lato";
28+
private FontWeight fontWeight = FontWeight.NORMAL;
1629

1730
Text() {
1831
super();
@@ -132,6 +145,29 @@ public Text setStrokeThickness(double strokeThickness, Curve curve) {
132145
set("strokeThickness", strokeThickness, curve);
133146
return this;
134147
}
148+
/**
149+
* Sets the weight of the font of this <code>Text</code>.
150+
*
151+
* @param style
152+
* the FontWeight of the <code>Text</code>.
153+
* @return this <code>Text</code>.
154+
*/
155+
public Text setFontWeight(FontWeight weight) {
156+
this.fontWeight = weight;
157+
set("fontWeight", weight.toString());
158+
return this;
159+
}
160+
161+
/**
162+
* Returns the weight of the font of this <code>Text</code>.
163+
* <p>
164+
* Default is NORMAL.
165+
*
166+
* @return the weight of the font of this <code>Text</code>.
167+
*/
168+
public FontWeight getFontWeight() {
169+
return this.fontWeight;
170+
}
135171

136172
/**
137173
* Returns the color of the fill of this <code>Text</code> as an RGB integer.

0 commit comments

Comments
 (0)