diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a9b4dbb..48df8b8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,47 @@ ## Next version +## 10.4.0 + +### Changes that require attention + +#### Font handling and loading + +ol-mapbox-style no longer defaults to loading Google fonts when a required font is not available. Instead, it respects the new `metadata.ol:webfonts` field in the Mapbox Style document. Example: +```js +{ + "version": 8, + "metadata": { + "ol:webfonts": "https://mytileservergl.com/fonts/{font-family}/{fontweight}{-fontstyle}.css" + } + // ... +} +``` +The supported template placeholders are +* {font-family}: CSS font family converted to lowercase, blanks replaced with `-`, e.g. `noto-sans` +* {Font+Family}: CSS font family in original case, blanks replaced with `+`, e.g. `Noto+Sans` +* {fontweight}: CSS font weight (numeric), e.g. `400`, `700` +* {fontstyle}: CSS font style, e.g. `normal`, `italic` +* {-fontstyle}: CSS font style other than normal, e.g. `-italic` or empty string for normal + +In addition to providing fonts along with the style, this can be used to retrieve fonts from a CDN (e.g. `@fontsource`) or Google fonts. If this metadata field is not set to the style, the following default template will be used: + + https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css + +To retain the current behavior (i.e. use Google Fonts), the template URL will have to be + + https://fonts.googleapis.com/css?family={Font+Family}:{fontweight}{fontstyle} + +### Other changes + +* Fix a potential tile cache issue +* Fix problem caused by `getUid` function missing in the full build +* Make `updateMapboxStyle()` work with objects that are not a reference to the original one +* Add support for the `tms` tile scheme for `raster` and `vector` layers +* Add support for the `terrarium` encoding for `raster-dem` sources +* Fix an issue where the `icon-offset` layout property modifies the underlying Mapbox Style object +* Set the correct input projection for `geojson` sources when the `projection` option is used + ## 10.3.4 * Fix addMapboxLayer - updateMapboxLayer - removeMapboxLayer sequence diff --git a/README.md b/README.md index 917410ae..242c6907 100644 --- a/README.md +++ b/README.md @@ -558,7 +558,7 @@ sure that sprite image loading works: | `spriteImageUrl` | `string` | `undefined` | Sprite image url for the sprite specified in the Mapbox Style object's `sprite` property. Only required if a `sprite` property is specified in the Mapbox Style object. | | `getFonts` | (`arg0`: `string`\[], `arg1`: `string`) => `string`\[] | `undefined` | Function that receives a font stack and the url template from the GL style's `metadata['ol:webfonts']` property (if set) as arguments, and returns a (modified) font stack that is available. Font names are the names used in the Mapbox Style object. If not provided, the font stack will be used as-is. This function can also be used for loading web fonts. | | `getImage?` | (`arg0`: `VectorLayer`<`any`> \| `VectorTileLayer`, `arg1`: `string`) => `string` \| `HTMLCanvasElement` \| `HTMLImageElement` | `undefined` | Function that returns an image or a URL for an image name. If the result is an HTMLImageElement, it must already be loaded. The layer can be used to call layer.changed() when the loading and processing of the image has finished. This function can be used for icons not in the sprite or to override sprite icons. | -| `...args` | `any`\[] | `undefined` | - | +| `...args` | `any` | `undefined` | - | ##### Returns diff --git a/package-lock.json b/package-lock.json index c1141be9..8bb62501 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ol-mapbox-style", - "version": "10.3.4", + "version": "10.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ol-mapbox-style", - "version": "10.3.4", + "version": "10.4.0", "license": "BSD-2-Clause", "dependencies": { "@mapbox/mapbox-gl-style-spec": "^13.23.1", diff --git a/package.json b/package.json index f1f40c56..d6ae04ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ol-mapbox-style", - "version": "10.3.4", + "version": "10.4.0", "description": "Create OpenLayers maps from Mapbox Style objects", "type": "module", "browser": "dist/index.js",