Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect letter spacing in both tangram-es and js for many shaped languages #94

Open
tallytalwar opened this issue Jul 5, 2020 · 8 comments

Comments

@tallytalwar
Copy link
Member

Screen Shot 2020-07-05 at 12 35 35 PM

Look at the name for North America (उत्तरी अमेरिका). I think I have mentioned about this issue in some other mapzen base style and the underlying problem was how " " was being used, or on those lines. Will try to dig the issue if I can, or else @nvkelso might remember this too (quite confident I discussed this and solved it with him).

@tallytalwar
Copy link
Member Author

I thought we had addressed this in another style but looks like all styles have this issue.
Its because of the split done on " " and replacing it with a "\n". Refer:

name = name.split(' ').join('\n');
return name.split('').join(' ');

Won't work for many other languages (not just indic).

@tallytalwar tallytalwar changed the title Incorrect letter spacing in tangram-es for hindi text Incorrect letter spacing in tangram-es for many shaped languages Jul 7, 2020
@tallytalwar tallytalwar changed the title Incorrect letter spacing in tangram-es for many shaped languages Incorrect letter spacing in both tangram-es and js for many shaped languages Jul 7, 2020
@tallytalwar
Copy link
Member Author

tallytalwar commented Jul 7, 2020

I can reproduce the same issue in tangram js also.

Screen Shot 2020-07-06 at 11 34 31 PM

@matteblair
Copy link
Member

I can't read Hindi but even I can tell that ain't right 😂

The join('\n') seems like it can (read: should) be replaced with a text_wrap parameter, which will handle RTL and shaped scripts correctly.

The join(' ') seems like it's emulating "expansion" for the font (not sure if there's another name for this, but "expansion" is what CoreText and TrueType call it). I think we could add a draw parameter for text expansion in Tangram ES - not sure about JS. More immediately, we could add a conditional in this function to skip that step if the chosen language is in a "blocklist" of shaped languages.

@tallytalwar
Copy link
Member Author

tallytalwar commented Jul 7, 2020

That sounds reasonable (with respect to disabling for blocklist of shaped languages) to me @matteblair. Thanks

@matteblair
Copy link
Member

Oh I just realized - adding spaces between letters makes it such that text_wrap won't work as expected because it will be applied on the output string. The spaces make it such that a line break can go anywhere in the word. So unless the "expansion" can be done properly in the font rendering, text_wrap won't be usable here :\

@nvkelso
Copy link
Member

nvkelso commented Jul 7, 2020 via email

@matteblair
Copy link
Member

Looks like maybe font-stretch is what "text expansion" is called in CSS. Does this property work with Canvas font rendering?

@nvkelso
Copy link
Member

nvkelso commented Jul 15, 2020

CSS letter spacing would add space between the characters.

Font stretch instead exaggerates the letter forms themselves and generally should only be used for fitting text inside a constrained area (like body text on a web page... or perhaps to get a line (road) text label to fit by adjusting it just a smidge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants