From ab29a6817753b3f25aa723291190bc7fafa4b97a Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Thu, 7 Mar 2024 13:32:05 +0100 Subject: [PATCH] fonts --- Dsl.kt | 4 ++-- Main.kt | 10 ++++------ demo/streetcomplete-night.json | 20 +++++++++----------- demo/streetcomplete.json | 20 +++++++++----------- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Dsl.kt b/Dsl.kt index 47b4e06..839f124 100644 --- a/Dsl.kt +++ b/Dsl.kt @@ -167,7 +167,7 @@ data class Text( val text: String, val size: String, val color: String, - val fonts: List, + val fonts: List? = null, val wrap: Number? = null, val padding: Number? = null, val outlineColor: String? = null, @@ -190,7 +190,7 @@ data class Text( listOfNotNull( "\"text-field\": $text", "\"text-size\": $size", - "\"text-font\": [${fonts.joinToString { "\"$it\""}}]", + fonts?.joinToString(transform = { "\"$it\"" })?.let { "\"text-font\": [$it]" }, placement?.let { "\"symbol-placement\": \"$it\"" }, padding?.let { "\"text-padding\": $it" }, wrap?.let { "\"text-max-width\": $it" }, diff --git a/Main.kt b/Main.kt index e8ffed0..ccfd378 100644 --- a/Main.kt +++ b/Main.kt @@ -101,7 +101,7 @@ fun createStyle(name: String, accessToken: String, languages: List, colo val defaultTextStyle = Text( text = coalesceName(), size = byZoom(1, 13, 24, 64), - fonts = listOf("Roboto Regular", "Noto Regular"), + fonts = listOf("Noto Sans Regular"), color = colors.text, outlineColor = colors.textOutline, outlineWidth = 2.5, @@ -464,7 +464,7 @@ fun createStyle(name: String, accessToken: String, languages: List, colo Layer("labels-country", src = "boundary_labels", filter = listOf(tagIs("admin_level", 2)), - paint = defaultTextStyle.copy(fonts = listOf("Roboto Bold", "Noto Bold")) + paint = defaultTextStyle.copy(fonts = listOf("Noto Sans Bold")) ), Layer("labels-localities", @@ -520,14 +520,12 @@ fun createStyle(name: String, accessToken: String, languages: List, colo "sources": { "shortbread-v1": { "type": "vector", - "url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json", - "attribution": "© OSM contributors", - "maxzoom": 16 + "url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json" } }, "transition": { "duration": 300, "delay": 0 }, "light": { "intensity": 0.2 }, - "glyphs": "https://tiles.versatiles.org/assets/fonts/{fontstack}/{range}.pbf", + "glyphs": "https://tiles.versatiles.org/fonts/{fontstack}/{range}.pbf", "sprite": "https://tiles.versatiles.org/sprites/sprites", "layers": [ { "id": "background", "type": "background", "paint": {"background-color": "${colors.earth}"}}, diff --git a/demo/streetcomplete-night.json b/demo/streetcomplete-night.json index 7e22577..105c49d 100644 --- a/demo/streetcomplete-night.json +++ b/demo/streetcomplete-night.json @@ -4,14 +4,12 @@ "sources": { "shortbread-v1": { "type": "vector", - "url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json", - "attribution": "© OSM contributors", - "maxzoom": 16 + "url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json" } }, "transition": { "duration": 300, "delay": 0 }, "light": { "intensity": 0.2 }, - "glyphs": "https://tiles.versatiles.org/assets/fonts/{fontstack}/{range}.pbf", + "glyphs": "https://tiles.versatiles.org/fonts/{fontstack}/{range}.pbf", "sprite": "https://tiles.versatiles.org/sprites/sprites", "layers": [ { "id": "background", "type": "background", "paint": {"background-color": "#2e2e48"}}, @@ -105,12 +103,12 @@ { "id": "aerialways", "source": "shortbread-v1", "source-layer": "aerialways", "type": "line","paint": {"line-color": "#96c", "line-width": ["interpolate", ["exponential", 2], ["zoom"], 12, 0.75, 13, 2.0, 16.999, 4, 17, 2, 24, 128], "line-gap-width": ["interpolate", ["exponential", 2], ["zoom"], 12, 0, 17, 0, 24, 256], "line-opacity": ["interpolate", ["exponential", 2], ["zoom"], 12, 0, 13, 1]},"layout": {"line-join": "round"} }, { "id": "oneway-arrows", "source": "shortbread-v1", "source-layer": "streets", "minzoom": 16.0, "filter": ["==", ["get", "oneway"], true], "type": "symbol", "paint": {"icon-color": "#ccf"}, "layout": {"icon-image": "oneway", "symbol-spacing": 200, "symbol-placement": "line", "icon-padding": 5} }, { "id": "boundaries", "source": "shortbread-v1", "source-layer": "boundaries", "filter": ["all", ["==", ["get", "admin_level"], 2], ["!=", ["get", "maritime"], true]], "type": "line","paint": {"line-color": "#e72", "line-width": 1, "line-dasharray": [1, 2]} }, -{ "id": "labels-country", "source": "shortbread-v1", "source-layer": "boundary_labels", "filter": ["==", ["get", "admin_level"], 2], "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Bold", "Noto Bold"], "text-padding": 12} }, -{ "id": "labels-localities", "source": "shortbread-v1", "source-layer": "place_labels", "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "text-padding": 12} }, -{ "id": "labels-housenumbers", "source": "shortbread-v1", "source-layer": "addresses", "minzoom": 19.0, "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "housenumber"], ["get", "housename"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "text-padding": 12} }, -{ "id": "labels-road", "source": "shortbread-v1", "source-layer": "street_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "symbol-placement": "line-center", "text-padding": 12, "text-max-width": 25} }, -{ "id": "labels-road-areas", "source": "shortbread-v1", "source-layer": "streets_polygons_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "text-padding": 12} }, -{ "id": "labels-rivers", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 14.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["river", "canal"]]]], "type": "symbol", "paint": {"text-color": "#2e2e48", "text-halo-color": "#ccf", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "symbol-placement": "line-center", "text-padding": 12} }, -{ "id": "labels-streams", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 16.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["stream", "ditch", "drain"]]]], "type": "symbol", "paint": {"text-color": "#2e2e48", "text-halo-color": "#ccf", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "symbol-placement": "line-center", "text-padding": 12} } +{ "id": "labels-country", "source": "shortbread-v1", "source-layer": "boundary_labels", "filter": ["==", ["get", "admin_level"], 2], "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Bold"], "text-padding": 12} }, +{ "id": "labels-localities", "source": "shortbread-v1", "source-layer": "place_labels", "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "text-padding": 12} }, +{ "id": "labels-housenumbers", "source": "shortbread-v1", "source-layer": "addresses", "minzoom": 19.0, "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "housenumber"], ["get", "housename"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "text-padding": 12} }, +{ "id": "labels-road", "source": "shortbread-v1", "source-layer": "street_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "symbol-placement": "line-center", "text-padding": 12, "text-max-width": 25} }, +{ "id": "labels-road-areas", "source": "shortbread-v1", "source-layer": "streets_polygons_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#ccf", "text-halo-color": "#2e2e48", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "text-padding": 12} }, +{ "id": "labels-rivers", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 14.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["river", "canal"]]]], "type": "symbol", "paint": {"text-color": "#2e2e48", "text-halo-color": "#ccf", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "symbol-placement": "line-center", "text-padding": 12} }, +{ "id": "labels-streams", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 16.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["stream", "ditch", "drain"]]]], "type": "symbol", "paint": {"text-color": "#2e2e48", "text-halo-color": "#ccf", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "symbol-placement": "line-center", "text-padding": 12} } ] } diff --git a/demo/streetcomplete.json b/demo/streetcomplete.json index 7518164..9d5e0b4 100644 --- a/demo/streetcomplete.json +++ b/demo/streetcomplete.json @@ -4,14 +4,12 @@ "sources": { "shortbread-v1": { "type": "vector", - "url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json", - "attribution": "© OSM contributors", - "maxzoom": 16 + "url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json" } }, "transition": { "duration": 300, "delay": 0 }, "light": { "intensity": 0.2 }, - "glyphs": "https://tiles.versatiles.org/assets/fonts/{fontstack}/{range}.pbf", + "glyphs": "https://tiles.versatiles.org/fonts/{fontstack}/{range}.pbf", "sprite": "https://tiles.versatiles.org/sprites/sprites", "layers": [ { "id": "background", "type": "background", "paint": {"background-color": "#f3eacc"}}, @@ -105,12 +103,12 @@ { "id": "aerialways", "source": "shortbread-v1", "source-layer": "aerialways", "type": "line","paint": {"line-color": "#99a", "line-width": ["interpolate", ["exponential", 2], ["zoom"], 12, 0.75, 13, 2.0, 16.999, 4, 17, 2, 24, 128], "line-gap-width": ["interpolate", ["exponential", 2], ["zoom"], 12, 0, 17, 0, 24, 256], "line-opacity": ["interpolate", ["exponential", 2], ["zoom"], 12, 0, 13, 1]},"layout": {"line-join": "round"} }, { "id": "oneway-arrows", "source": "shortbread-v1", "source-layer": "streets", "minzoom": 16.0, "filter": ["==", ["get", "oneway"], true], "type": "symbol", "paint": {"icon-color": "#888"}, "layout": {"icon-image": "oneway", "symbol-spacing": 200, "symbol-placement": "line", "icon-padding": 5} }, { "id": "boundaries", "source": "shortbread-v1", "source-layer": "boundaries", "filter": ["all", ["==", ["get", "admin_level"], 2], ["!=", ["get", "maritime"], true]], "type": "line","paint": {"line-color": "#e39", "line-width": 1, "line-dasharray": [1, 2]} }, -{ "id": "labels-country", "source": "shortbread-v1", "source-layer": "boundary_labels", "filter": ["==", ["get", "admin_level"], 2], "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Bold", "Noto Bold"], "text-padding": 12} }, -{ "id": "labels-localities", "source": "shortbread-v1", "source-layer": "place_labels", "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "text-padding": 12} }, -{ "id": "labels-housenumbers", "source": "shortbread-v1", "source-layer": "addresses", "minzoom": 19.0, "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "housenumber"], ["get", "housename"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "text-padding": 12} }, -{ "id": "labels-road", "source": "shortbread-v1", "source-layer": "street_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "symbol-placement": "line-center", "text-padding": 12, "text-max-width": 25} }, -{ "id": "labels-road-areas", "source": "shortbread-v1", "source-layer": "streets_polygons_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "text-padding": 12} }, -{ "id": "labels-rivers", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 14.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["river", "canal"]]]], "type": "symbol", "paint": {"text-color": "#fff", "text-halo-color": "#349", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "symbol-placement": "line-center", "text-padding": 12} }, -{ "id": "labels-streams", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 16.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["stream", "ditch", "drain"]]]], "type": "symbol", "paint": {"text-color": "#fff", "text-halo-color": "#349", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Roboto Regular", "Noto Regular"], "symbol-placement": "line-center", "text-padding": 12} } +{ "id": "labels-country", "source": "shortbread-v1", "source-layer": "boundary_labels", "filter": ["==", ["get", "admin_level"], 2], "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Bold"], "text-padding": 12} }, +{ "id": "labels-localities", "source": "shortbread-v1", "source-layer": "place_labels", "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "text-padding": 12} }, +{ "id": "labels-housenumbers", "source": "shortbread-v1", "source-layer": "addresses", "minzoom": 19.0, "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "housenumber"], ["get", "housename"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "text-padding": 12} }, +{ "id": "labels-road", "source": "shortbread-v1", "source-layer": "street_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "symbol-placement": "line-center", "text-padding": 12, "text-max-width": 25} }, +{ "id": "labels-road-areas", "source": "shortbread-v1", "source-layer": "streets_polygons_labels", "minzoom": 14.0, "type": "symbol", "paint": {"text-color": "#124", "text-halo-color": "#fff", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "text-padding": 12} }, +{ "id": "labels-rivers", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 14.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["river", "canal"]]]], "type": "symbol", "paint": {"text-color": "#fff", "text-halo-color": "#349", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "symbol-placement": "line-center", "text-padding": 12} }, +{ "id": "labels-streams", "source": "shortbread-v1", "source-layer": "water_lines_labels", "minzoom": 16.0, "filter": ["all", ["!=", ["get", "tunnel"], true], ["in", ["get", "kind"], ["literal", ["stream", "ditch", "drain"]]]], "type": "symbol", "paint": {"text-color": "#fff", "text-halo-color": "#349", "text-halo-width": 2.5}, "layout": {"text-field": ["coalesce", ["get", "name"]], "text-size": ["interpolate", ["exponential", 2], ["zoom"], 1, 13, 24, 64], "text-font": ["Noto Sans Regular"], "symbol-placement": "line-center", "text-padding": 12} } ] }