Skip to content

Commit

Permalink
fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Mar 7, 2024
1 parent aef8ae0 commit ab29a68
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Dsl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ data class Text(
val text: String,
val size: String,
val color: String,
val fonts: List<String>,
val fonts: List<String>? = null,
val wrap: Number? = null,
val padding: Number? = null,
val outlineColor: String? = null,
Expand All @@ -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" },
Expand Down
10 changes: 4 additions & 6 deletions Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fun createStyle(name: String, accessToken: String, languages: List<String>, 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,
Expand Down Expand Up @@ -464,7 +464,7 @@ fun createStyle(name: String, accessToken: String, languages: List<String>, 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",
Expand Down Expand Up @@ -520,14 +520,12 @@ fun createStyle(name: String, accessToken: String, languages: List<String>, colo
"sources": {
"shortbread-v1": {
"type": "vector",
"url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json",
"attribution": "<a href='https://www.openstreetmap.org/copyright' title='OpenStreetMap is open data licensed under ODbL' target='_blank' class='osm-attrib'>&copy; OSM contributors</a>",
"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}"}},
Expand Down
20 changes: 9 additions & 11 deletions demo/streetcomplete-night.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"sources": {
"shortbread-v1": {
"type": "vector",
"url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json",
"attribution": "<a href='https://www.openstreetmap.org/copyright' title='OpenStreetMap is open data licensed under ODbL' target='_blank' class='osm-attrib'>&copy; OSM contributors</a>",
"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"}},
Expand Down Expand Up @@ -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} }
]
}
20 changes: 9 additions & 11 deletions demo/streetcomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"sources": {
"shortbread-v1": {
"type": "vector",
"url": "https://demo.tilekiln.xyz/shortbread_v1/tilejson.json",
"attribution": "<a href='https://www.openstreetmap.org/copyright' title='OpenStreetMap is open data licensed under ODbL' target='_blank' class='osm-attrib'>&copy; OSM contributors</a>",
"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"}},
Expand Down Expand Up @@ -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} }
]
}

0 comments on commit ab29a68

Please sign in to comment.