fix font setup in document command

This commit is contained in:
Jörg Prante 2023-08-07 18:14:51 +02:00
parent 9eeebfac01
commit ddb5db7b84
2 changed files with 10 additions and 13 deletions

View file

@ -239,7 +239,6 @@ public class Document implements Element, Closeable, RenderListener {
return PDType0Font.load(pdDocument, openTypeFont, true);
}
public Font getFont(String name) {
return fonts.get(name);
}

View file

@ -71,18 +71,16 @@ public class DocumentCommand implements Command {
} else {
document.setModificationDate(instant);
}
if (settings.containsSetting("font")) {
String[] fonts = settings.getAsArray("font");
for (String font : fonts) {
switch (font) {
case "helvetica" -> document.registerFont("helvetica", BaseFont.HELVETICA);
case "times" -> document.registerFont("times", BaseFont.TIMES);
case "courier" -> document.registerFont("courier", BaseFont.COURIER);
case "notosans" -> document.registerNotoSansFont();
case "notosanscjksc" -> document.registerNotoSansCJKSCFont();
case "opensans" -> document.registerOpenSansFont();
case "sourcesans" -> document.registerSourceSansFont();
}
String[] fonts = settings.getAsArray("font");
for (String font : fonts) {
switch (font) {
case "helvetica" -> document.registerFont("helvetica", BaseFont.HELVETICA);
case "times" -> document.registerFont("times", BaseFont.TIMES);
case "courier" -> document.registerFont("courier", BaseFont.COURIER);
case "notosans" -> document.registerNotoSansFont();
case "notosanscjksc" -> document.registerNotoSansCJKSCFont();
case "opensans" -> document.registerOpenSansFont();
case "sourcesans" -> document.registerSourceSansFont();
}
}
state.getElements().push(document);