You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the tip @1ec5 ! I don't think we've used that before, so this'll be a little learning on our part, but I imagine it's relatively straightforward to install and configure.
maybe we could just add Noto Arabic and Noto Hebrew to the text-font lists where Open Sans is used, so it will fail over to those if it can't find a glyph?
Changing fonts means rebuilding the glyphs PBF for the style
First proof of concept: RTL plugin + the fontstack URLs over at Mapbox.
Naturally, we can't really use this fontstack at Mapbox with someone else's access token and all. But it does prove the concept that Open Sans is still the shortcoming. If I supplement it with Noto Arabic and Noto Hebrew, this should work...
If I remember correctly, Mapbox’s Fonts API uses node-fontnik under the hood to vend PBFs that fall back to different fonts per glyph. Typically the style (or GL) will append Arial Unicode MS to the fontstack as a pan-Unicode font. I don’t think it generates the PBFs on the fly exactly.
Right, I had figured that part, that they compose PBFs that have a mixture
of glyphs from the fonts. The fontnik API lists a method for merging
glyphs, but does not provide a utility nor example code. So if that's the
direction we are going, it could take a bit to create and document that
process.
Then again there's a Rust utility that claims to merge font PBFs as well. I
don't know Rust but it's another angle.
We are also looking into licensing Arial Unicode, which would be a real
time saver since it supports so many glyphs already.
There are other pan-Unicode fonts, some of them freely licensed, but any pan-Unicode font comes with a lot of compromises. For example, Arial Unicode MS has a very tall line height because of its Thai and Vietnamese support, although some more recent fonts include Thai and Vietnamese with much less leading. If you can manage to include a wide variety of Noto fonts in the fontstack, I think that would lead to higher quality results (and ultimately the same performance characteristics on the client side).
Arial Unicode MS also makes some fraught compromises for CJK, but we already render CJK on the client side so it’s irrelevant here.
It is released under GPL, but our usage would likely fall under the GPL Font Embedding Exception.
Its glyph support is extensive.
There does not seem to be a bold nor italic version of the font. Arch Linux has a package script using mkfont and mkbold with the BDF version of the font, so if this proves promising there may be a path forward there: Unifont BDF -> mkbold and mkitalic -> mkttf -> fontnik build-glyphs
Promising results
Hebrew
Arabic
Japanese, Chinese
But Latin characters are not very pretty, kind of "computery"
These are Open Sans Regular, Bold, and Italic, with Unifont appended to them. Therefore the glyph from Open Sans will be used where it has a matching glyph (Latin character sets), then the Unifont glyph will be used where not (Hebrew, Arabic, and beyond).
In the map style definition in ohm.style.original.js I then replaced the font name:
"Open Sans" => "OpenHistorical"
"Open Sans Bold" => "OpenHistorical Bold"
"Open Sans Italic" => "OpenHistorical Italic"
In my testing this looks great:
Caveat about bold & italic:
Unifont does not have a bold nor italic version readily available. As such, an Arabic or Hebrew name that should be bold may show up in not-bold. I would need an example in order to test this out. I see that Arch Linux has a script when compiling their packages for creating bold & italic Unifont, so perhaps there is a way forward should this come up?
Next steps:
can anyone bring up an example of an Arabic or Hebrew label which should be bold? if so, does it appear bold correctly? @XPipe-SL ?
communicate with @tsinn about making corresponding changes in the upstream style, or otherwise figuring up what else would need to change e.g. font sizes
Create a branch & pull request for ohm-website with this modified style, get it deployed
Discuss with @vknoppkewetzel whether Woodblock would need something similar, e.g. a new "OpenHistorical Woodblock" font composed of Eaudi + Unifont?
Activity
1ec5 commentedon Apr 20, 2022
We probably need to install the right-to-left text plugin on the site.
danrademacher commentedon Apr 20, 2022
Thanks for the tip @1ec5 ! I don't think we've used that before, so this'll be a little learning on our part, but I imagine it's relatively straightforward to install and configure.
gregallensworth commentedon Apr 22, 2022
The RTL plugin requires 0.32.1 and this is running 0.53.1
According to https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-rtl-text/ there is a plugin that can do this for Mapbox GL. There's a paragraph that may copy-paste in readily.
According to Arabic text not displayed correctly mapbox/mapbox-gl-rtl-text#4 the font used in the map must also provide Arabic glyphs. The fonts used in Historical are Open Sans Italic and Open Sans Regular and Open Sans does not support Arabic*
So, a rough outline for my local testing:
text-fontlists where Open Sans is used, so it will fail over to those if it can't find a glyph?gregallensworth commentedon Apr 22, 2022
First proof of concept: RTL plugin + the fontstack URLs over at Mapbox.
Naturally, we can't really use this fontstack at Mapbox with someone else's access token and all. But it does prove the concept that Open Sans is still the shortcoming. If I supplement it with Noto Arabic and Noto Hebrew, this should work...
gregallensworth commentedon Apr 22, 2022
I could use some help on building the font stack necessary.
To use Open Sans, then failing over to some fonts which support other characters, the map style would read like this:
But of course this translates to:
https://openhistoricalmap.github.io/map-styles/fonts/Open%20Sans%20Regular,Noto%20Sans,Noto%20Sans%20Arabic,Noto%20Sans%20Hebrew/0-255.pbf
So the next question is how one combines the PBFs for the various fonts, in order to create a proper font stack that supports all of the glyphs?
At Mapbox URLs such as https://api.mapbox.com/fonts/v1/mapbox/DIN%20Offc%20Pro%20Regular,Arial%20Unicode%20MS%20Regular/8192-8447.pbf?access_token=xxx work for a variety of fonts and combinations of fonts. I imagine that they have already combined them and/or have some service which combines them on the fly.
1ec5 commentedon Apr 23, 2022
If I remember correctly, Mapbox’s Fonts API uses node-fontnik under the hood to vend PBFs that fall back to different fonts per glyph. Typically the style (or GL) will append Arial Unicode MS to the fontstack as a pan-Unicode font. I don’t think it generates the PBFs on the fly exactly.
gregallensworth commentedon Apr 23, 2022
1ec5 commentedon Apr 23, 2022
There are other pan-Unicode fonts, some of them freely licensed, but any pan-Unicode font comes with a lot of compromises. For example, Arial Unicode MS has a very tall line height because of its Thai and Vietnamese support, although some more recent fonts include Thai and Vietnamese with much less leading. If you can manage to include a wide variety of Noto fonts in the fontstack, I think that would lead to higher quality results (and ultimately the same performance characteristics on the client side).
Arial Unicode MS also makes some fraught compromises for CJK, but we already render CJK on the client side so it’s irrelevant here.
gregallensworth commentedon May 2, 2022
Thumbing through some pan-Unicode fonts, starting with the list at https://en.wikipedia.org/wiki/Open-source_Unicode_typefaces#Comparison
GNU Unifont
Despite the ugly website at https://unifoundry.com/unifont/ Unifont is being updated actively, its most recent being April 2022.
It is released under GPL, but our usage would likely fall under the GPL Font Embedding Exception.
Its glyph support is extensive.
There does not seem to be a bold nor italic version of the font. Arch Linux has a package script using mkfont and mkbold with the BDF version of the font, so if this proves promising there may be a path forward there: Unifont BDF -> mkbold and mkitalic -> mkttf -> fontnik build-glyphs
Promising results
Hebrew
Arabic
Japanese, Chinese
But Latin characters are not very pretty, kind of "computery"
gregallensworth commentedon May 3, 2022
I have composed some new fonts:
https://github.com/OpenHistoricalMap/map-styles/tree/staging/fonts/OpenHistorical
https://github.com/OpenHistoricalMap/map-styles/tree/staging/fonts/OpenHistorical%20Bold
https://github.com/OpenHistoricalMap/map-styles/tree/staging/fonts/OpenHistorical%20Italic
These are Open Sans Regular, Bold, and Italic, with Unifont appended to them. Therefore the glyph from Open Sans will be used where it has a matching glyph (Latin character sets), then the Unifont glyph will be used where not (Hebrew, Arabic, and beyond).
In the map style definition in ohm.style.original.js I then replaced the font name:
In my testing this looks great:
Caveat about bold & italic:
Next steps:
Open Sans to OpenHistorical
OpenHistoricalMap/issues#359 OpenHistorical font incl Arabic et al
gregallensworth commentedon May 6, 2022
See new branch: gin-openhistorical-font
See new pull request: OpenHistoricalMap/ohm-website#88
danrademacher commentedon May 10, 2022
https://openhistoricalmap.org/#map=7/37.095/-3.631&layers=O&date=1300&daterange=1,2022
Confirmed deployed:
