Skip to content

Commit 979033f

Browse files
committed
Minor Glyph refactoring.
1 parent 6e3c315 commit 979033f

File tree

1 file changed

+8
-11
lines changed
  • io/src/main/java/com/itextpdf/io/font/otf

1 file changed

+8
-11
lines changed

io/src/main/java/com/itextpdf/io/font/otf/Glyph.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,15 @@ public Glyph(int code, int width, Integer unicode, int[] bbox) {
9191
}
9292

9393
public Glyph(int width, Integer unicode) {
94-
this(-1, width, unicode, unicode != null ? TextUtil.convertFromUtf32(unicode) : null, false);
94+
this(-1, width, unicode, getChars(unicode), false);
9595
}
9696

9797
public Glyph(int code, int width, Integer unicode, char[] chars, boolean IsMark) {
9898
this.code = code;
9999
this.width = width;
100100
this.unicode = unicode;
101101
this.isMark = IsMark;
102-
this.chars = chars;
103-
if (chars == null && unicode != null && Character.isValidCodePoint(unicode)) {
104-
this.chars = TextUtil.convertFromUtf32(unicode);
105-
}
102+
this.chars = chars != null ? chars : getChars(unicode);
106103
}
107104

108105
public Glyph(Glyph glyph) {
@@ -129,11 +126,7 @@ public Glyph(Glyph glyph, int xPlacement, int yPlacement, int xAdvance, int yAdv
129126
}
130127

131128
public Glyph(Glyph glyph, Integer unicode) {
132-
this.code = glyph.code;
133-
this.width = glyph.width;
134-
this.isMark = glyph.isMark;
135-
this.chars = unicode != null ? TextUtil.convertFromUtf32(unicode) : null;
136-
this.unicode = unicode;
129+
this(glyph.code, glyph.width, unicode, getChars(unicode), glyph.isMark());
137130
}
138131

139132
public int getCode() {
@@ -154,7 +147,7 @@ public Integer getUnicode() {
154147

155148
public void setUnicode(Integer unicode) {
156149
this.unicode = unicode;
157-
this.chars = unicode != null ? TextUtil.convertFromUtf32(unicode) : null;
150+
this.chars = getChars(unicode);
158151
}
159152

160153
public char[] getChars() {
@@ -259,4 +252,8 @@ private static Integer codePoint(char[] a) {
259252
}
260253
return null;
261254
}
255+
256+
private static char[] getChars(Integer unicode) {
257+
return unicode != null ? TextUtil.convertFromUtf32(unicode) : null;
258+
}
262259
}

0 commit comments

Comments
 (0)