diff --git a/.github/workflows/publish-pages.yml b/.github/workflows/publish-pages.yml new file mode 100644 index 0000000..865ca31 --- /dev/null +++ b/.github/workflows/publish-pages.yml @@ -0,0 +1,75 @@ +name: Publish GitHub Pages + +# Publishes the demo site to GitHub Pages on every push to main and on each +# published release (and on manual dispatch). The site is assembled from the +# canonical sources at build time, so nothing has to be hand-copied into +# docs/ anymore: +# - docs/index.html -> / (the demo page) +# - styles/golfTilesStyle.json -> /styles/ (pmtiles URL rewritten to the +# Pages origin: golftiles.org +# sends no CORS headers) +# - docs/samples/*.pmtiles -> /samples/ (example tilesets) +# - docs/fonts/ -> /fonts/ (self-hosted glyph ranges) +# +# Requires the repo's Pages source to be set to "GitHub Actions" +# (one-time: gh api -X PUT repos/HuggeK/golfTiles/pages -f build_type=workflow). + +on: + push: + branches: [main] + release: + types: [published] + workflow_dispatch: # allow manual runs from the Actions tab + +# Never cancel a deployment in progress; queue instead. +concurrency: + group: pages + cancel-in-progress: false + +jobs: + publish: + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + pages: write # required to deploy to Pages + id-token: write # required by deploy-pages for OIDC verification + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure Pages + id: pages + uses: actions/configure-pages@v5 + + - name: Assemble site + env: + BASE_URL: ${{ steps.pages.outputs.base_url }} + run: | + mkdir -p _site/styles _site/samples + cp docs/index.html _site/index.html + cp docs/samples/*.pmtiles _site/samples/ + cp -r docs/fonts _site/fonts + # The canonical style points its pmtiles source at golftiles.org, + # which serves no CORS headers; the Pages copy must fetch tiles from + # its own origin. The same applies to glyphs: the canonical style + # declares none, so point it at the ranges copied above, otherwise + # docs/fonts/ ships for nothing and labels fall back to locally + # rendered glyphs. Both rewrites keep styles/golfTilesStyle.json + # itself untouched. jq doubles as a JSON validity gate. + jq --arg url "pmtiles://${BASE_URL}/samples/golfTiles_se_dk_fi.pmtiles" \ + --arg glyphs "${BASE_URL}/fonts/{fontstack}/{range}.pbf" \ + '.sources.golfTiles_source.url = $url | .glyphs = $glyphs' \ + styles/golfTilesStyle.json > _site/styles/golfTilesStyle.json + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: _site + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index 91ee8f8..3479699 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ /.vscode *:Zone.Identifier !/docs/samples/*.pmtiles -!/tests/fixtures/*.pbf \ No newline at end of file +!/tests/fixtures/*.pbf +!/docs/fonts/**/*.pbf +/_site diff --git a/README.md b/README.md index 282874a..cdffda5 100644 --- a/README.md +++ b/README.md @@ -102,12 +102,12 @@ golfTiles/ │ └── process.lua # Process file which decides what should be included in the tiles in what layers and what vector attributes should be written to the features(Schema) ├── data/ # Folder to place your .pbf extracts to generate tiles on. │ └── processed/ # Temporary folder used by the run_all.sh script for osmium-tool. -├── docs/ # Documentation. +├── docs/ # Documentation + sources for the GitHub Pages demo site. +│ ├── fonts/ # Self-hosted glyph .pbf ranges used by the style's glyphs property. │ ├── samples/ # folder for samples to be downloaded by interested parties and used by the demo. -│ ├── styles/ # mirrors the styles/ folder, to be use on the github pages due to CORS │ ├── CONTRIBUTING.md # Contributing information. │ ├── diary.md # Some development diary documenting the early process. -│ └── index.html # The page for github pages. +│ └── index.html # The demo page for github pages. ├── openfreemap-styles/ # Git Submodule of openfreemap-styles using the OpenMapTiles schema. ├── store/ # Folder to be used as swapspace for tilemaker. TBD. ├── styles/ # Contains the maplibre GL Styles golfTilesStyle.json, @@ -118,6 +118,16 @@ golfTiles/ └── run_all.sh # Main script to get generate .pmtiles. ``` +## Publishing the demo site +The GitHub Pages demo (https://huggek.github.io/golfTiles/) is published by the +[`publish-pages.yml`](.github/workflows/publish-pages.yml) workflow, which runs on every push to +main and on every published release (or manually from the Actions tab). It assembles the site from the canonical sources — the +demo page (`docs/index.html`), the style (`styles/golfTilesStyle.json`, with its pmtiles source URL +rewritten to the Pages origin since golftiles.org serves no CORS headers), the example tilesets +(`docs/samples/`) and the self-hosted font glyphs (`docs/fonts/`) — so no copies need to be kept in +sync by hand. Longer term, golftiles.org is meant to be the bucket endpoint serving the tiles and +the style, with the GitHub Pages site acting as the demo page. + ## Future technical development to solve the limitation using tileMaker In the future one could maybe use a "dynamic" tile generator server such as: - osm2psql diff --git a/docs/fonts/OFL.txt b/docs/fonts/OFL.txt new file mode 100644 index 0000000..d762c3c --- /dev/null +++ b/docs/fonts/OFL.txt @@ -0,0 +1,92 @@ +Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/fonts/Open Sans Regular/0-255.pbf b/docs/fonts/Open Sans Regular/0-255.pbf new file mode 100644 index 0000000..abc0300 Binary files /dev/null and b/docs/fonts/Open Sans Regular/0-255.pbf differ diff --git a/docs/fonts/Open Sans Regular/1024-1279.pbf b/docs/fonts/Open Sans Regular/1024-1279.pbf new file mode 100644 index 0000000..c097612 Binary files /dev/null and b/docs/fonts/Open Sans Regular/1024-1279.pbf differ diff --git a/docs/fonts/Open Sans Regular/1280-1535.pbf b/docs/fonts/Open Sans Regular/1280-1535.pbf new file mode 100644 index 0000000..c5e51f0 Binary files /dev/null and b/docs/fonts/Open Sans Regular/1280-1535.pbf differ diff --git a/docs/fonts/Open Sans Regular/256-511.pbf b/docs/fonts/Open Sans Regular/256-511.pbf new file mode 100644 index 0000000..c84003a Binary files /dev/null and b/docs/fonts/Open Sans Regular/256-511.pbf differ diff --git a/docs/fonts/Open Sans Regular/42752-43007.pbf b/docs/fonts/Open Sans Regular/42752-43007.pbf new file mode 100644 index 0000000..8e96ade Binary files /dev/null and b/docs/fonts/Open Sans Regular/42752-43007.pbf differ diff --git a/docs/fonts/Open Sans Regular/43776-44031.pbf b/docs/fonts/Open Sans Regular/43776-44031.pbf new file mode 100644 index 0000000..3e6972c Binary files /dev/null and b/docs/fonts/Open Sans Regular/43776-44031.pbf differ diff --git a/docs/fonts/Open Sans Regular/512-767.pbf b/docs/fonts/Open Sans Regular/512-767.pbf new file mode 100644 index 0000000..2f8c6f3 Binary files /dev/null and b/docs/fonts/Open Sans Regular/512-767.pbf differ diff --git a/docs/fonts/Open Sans Regular/64256-64511.pbf b/docs/fonts/Open Sans Regular/64256-64511.pbf new file mode 100644 index 0000000..925b113 Binary files /dev/null and b/docs/fonts/Open Sans Regular/64256-64511.pbf differ diff --git a/docs/fonts/Open Sans Regular/65280-65535.pbf b/docs/fonts/Open Sans Regular/65280-65535.pbf new file mode 100644 index 0000000..bfee3a9 Binary files /dev/null and b/docs/fonts/Open Sans Regular/65280-65535.pbf differ diff --git a/docs/fonts/Open Sans Regular/768-1023.pbf b/docs/fonts/Open Sans Regular/768-1023.pbf new file mode 100644 index 0000000..053caee Binary files /dev/null and b/docs/fonts/Open Sans Regular/768-1023.pbf differ diff --git a/docs/fonts/Open Sans Regular/7680-7935.pbf b/docs/fonts/Open Sans Regular/7680-7935.pbf new file mode 100644 index 0000000..b1583af Binary files /dev/null and b/docs/fonts/Open Sans Regular/7680-7935.pbf differ diff --git a/docs/fonts/Open Sans Regular/7936-8191.pbf b/docs/fonts/Open Sans Regular/7936-8191.pbf new file mode 100644 index 0000000..0350116 Binary files /dev/null and b/docs/fonts/Open Sans Regular/7936-8191.pbf differ diff --git a/docs/fonts/Open Sans Regular/8192-8447.pbf b/docs/fonts/Open Sans Regular/8192-8447.pbf new file mode 100644 index 0000000..74ba65f Binary files /dev/null and b/docs/fonts/Open Sans Regular/8192-8447.pbf differ diff --git a/docs/fonts/Open Sans Regular/8448-8703.pbf b/docs/fonts/Open Sans Regular/8448-8703.pbf new file mode 100644 index 0000000..25e0b65 Binary files /dev/null and b/docs/fonts/Open Sans Regular/8448-8703.pbf differ diff --git a/docs/fonts/Open Sans Regular/8704-8959.pbf b/docs/fonts/Open Sans Regular/8704-8959.pbf new file mode 100644 index 0000000..d45e111 Binary files /dev/null and b/docs/fonts/Open Sans Regular/8704-8959.pbf differ diff --git a/docs/fonts/Open Sans Regular/9472-9727.pbf b/docs/fonts/Open Sans Regular/9472-9727.pbf new file mode 100644 index 0000000..64c907d Binary files /dev/null and b/docs/fonts/Open Sans Regular/9472-9727.pbf differ diff --git a/docs/fonts/README.md b/docs/fonts/README.md new file mode 100644 index 0000000..0c9f41d --- /dev/null +++ b/docs/fonts/README.md @@ -0,0 +1,50 @@ +# Self-hosted font glyphs + +These are prebuilt SDF glyph ranges (`{fontstack}/{range}.pbf`) consumed by the MapLibre GL style +via its top-level `glyphs` property: + +``` +https://huggek.github.io/golfTiles/fonts/{fontstack}/{range}.pbf +``` + +GitHub Pages serves everything with `Access-Control-Allow-Origin: *`, so the same URL also works +when the style is served from golftiles.org or embedded in third-party apps. + +## Source and license + +- Generated from the current upstream **Open Sans**, the variable font + [`ofl/opensans/OpenSans[wdth,wght].ttf`](https://github.com/google/fonts/tree/main/ofl/opensans) + in `google/fonts`. +- Licensed under the [SIL Open Font License 1.1](https://openfontlicense.org/), © 2020 The Open + Sans Project Authors. A verbatim copy ships beside the glyphs as [`OFL.txt`](OFL.txt) and is + published at `/fonts/OFL.txt`; the OFL requires the licence and copyright notice to travel with + any redistribution, and these `.pbf` ranges are derived from the font. +- Open Sans was **relicensed from Apache 2.0 to OFL 1.1 in March 2021**, when it became a variable + font. Older prebuilt ranges (for example those from `fonts.openmaptiles.org`) are built from the + pre-2021 static TTFs and are still Apache 2.0. Do not mix the two without also changing `OFL.txt`. + +## Why only 16 files, not 256 + +MapLibre requests glyphs one 256-codepoint block at a time, so a complete fontstack is 256 files +covering the whole Basic Multilingual Plane. For Open Sans only **16 of those blocks contain any +glyphs** — the other 240 are ~32-byte empty stubs for scripts the font does not cover, so they are +not committed. + +A range that is absent 404s instead of returning an empty file. MapLibre treats both the same way: +it warns once and falls back to rendering that codepoint locally. Since the omitted blocks have no +glyphs to begin with, nothing renders differently — the only change is a console warning instead of +a silent empty response, and only for text outside Open Sans's coverage. + +## Regenerating + +The ranges were produced with MapLibre's own [font-maker](https://github.com/maplibre/font-maker) +WASM build (`sdfglyph.wasm`), which is what runs. Drop the +variable TTF into that page, name the stack exactly `Open Sans Regular` so it matches `text-font` +in `styles/golfTilesStyle.json`, download the ZIP, and keep only the non-empty ranges. FreeType +uses the variable font's default instance (`wght` 400, `wdth` 100), which is Regular. + +## Adding another fontstack + +Put the new stack's ranges in a sibling directory named exactly like the fontstack (spaces +included), e.g. `Open Sans Bold/0-255.pbf`, and reference it from the style's `text-font`. The +`publish-pages.yml` workflow copies the whole `docs/fonts/` directory into the published site. diff --git a/docs/index.html b/docs/index.html index 0668323..c1fb6a2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ - golfTiles.org + golfTiles