maplibre-gl-js icon indicating copy to clipboard operation
maplibre-gl-js copied to clipboard

Unicode font do not display properly in map.

Open aerotypebharat opened this issue 4 years ago • 18 comments

This is the name in openstreetmap.org image This is what displayed in map. image Test code available in code pen here https://codepen.io/snickell/pen/dypOWzj

aerotypebharat avatar Dec 29 '20 18:12 aerotypebharat

I opened this issue in Mapbox gl js. Can anyone give me direction how this can be solved to support Devanagari letters

aerotypebharat avatar Jun 30 '21 02:06 aerotypebharat

I'm not sure I fully understand the problem. It would be best if you elaborate. Regardless, you'll probably need to download a font that support these letters and use it instead of the current font. I had the same problem with hebrew letters I think...

HarelM avatar Jun 30 '21 04:06 HarelM

image This vowel character is supposed to go in front of the consonant. More details can ne explored here in Wikipedia https://en.wikipedia.org/wiki/Devanagari image I also found this line is commented out in is_char_in_unicode_block.js image

aerotypebharat avatar Jul 18 '21 17:07 aerotypebharat

Ahh, I have the same problem with "nikud" - the hebrew extra characters to indicate how to read, they appear after the letter instead of within the letter. I have no clue how to solve this, you'll need to research how text in webgl is created and how to add these letters in the right place. Sorry I don't have better knowledge on the subject. But if you find out please serve a PR :-)

HarelM avatar Jul 18 '21 18:07 HarelM

@aerotypebharat: What fontface is used in your screenshot? Do you have a public fontface that renders Devanagari correctly at https://fonts.google.com/ ? You can then use https://github.com/orangemug/font-glyphs to generate pre-rendered fonts (Signed Distance Field glyphs) to consume from your style

ambientlight avatar Jul 19 '21 02:07 ambientlight

I am using Khula font. It is public in Google Khula Font. It renders properly in text. I have tried other fonts that support Devanagari but maplibre-gl.js does not have code to handle vowels and special characters of Devanagari.

aerotypebharat avatar Jul 19 '21 02:07 aerotypebharat

The approach chosen by Mapbox to render labels is unfortunately fundamentally incompatible with scripts that require more sophisticated handling than a mechanical typewriter could provide. This is not a problem with Unicode support as such; there is no problem with the encoding.

anarchodin avatar Sep 15 '21 22:09 anarchodin

There was some attempts to solve this, but they didn't go far. OpenLayers tried to do it using svg on canvas, but iirc it was not solving it properly either.

Basically there is a c++ lib that knows how to do all the proper text rendering. Browsers use that for the sites. Webgl has limited support of that lib (?), eg cannot use it along a curve to draw street names. So mb had to create a separate system for fonts that can draw labels in webgl along a curve line, but only if each letter is by itself. It does not support ligatures and other complexities. They did a hack for Arabic by creating 4 variants for each letter: without ligatures, with one on left, one in right, and both, plus some code that decides which variant to use. Languages such as used in Maianmar (Birma) are far more complex, and cannot be hacked this way.

Hopefully some day browsers will have a good font support in webgl so all this hackary can just be dropped

nyurik avatar Sep 15 '21 22:09 nyurik

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 15 '22 01:03 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Apr 19 '22 02:04 github-actions[bot]

Assigned XXL bounty. https://github.com/maplibre/maplibre/issues/193 Acceptance criteria: brahmic fonts are rendered correctly.

HarelM avatar Mar 16 '23 06:03 HarelM

@HarelM I'd like to work on this issue, can I claim this?

hami9x avatar Mar 20 '23 02:03 hami9x

Nice that you start working on this, @hami9x. You can have a look at https://github.com/maplibre/maplibre-gl-native/discussions/778 there should be some useful info.

wipfli avatar Mar 20 '23 14:03 wipfli

And also this one: https://github.com/maplibre/maplibre/discussions/231

wipfli avatar Mar 20 '23 14:03 wipfli

@wipfli Thank you for the heads up, I have some background in C++ and enjoy hardcore stuff like this. This will be really challenging though.

hami9x avatar Mar 21 '23 04:03 hami9x

It's worth considering writing it in Rust maybe, so that it will be available in both native and here (as wasm).

HarelM avatar Mar 21 '23 06:03 HarelM

The arabic is displaying backwards and the letters are disconnected.

bigBxr avatar Mar 14 '24 22:03 bigBxr

@bigBxr to get correct arabic text you need to load the RTL plugin

wipfli avatar Mar 15 '24 01:03 wipfli