ol-mapbox-style
Advanced tools
Comparing version 8.0.5 to 8.0.6
# Changelog | ||
## 8.0.6 | ||
* Remove `webfont-matcher` dependency. Instead, load Google fonts only when they are not available already. | ||
* Normalize Arial font name to make sure it can be detected. | ||
* Use `sans-serif` as fallback font. | ||
## 8.0.5 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "ol-mapbox-style", | ||
"version": "8.0.5", | ||
"version": "8.0.6", | ||
"description": "Create OpenLayers maps from Mapbox Style objects", | ||
@@ -40,4 +40,3 @@ "type": "module", | ||
"@mapbox/mapbox-gl-style-spec": "^13.23.1", | ||
"mapbox-to-css-font": "^2.4.1", | ||
"webfont-matcher": "^1.1.0" | ||
"mapbox-to-css-font": "^2.4.1" | ||
}, | ||
@@ -44,0 +43,0 @@ "devDependencies": { |
@@ -1039,2 +1039,5 @@ /* | ||
); | ||
if (!font.includes('sans-serif')) { | ||
font += ',sans-serif'; | ||
} | ||
letterSpacing = getValue( | ||
@@ -1041,0 +1044,0 @@ layer, |
@@ -1,3 +0,3 @@ | ||
import googleFonts from 'webfont-matcher/lib/fonts/google.js'; | ||
import mb2css from 'mapbox-to-css-font'; | ||
import {checkedFonts, registerFont} from 'ol/render/canvas.js'; | ||
import {createCanvas} from './util.js'; | ||
@@ -151,3 +151,2 @@ | ||
const processedFontFamilies = {}; | ||
const googleFamilies = googleFonts.getNames(); | ||
@@ -162,27 +161,43 @@ /** | ||
if (fontsKey in processedFontFamilies) { | ||
return fonts; | ||
return processedFontFamilies[fontsKey]; | ||
} | ||
const googleFontDescriptions = fonts.map(function (font) { | ||
const parts = mb2css(font, 1).split(' '); | ||
return [parts.slice(3).join(' ').replace(/"/g, ''), parts[1] + parts[0]]; | ||
}); | ||
const googleFontDescriptions = []; | ||
for (let i = 0, ii = fonts.length; i < ii; ++i) { | ||
fonts[i] = fonts[i].replace('Arial Unicode MS', 'Arial'); | ||
const font = fonts[i]; | ||
const cssFont = mb2css(font, 1); | ||
registerFont(cssFont); | ||
const parts = cssFont.split(' '); | ||
googleFontDescriptions.push([ | ||
parts.slice(3).join(' ').replace(/"/g, ''), | ||
parts[1], | ||
parts[0], | ||
]); | ||
} | ||
for (let i = 0, ii = googleFontDescriptions.length; i < ii; ++i) { | ||
const googleFontDescription = googleFontDescriptions[i]; | ||
const family = googleFontDescription[0]; | ||
if (!hasFontFamily(family) && googleFamilies.indexOf(family) !== -1) { | ||
const fontUrl = | ||
'https://fonts.googleapis.com/css?family=' + | ||
family.replace(/ /g, '+') + | ||
':' + | ||
googleFontDescription[1]; | ||
if (!document.querySelector('link[href="' + fontUrl + '"]')) { | ||
const markup = document.createElement('link'); | ||
markup.href = fontUrl; | ||
markup.rel = 'stylesheet'; | ||
document.head.appendChild(markup); | ||
if (!hasFontFamily(family)) { | ||
if ( | ||
checkedFonts.get( | ||
`${googleFontDescription[2]}\n${googleFontDescription[1]} \n${family}` | ||
) !== 100 | ||
) { | ||
const fontUrl = | ||
'https://fonts.googleapis.com/css?family=' + | ||
family.replace(/ /g, '+') + | ||
':' + | ||
googleFontDescription[1] + | ||
googleFontDescription[2]; | ||
if (!document.querySelector('link[href="' + fontUrl + '"]')) { | ||
const markup = document.createElement('link'); | ||
markup.href = fontUrl; | ||
markup.rel = 'stylesheet'; | ||
document.head.appendChild(markup); | ||
} | ||
} | ||
} | ||
} | ||
processedFontFamilies[fontsKey] = true; | ||
processedFontFamilies[fontsKey] = fonts; | ||
return fonts; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
5964798
95
18696
- Removedwebfont-matcher@^1.1.0
- Removedwebfont-matcher@1.1.0(transitive)