Skip to content

Commit

Permalink
add additional dejavusans/serif fonts (for invoice) (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer authored Jun 21, 2018
1 parent 06923a1 commit b0bdfeb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/main/java/alfio/controller/support/TemplateProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,18 @@ public static PdfBoxRenderer prepareItextRenderer(String page) {

builder.withW3cDocument(DOMBuilder.jsoup2DOM(Jsoup.parse(page)), "");
PdfBoxRenderer renderer = builder.buildPdfRenderer();
try (InputStream is = new ClassPathResource("/alfio/font/DejaVuSansMono.ttf").getInputStream()) {
try (InputStream is = new ClassPathResource("/alfio/font/DejaVuSansMono.ttf").getInputStream();
InputStream issans = new ClassPathResource("/alfio/font/DejaVuSans.ttf").getInputStream();
InputStream isserif = new ClassPathResource("/alfio/font/DejaVuSerif.ttf").getInputStream();
InputStream issmonob = new ClassPathResource("/alfio/font/DejaVuSansMono-Bold.ttf").getInputStream();
InputStream issansb = new ClassPathResource("/alfio/font/DejaVuSans-Bold.ttf").getInputStream();
InputStream isserifb = new ClassPathResource("/alfio/font/DejaVuSerif-Bold.ttf").getInputStream()) {
renderer.getFontResolver().addFont(() -> is, "DejaVu Sans Mono", null, null, false);
renderer.getFontResolver().addFont(() -> issans, "DejaVu Sans", null, null, false);
renderer.getFontResolver().addFont(() -> isserif, "DejaVu", null, null, false);
renderer.getFontResolver().addFont(() -> issmonob, "DejaVu Sans Mono Bold", null, null, false);
renderer.getFontResolver().addFont(() -> issansb, "DejaVu Sans Bold", null, null, false);
renderer.getFontResolver().addFont(() -> isserifb, "DejaVu Bold", null, null, false);
} catch(IOException e) {
log.warn("error while loading DejaVuSansMono.ttf font", e);
}
Expand Down
Binary file not shown.
Binary file added src/main/resources/alfio/font/DejaVuSans.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/main/resources/alfio/font/DejaVuSerif.ttf
Binary file not shown.
8 changes: 5 additions & 3 deletions src/main/resources/alfio/templates/invoice.ms
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<head>
<style>
body {
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:11pt;
font-family: "DejaVu Sans";
font-size:10pt;
line-height:12pt;
}

h1,h2,p {margin:0;}
Expand Down Expand Up @@ -73,8 +74,9 @@
min-height: 25px;
}

.strong {
.strong, strong {
font-weight: bold;
font-family: "DejaVu Sans Bold"
}

.mb {
Expand Down

0 comments on commit b0bdfeb

Please sign in to comment.