Skip to content

Instantly share code, notes, and snippets.

@maknoll
Created August 15, 2011 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maknoll/1148055 to your computer and use it in GitHub Desktop.
Save maknoll/1148055 to your computer and use it in GitHub Desktop.
Fixes widths of german umlauts when loading ttf fonts with PdfBox
PDFont font = PDTrueTypeFont.loadTTF(document, "putr8a.ttf"); // example font (Utopia)
List<Float> widths = font.getWidths();
for (int i = 1; i <= 22; i++)
widths.add(250f); // add 22 floats to cover all 255 ascii chars
widths.set(246, widths.get(111)); // copy width of o to ö
widths.set(252, widths.get(117)); // u to ü
font.setWidths(widths);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment