diff --git a/src/OlStyleParser.spec.ts b/src/OlStyleParser.spec.ts index da3c9793..1d96c1f5 100644 --- a/src/OlStyleParser.spec.ts +++ b/src/OlStyleParser.spec.ts @@ -874,7 +874,7 @@ describe('OlStyleParser implements StyleParser', () => { expecSymb.rotate = expecSymb.rotate as number; const expecRotation = expecSymb.rotate * Math.PI / 180; // openlayers adds default font-style - const expecFont = `Normal ${expecSymb.size}px ${expecSymb.font?.join(', ')}`; + const expecFont = `normal normal ${expecSymb.size}px ${expecSymb.font?.join(', ')}`; const style = styles[0] as OlStyle; expect(style).toBeDefined(); diff --git a/src/OlStyleParser.ts b/src/OlStyleParser.ts index e6978d71..8d710c19 100644 --- a/src/OlStyleParser.ts +++ b/src/OlStyleParser.ts @@ -63,7 +63,6 @@ export class OlStyleParser implements StyleParser { MarkSymbolizer: { avoidEdges: 'none', blur: 'none', - fillOpacity: 'none', offsetAnchor: 'none', pitchAlignment: 'none', pitchScale: 'none', @@ -943,8 +942,15 @@ export class OlStyleParser implements StyleParser { } const fill = new this.OlStyleFillConstructor({ - color: (markSymbolizer.color && markSymbolizer.opacity !== undefined) ? - OlStyleUtil.getRgbaColor(markSymbolizer.color, markSymbolizer.opacity) : markSymbolizer.color + color: + markSymbolizer.color && + (markSymbolizer.opacity !== undefined || + markSymbolizer.fillOpacity !== undefined) + ? OlStyleUtil.getRgbaColor( + markSymbolizer.color, + markSymbolizer.opacity ?? markSymbolizer.fillOpacity ?? 1 + ) + : markSymbolizer.color, }); let olStyle: any; diff --git a/src/Util/OlStyleUtil.spec.ts b/src/Util/OlStyleUtil.spec.ts index e24dde78..828ef651 100644 --- a/src/Util/OlStyleUtil.spec.ts +++ b/src/Util/OlStyleUtil.spec.ts @@ -99,7 +99,7 @@ describe('OlStyleUtil', () => { offset: [0, 5] }; const opac = OlStyleUtil.getTextFont(symb); - expect(opac).toEqual('Normal 12px Arial'); + expect(opac).toEqual('normal normal 12px Arial'); }); }); diff --git a/src/Util/OlStyleUtil.ts b/src/Util/OlStyleUtil.ts index bd94352e..b0cd32aa 100644 --- a/src/Util/OlStyleUtil.ts +++ b/src/Util/OlStyleUtil.ts @@ -147,13 +147,15 @@ class OlStyleUtil { * @param symbolizer The TextSymbolizer to derive the font string from */ public static getTextFont(symbolizer: TextSymbolizer) { - // since TextSymbolizer has no prop for font weight we use 'Normal' as default - const weight = 'Normal'; + const fontWeight = symbolizer.fontWeight ?? 'normal'; + const fontStyle = symbolizer.fontStyle ?? 'normal'; + const size = symbolizer.size; const font = symbolizer.font; - return weight + ' ' + size + 'px ' + font; + return fontWeight + ' ' + fontStyle + ' ' + size + 'px ' + font; } + /** * Returns true if the given mark symbolizer is based on a font glyph * (i.e. has a well known name property starting with 'ttf://').