Mercurial > gemma
diff client/src/components/Pdftool.vue @ 2240:c3cc21dee75d
client: pdf-gen add multi-language font
* Add use of three LinBiolinum fonts from libertine-fonts.org.
See the header of font-linbiolinum.js how I've prepared them for
jsPDF. There certainly is a better way to load these files.
* Adapted pdf layout slightly to accomodate for the font now used.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 13 Feb 2019 15:14:53 +0100 |
parents | 9b545e470b94 |
children | e6fba449aa3c |
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue Wed Feb 13 14:38:51 2019 +0100 +++ b/client/src/components/Pdftool.vue Wed Feb 13 15:14:53 2019 +0100 @@ -111,6 +111,7 @@ */ import { mapGetters, mapState } from "vuex"; import jsPDF from "jspdf"; +import "@/lib/font-linbiolinum.js"; import { getPointResolution } from "ol/proj.js"; import locale2 from "locale2"; @@ -211,7 +212,7 @@ let canvas = event.context.canvas; // because we are using Web Mercator, a pixel represents - // a differently sizes spot depending on the place of the map. + // a differently sized spot depending on the place of the map. // So we use a value calculated from the center of the current view. let view = map.getView(); let proj = view.getProjection(); @@ -237,7 +238,8 @@ ); if (template) { - let defaultFontSize = 10, + this.pdf.doc.setFont("linbiolinum", "normal"); + let defaultFontSize = 11, defaultRounding = 0, defaultTextColor = "black", defaultBgColor = "white", @@ -552,7 +554,7 @@ // draw numeric labels above scalebar this.pdf.doc.setTextColor("black"); - this.pdf.doc.setFontSize(5); + this.pdf.doc.setFontSize(6); this.pdf.doc.text(scaleBarX, scaleBarY - 1, "0"); // /4 and could give 2.5. We still round, because of floating point arith this.pdf.doc.text( @@ -672,7 +674,7 @@ ) { let width = 54; let height = 13; - let padding = 5; + let padding = 3; // x/y defaults to offset for topleft corner (normal x/y coordinates) let x = offset.x; @@ -689,8 +691,7 @@ this.addRoundedBox(x, y, width, height, "white", rounding); - this.pdf.doc.setFont("times", "normal"); - this.pdf.doc.setFontSize(9); + this.pdf.doc.setFontSize(10); this.pdf.doc.setTextColor(color); let str, w;