int originalFontSize = fontSize; //important for font cache
PImage dummy = new PImage(1,1);
// /*
//Manually add a newLine character to the font
BitmapFontCharacter newLine = new BitmapFontCharacter(dummy, pa, "\n", 0, 0, 0);
newLine.setPickable(false);
newLine.setVisible(false);
newLine.setNoFill(true);
newLine.setNoStroke(true);
newLine.setName("newline");
bitMapCharacters.add(newLine);
//Manually add a SPACE character to the font
// int spaceAdvancex = defaultHorizontalAdvX;
// int spaceAdvancex = fm.charWidth(' ');
//TODO hack, we use the dash character's width for the space width, because dont know how to get it
// int spaceIndex = p5Font.index('-');
// int spaceAdvancex = p5Font.width[spaceIndex];
// int spaceAdvancex = p5Font.getGlyph('-').width;
int spaceAdvancex = Math.round(((float) p5Font.width('i') * (float) fontSize));
// int spaceAdvancex = Math.round(pa.textWidth(' '));
// int spaceAdvancex = Math.round(p5Font.width(' ') * p5Font.size);
BitmapFontCharacter space = new BitmapFontCharacter(dummy, pa, " ", 0, 0, spaceAdvancex);
space.setPickable(false);
space.setVisible(false);
space.setNoFill(true);
space.setNoStroke(true);
space.setName("space");
bitMapCharacters.add(space);
//Manually add a TAB character to the font
int defaultTabWidth = spaceAdvancex*4;
BitmapFontCharacter tab = new BitmapFontCharacter(dummy, pa, "\t", 0, 0, defaultTabWidth);
try {
int tabWidth = 4 * space.getHorizontalDist();
tab.setHorizontalDist(tabWidth);
} catch (Exception e) {
tab.setHorizontalDist(defaultTabWidth);
}
tab.setPickable(false);
tab.setName("tab");
tab.setVisible(false);
tab.setNoFill(true);
tab.setNoStroke(true);
bitMapCharacters.add(tab);
// */
//TODO bitmap font size seems different to same size vector font, we must have check descent -> textarea -> res*em*etc
//TODO eureka font - numbers baseline wrong?