ArrayList<VectorFontCharacter> characters = new ArrayList<VectorFontCharacter>();
int x = 0;
for (short i = 0; i < text.length(); i++) {
int glyphIndex = cmapFmt.mapCharCode(text.charAt(i));
Glyph glyph = f.getGlyph(glyphIndex);
int default_advance_x = f.getHmtxTable().getAdvanceWidth(glyphIndex);
if (glyph != null) {
// glyph.scale(Math.round(scaleFactor)); //Scaling has changed to int!?
// Add the Glyph to the Shape with an horizontal offset of x
VectorFontCharacter fontChar = getGlyphAsShape(f, glyph, glyphIndex, x, fillColor, strokeColor);
if (fontChar != null){
//Sets characters horizontal advancement and unicode value
fontChar.setHorizontalDist(default_advance_x);
// float tmp = fontChar.getHorizontalDist() * (float)(1.0/(float)this.unitsPerEm);
// fontChar.setHorizontalDist(Math.round(tmp * fontSize));
fontChar.setHorizontalDist(Math.round(fontChar.getHorizontalDist() * scaleFactor)); //FIXME TRIAL
fontChar.setUnicode(Character.toString(text.charAt(i)));
fontChar.setName(Character.toString(text.charAt(i)));
characters.add(fontChar);
}
x += glyph.getAdvanceWidth();
}else{
logger.error("Couldnt find character: \"" + text.charAt(i) + "\" in " + fontPath);
x += (int)((float)default_advance_x /* *scaleFactor */);
}