ioda-net / geo-front3

frontend from geoadmin/mf-geoadmin3
Other
1 stars 0 forks source link

Print KML font-family Helvetica file not found #124

Closed tigerfoot closed 7 years ago

tigerfoot commented 7 years ago

Discovered today

Extract of mapfish print log json {"symbolizers":[{"externalGraphic":"https://geojb.sigeom.local/api/color/255,0,0/marker-24@2x.png","type":"point"},{"haloOpacity":1,"fontFamily":"Helvetica","labelAlign":"cm","haloRadius":1,"haloColor":"#ffffff","fontSize":"8px","label":"Sapin","type":"Text","fontWeight":"normal","fontColor":"#ff0000"}]}},"opacity":1,"type":"geojson"}

INFO [ForkJoinPool-2-worker-7] org.geotools.renderer.style.FontCache.loadFromUrl null input stream, could not load the font INFO [ForkJoinPool-2-worker-7] org.geotools.renderer.style.FontCache.loadFromUrl Bad file name in SLDStyleFactoryHelvetica java.io.FileNotFoundException: Helvetica (No such file or directory)

We should provide a working font file and/or url Question if we have a real font file, should be the text rendered as text then in PDF.

In most jasper template we have "DejaVu Sans" used.

tigerfoot commented 7 years ago

Seems that this kind of patch would allow us to use another font by default

diff --git i/src/components/StylesService.js w/src/components/StylesService.js
index 4d39a4cc..b60eb557 100644
--- i/src/components/StylesService.js
+++ w/src/components/StylesService.js
@@ -10,7 +10,7 @@ goog.require('gf3');
   ]);

   module.provider('gaStyleFactory', function(gf3GlobalOptions) {
-    var DEFAULT_FONT = 'normal 16px Helvetica',
+    var DEFAULT_FONT = 'normal 16px DejaVu Sans',
         ZPOLYGON = 10,
         ZLINE = 20,
         ZICON = 30,
diff --git i/src/components/ngeoPrint/NgeoPrint.js w/src/components/ngeoPrint/NgeoPrint.js
index cfc3a958..d981dc8e 100644
--- i/src/components/ngeoPrint/NgeoPrint.js
+++ w/src/components/ngeoPrint/NgeoPrint.js
@@ -884,7 +884,7 @@ ngeo.Print.prototype.encodeOverlays_ = function(arr, overlays, scale) {
                 fontColor: '#ffffff',
                 fontSize: 7,
                 fontWeight: 'bold',
-                fontFamily: 'Helvetica'
+                fontFamily: 'DejaVu Sans'
               }, {
                 type: 'Point',
                 externalGraphic: printImagesUrl + '/print-bubble.png',

There's also still test and other libs (ol3cesium) who have a reference to Helvetica. @Jenselme is it worth to do that, especially when thinking in term of maintenance ?

Jenselme commented 7 years ago

I guess the reference to Helvetica in OL are default fonts that can be changed by the user. We shouldn't do anything about that.

We can add a font option in the configuration with DejaVu Sans as default and use it in the two places you found. That should solve the problem.

tigerfoot commented 7 years ago

+1 go for the option and to set the default to Deja Vu Sans (at least the same police used in Drawing tool) so end user get the same font aspect between their drawing and in printed material