VectorFontCharacter[] newArray = new VectorFontCharacter[chars.length+3];
System.arraycopy(chars, 0, newArray, 0, chars.length);
//Manually add a NEWLINE character to the font
Vertex[] nlVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
ArrayList<Vertex[]> nlContours = new ArrayList<Vertex[]>();
nlContours.add(nlVerts);
VectorFontCharacter newLine = new VectorFontCharacter(nlContours, pa);
newLine.setPickable(false);
newLine.setVisible(false);
newLine.setNoFill(true);
newLine.setNoStroke(true);
newLine.setHorizontalDist(0);
newLine.setUnicode("\n");
newLine.setName("newline");
newArray[newArray.length-3] = newLine;
//Manually add a SPACE character to the font
// int charIndex = this.getCmapFormat(f).mapCharCode(32);
int charIndex = this.getCmapFormat(f).mapCharCode('i');
// int charIndex = this.getCmapFormat(f).mapCharCode('-');
int default_advance_x = f.getHmtxTable().getAdvanceWidth(charIndex);
Glyph glyph = f.getGlyph(charIndex);
int xadvance = 0;
if (glyph != null){
// xadvance = Math.round((default_advance_x * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
xadvance = Math.round(default_advance_x * this.scaleFactor);
}else{
// xadvance = Math.round((fontDefaultXAdvancing * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
xadvance = Math.round(fontDefaultXAdvancing * this.scaleFactor);
}
Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(xadvance,0,0),new Vertex(xadvance,100,0), /*new Vertex(0,100,0)*/};
ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
spaceContours.add(spaceVerts);
VectorFontCharacter space = new VectorFontCharacter(spaceContours, pa);
space.setPickable(false);
space.setVisible(false);
space.setNoFill(true);
space.setNoStroke(true);
space.setHorizontalDist(xadvance);
space.setUnicode(" ");
space.setName("space");
newArray[newArray.length-2] = space;
//Manually add a TAB character to the font
int defaultTabWidth = fontDefaultXAdvancing*4;
Vertex[] tabVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
ArrayList<Vertex[]> tabContours = new ArrayList<Vertex[]>();
tabContours.add(tabVerts);
VectorFontCharacter tab = new VectorFontCharacter(tabContours, pa);
tab.setPickable(false);
try {
int tabWidth = 4 * space.getHorizontalDist();
tab.setHorizontalDist(tabWidth);
tab.setVertices(new Vertex[]{new Vertex(0,0,0), new Vertex(tabWidth,0,0),new Vertex(tabWidth,100,0),/*new Vertex(0,100,0)*/} );
} catch (Exception e) {
tab.setHorizontalDist(defaultTabWidth);
}
tab.setUnicode("\t");
tab.setName("tab");