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

Reduce vertical spacing in labels #2358

Closed
matthijsmelissen opened this issue Sep 20, 2016 · 45 comments
Closed

Reduce vertical spacing in labels #2358

matthijsmelissen opened this issue Sep 20, 2016 · 45 comments

Comments

@matthijsmelissen
Copy link
Collaborator

matthijsmelissen commented Sep 20, 2016

Noto has a lot larger vertical spacing than the old font. This looks rather ugly for cartography (at least for Latin script).

Before/after:

screenshot_2016-09-20_23-55-12 screenshot_2016-09-20_23-54-38

We can use a negative text-line-spacing attribute to reduce the vertical spacing by a couple of pixels.

@pnorman
Copy link
Collaborator

pnorman commented Sep 20, 2016

https://material.google.com/style/typography.html#typography-styles has suggestions for line height. We don't need to follow them and we've got a different use case, but they'd be a good place to start. I'm not sure what values they suggest since I'm on airport wifi.

@sommerluk
Copy link
Collaborator

See also #2204 (comment) about line spacing.

Notos default line spacing is okay (or even narrow) for normal text bodys (about 60 characters per line). In general, in typography you would use a bigger line spacing when your lines are very large, and a narrower line spacing when your lines are very short. In cartography there are no text bodies, but only labels, and they are horizontially rather short. So a rather narrow line spacing would be good. The limit might be either tall scripts (#2349 (comment) and for a list also https://material.google.com/style/typography.html#typography-other-typographic-guidelines) or latin scripts with high characters (all capital characters, f, k, h…) with one or more combining diacritics (thought it’s rather seldom to have more than two combining ciacritics at the same letter).

@sommerluk
Copy link
Collaborator

Here is a screenshot (500%) with some example data:
wutajzyn
Reducing the baseline-to-baseline distance would lead to collisions here. The question is: How likely are such character combinations?

I agree that a smaller baseline-to-baseline distance would much improve the situation for latin scripts. But I don’t know how to do this without accepting some (seldom?) collisions in non-latin scripts or when using many diacritics.

@sommerluk
Copy link
Collaborator

sommerluk commented Oct 11, 2016

A real-world example for not-too-large spacing:
Pan Be (North) ပန်းဘဲ (မြောက်)
http://www.openstreetmap.org/node/4311140131#map=14/21.8905/96.0426
screenshot 3

@jojo4u
Copy link

jojo4u commented Oct 13, 2016

How does the non-UI Noto look like? The usage of the UI-variant seems logical ("constrained space") but I never saw example renderings of non-UI.

@pnorman
Copy link
Collaborator

pnorman commented Oct 13, 2016

How does the non-UI Noto look like? The usage of the UI-variant seems logical ("constrained space") but I never saw example renderings of non-UI

#2349 (comment) has an example. There is no difference on common latin characters, but SE Asian languages do show the difference

@jojo4u
Copy link

jojo4u commented Oct 13, 2016

Thanks, this was actually linked in first post, sorry.

@jojo4u
Copy link

jojo4u commented Oct 15, 2016

Some example pictures from notofonts/gujarati#18

"Frankfurt am Main" has very wide spacing, the second line looks very unconnected to the first.
screenshot_2016-10-15_13-33-03

"Frankfurt am Main" and "Freiburg im Breisgau" (left-bottom) have very wide spacing, the second line looks like a city on it's own.
screenshot_2016-10-15_13-33-21

@sommerluk
Copy link
Collaborator

A solution for “Freiburg im Breisgau” might be to increase the necessary distance from label to label. But this would reduce notably the number of labels that appear on the map, which would not be really practical.

@sommerluk
Copy link
Collaborator

Notos baseline-to-baseline distance (vertical spacing) seems to be script/font-file specific:

https://github.com/googlei18n/noto-fonts/issues/764#issuecomment-252778567

@pnorman
Copy link
Collaborator

pnorman commented Oct 27, 2016

Notos baseline-to-baseline distance (vertical spacing) seems to be script/font-file specific:

googlei18n/noto-fonts#764 (comment)

except

In addition, different scripts prefer different line metrics. Noto tries to provide suitable line metrics for each script rather than forcing all scripts to fit one. The UI fonts are an exception to this, however, so using them we could generate a single font sharing a single line height.

Sounds like some experimentation is needed.

@kocio-pl kocio-pl added the text label Nov 15, 2016
@kocio-pl kocio-pl added this to the Bugs and improvements milestone Nov 15, 2016
@verdy-p
Copy link

verdy-p commented Nov 16, 2016

See also this test page on the wiki (edit it to complete the text samples for missing scripts). It shows the full set of fonts used in the Master stylesheet for CartoCSS (in the same order, and for its three supported styles: book, bold and oblique).

https://wiki.openstreetmap.org/wiki/CartoCSS/fonts

All fonts are set to 10pt and drawn in black (with a small white glowing shadow) over a green background typical for the map, their name is displayed (along with a ISO 15924 script code from which they are designed, and followed by a suitable line-height for that script). The font size and the line-height for each script is set in this:

https://wiki.openstreetmap.org/wiki/CartoCSS/fonts/text

which is used as a template used in the previous page.

Currently, the following line-heights are determined by
{{#switch:{{{2|Latn}}}
|Mymr=1.6
|Hani|Hans|Hant|Hira|Kata|Hrkt|Jpan|Beng|Deva|Gujr|Knda|Telu|Mlym|Taml|Khmr|Thai=1.4
|Latn|Grek|Cyrl|#default=1.25
}}

As far as I see, the maximal value is 1.6 if we ignore the script used. That value 1.6 is the one implemented by default in Mediawiki. But it is only needed for Myanmarese/Burmese (whose Noto font still has no "UI" version with a smaller value around 1.4).
The default 1.25 is suitable for most scripts (... including symbols and Arabic in Kufi or Naskh style!), except Asian scripts (and Arabic in Nasthalik style for Urdu or Persian) that really need a minimum of 1.4.
Older scripts (not used in modern languages on the map) may need 1.4 (the #default above may be updated for them, by inserting sample text for test).

@pnorman
Copy link
Collaborator

pnorman commented Nov 16, 2016

What I'm really interested in is how the examples like မြော look with a an adjusted line spacing.

Remember, the property we set is text-line-spacing, not line height.

@verdy-p
Copy link

verdy-p commented Nov 17, 2016

"text-line-spacing" is a cartoCSS specific property which is simply the difference:
-
after conversion of units (because line-height can be given in "em", or with a relative unit, both being relative to the "font-size", or an absolute value in points/pixels/millimeters/inches/picas...; and because the font-size can also be specified separately in an absolute value, or in a relative value in percents or "em" dependant on the inherited font-size of another element)

There's no such "text-line-spacing" in standard CSS, this is an invention of cartoCSS.

When I mean a "line-height"=1.6, it means that the text-line-spacing is simply 0.6em (relative to the current font-size which is "1em"), so substract 1 to the relative line-height to get the desired "line-spacing" for cartoCSS.

However cartoCSS does not allow you to specify the "line-spacing" value directly, it uses a line-spacing from the font metrics property, and text-line-spacing will be a relative adjustment to the font metrics: "text-line-spacing:0" is exactly the same setting as "line-height:normal" which is the default for HTML and CSS.

cartoCSS contradicts here everything that is defined in the CSS standard (identically for HTML or SVG or all web standards), by defining it relative to the "normal" line-height, instead of relatively to the font-size.
The two systems do not work on the same units and on the same measurement, and there's for now no way to conciliate it because there's no common unit between cartoCSS and CSS:

  • cartoCSS uses a "font-normal-line-height-unit", which has no equivalent in CSS (except when you set "text-line-spacing:0" in cartoCSS, which should maps to "line-height:normal", but apparently this is not what is occuring as cartoCSS has a strange non-standard way to define its normal line-height (it is visibly larger than expected for Latin, reaching a value about 1.8em when the font metrics specify a normal line-height of 1.25em.

In my opinion cartoCSS is broken here: it probably uses the incorrect font-metrics or performs just a very weak hinting not really based on font-metrics, or based on the "em-height" with en estimated offset. (the em-height is the vertical extent of the "M" relative to the baseline, it is found in font metrics, and is about 0.8em in Latin fonts; in Asian fonts, the em-height is not defined because they use another baseline). CartoCSS has not followed what was standardized in CSS for defining font-metrics and defining a common line-height independantly of scripts and baselines.

CartoCSS is even broken here with its own definition of "text-label-position-tolerance" for defining the line-box (but only for the "placement:line") which is arbitrarily set to text-spacing/2.0 in order to define its own "shield". standr CSS uses a much more consistant "line-box", where all baselines can be placed. the cartoCSS metrics are broken here and do not even work correctly with Asian fonts: to compensate this defect and avoid collisions of text in Asian scripts, the default line-boxes produced by cartoCSS are much higher than expected and this is the reason why Latin scripts have excessive baselines.

I do think that cartoCSS should be extended to support all standard CSS metrics and baselines. CSS will certainly not be changed to support any cartoCSS metrics. But it's true that CSS would require an additional measurement unit for its "normal" line-height (e.g. "nh", so that "line-height: normal" in CSS would be exactly the same as "line-height: 1.0nh" in all scripts and all fonts and all baselines).

@nebulon42
Copy link
Contributor

@verdy-p I really appreciate your input, but it does not make sense to talk about plain CSS here. We use CartoCSS and while both have CSS in their name they don't have so much in common. It also does not make sense to talk about em. This unit is not available in CartoCSS. We cannot go beyond our renderer. For additional clarification: CartoCSS is just a preprocessor. It transforms a CSS-like syntax into Mapnik XML. As such it cannot do much things differently. It is the same thing with LESS/SASS and CSS.

I'm sure there are improvements possible to the text rendering but these are out of scope here and have to be discussed at the renderer library repository which is Mapnik.

@verdy-p
Copy link

verdy-p commented Nov 17, 2016

Speaking about CSS, it has all these things docmumented, but not supported at all in CartoCSS and this is a problem of CartoCSS, which then impacts the effective rendering of multiline labels.
It is still someting to correct in CartoCSS (independantly of Mapnik or JOSM renderers, which currently just use what CartoCSS produces, even if it's clearly defecting for that matters of multiline labels and causes all this havoc).
For now, CartoCSS just generates too large line-heights, even if CartoCSS remaps it in its own "text-line-spacing" that does not work as intended, and in fact cannot even be used correctly without setting it to something else than "text-line-spacing:0": this CartoCSS property is a complete non-sense and non-working, it has to be reworked and most probably deprecated/discarded completely.

Note: this discussion has been forwarded several times to other bugs/issues. Apparently no one want to support it anywhere. Discarding it here will not solve the problem. But someone must accept it, there's no appropriate place where to put it if every dependant project says this is not their problem and says this is "out of scope" or "non relevant". But moving CartoCSS forward to use properties as they are used in standard CSS would really help everyone (for all renderers: Mapnik, JOSM, iD, SVG/PDF generators, online vector rendering, including those using 3D extensions...), instead of reinventing the wheel.

@kocio-pl
Copy link
Collaborator

CartoCSS is already abandoned:

https://www.mapbox.com/blog/the-end-of-cartocss/

Yet the code can still be updated and released:

https://github.com/mapbox/carto

@pnorman
Copy link
Collaborator

pnorman commented Nov 17, 2016

It is still someting to correct in CartoCSS

...

But moving CartoCSS forward to use properties as they are used in standard CSS would really help everyone (for all renderers: Mapnik, JOSM, iD, SVG/PDF generators, online vector rendering, including those using 3D extensions...), instead of reinventing the wheel.

If different properties for line spacing are needed, this should be reported to Mapnik or CartoCSS issue trackers. We can't do anything about it here.

@verdy-p
Copy link

verdy-p commented Nov 17, 2016

You suggest reporting to CartoCSS, they forward the issue to here, for its use in Mapnik, and here "openstreetmap-carto" uses both CartoCSS (abandoned?) and Mapnik (they don't care about it).
So solution then if noone want to take this issue...
Maybe CartoCSS is abandonned by MapBox, but it is not for its use with Mapnik, JOSM, Overpass Turbo and others that need to continue to support it (independantly of Mapbox's decision to abandon it, also for a good reason: it could not work with their new framewotk supporting online vector rendering and 3D extensions)...
Here we are thinking about ways to improve the OpenStreetmap carto and if it cannot be solved with CartoCSS, you'll need to consider deviating from it (or like Mapbox, abandon it and return to more standard CSS). I think this should be coordinated with JOSM and other redering tools still using CartoCSS, and for which it would be preferable to develop a common solution: call it "CartoCSS 2.0" if you want.

@kocio-pl
Copy link
Collaborator

Did you try to contact the CartoCSS project?

Deviating from it or replacing it could be a huge problem.

@HolgerJeromin
Copy link
Contributor

@verdy-p JOSM and overpass-turbo use mapCSS which is not at all related to cartoCSS.

@nebulon42
Copy link
Contributor

@verdy-p You are still mixing up several things as @HolgerJeromin also explained. I'm also a maintainer at CartoCSS and I could not implement something like you suggest, because I can only take some input and map it to some Mapnik XML value. Mapnik would have to provide more finegrained options for anything to make sense in CartoCSS. Similarly, CSS' power is also not defined solely by its specification but by the rendering engine which implements it.

But that does not mean we cannot improve things here. Nobody really said that we don't want to improve the line spacing. It's just not as easy as with CSS.

@gravitystorm
Copy link
Owner

@verdy-p : @HolgerJeromin makes an important point - MapCSS and CartoCSS are completely different things and we should not mix them up.

Moreover, CartoCSS is not a "cartography version of standard CSS" or anything like that, so any comments about what font features are available in regular CSS are pretty much irrelevant. CartoCSS is simply an alternative way to describe Mapnik XML stylesheets.

We have only the font handling options available through Mapnik. If we want to do something that Mapnik doesn't support, then we need to add the feature to 1) Mapnik and then 2) to CartoCSS.

@verdy-p I would strongly encourage you to experiment with font handling within Mapnik, by using Kosmtik or Tilemill. This is much more practical than using unrelated technologies like mediawiki or html. And please stop referring to things as "broken", it's quite disrespectful to the people who work on them.

@verdy-p
Copy link

verdy-p commented Nov 19, 2016

Things can be said "broken" without loosing any respect to anyone.

Anyway if it is broken becauise of Mapnik, then Mapnik is broken there and should be modified. This does not change the fact there's a "problem" to solve.

If you don't like the term "broken", you will also not like the term "bug", but why is there any bug tracking system for those projects ? We admit that there are and will be problems to solve and it's independant of people that have already worked on these projects or will work on it to find solutions (and discover or create new problems/bugs/broken things). It's natural in any project with incremental evolutions. If all was already perfect, there would no longer be any project, everyone would use it "as is" without sending any criticism

If there are developers on these projects, it's exactly because there are problems to solve gradually or new requirements or features to implement. Are you saying that Mapnik and CartoCSS are completely finished projects ????

@kocio-pl
Copy link
Collaborator

I also feel this term is pretty neutral, but word games will not lead us anywhere. The most important thing is that Mapnik is a place you could start to get this problem solved, as Andy wrote.

I appreciate the work you've done searching for a solution. Do you need some help with it?

@verdy-p
Copy link

verdy-p commented Nov 19, 2016

Note: "unrelated technologies" are not so unrelated. OSM data will be rendered via various technologies but for many things we already have widely supported standards (with many developers involved for many other projects). Using HTML (even indirectly via a MediaWiki page) showns what can be done, and allows experimentation. Experimentation/demonstrations are very useful to know what can be done. I don't think that Mapnik or CartoCSS have to be "isolates" creating their own standard, this would not be productive and a loss of time for many developers that all want convergence with standards for more openness and for easier integration of other features. These projects don't have to become proprietary by rejecting those standards: "CartoCSS" resued the term "CSS" in its name but it is defective when it is not really an extension but a complete rewrite ignoring the standard (and the ongoing evolutions that are continuing fast in CSS: keeping away from this standard will cause later more and more work to follow what is desired and needed, and actually implemented in other solutions; in fine, you'll loose developers support that will prefer developing for something else, because it is has more features, has more possibilities of integration, is becioming more and more performant, and has many more tools to work with them).

But here you just want to promote a separate standard (that has comparatively a lower global support, even if for now it is having some success in some corners, but which is still not as mature as what competitors are doing, notably Google, Bing, MapBox... that will sell there own solutions)

Just consider that MapBox has abandoner the project to use soemthing else: it is a clear sign that the current state of CartoCSS will not be scalable and adaptable to newer projects that really want to do more with cartographic visualisations.

So don't loose time, and think about reconverging with the standard solutions. Otherwise this project will be slowly loosing its current supporters. Mapnik will need to evolve (another desrired thing in Mapnik is to support more zoom levels instead of the current levels based on integral powers of 2. Already others are already using quarter-levels and also implement now vector rendering and multiple projections (not just WGS84), and maps not necessarily oriented to the North. but for now Mapnik renders single tiles combining a background and oriented texts and icons that are not usable for rotating the generated maps. Probably later Mapnik will have to support multiple layers, and in fact generate many labels (for cities) and icons separatetly from tiles for the background: this layer of text and icons should probably become vectorial and will be able to support translations without having to generate everything: tiles will need to become transparent.

If later we want to reuse our languages for vectorial rendering, we'll need to have style properties working with other n,on-bitmap renderings. And almost all vectorial renderers are now using standard CSS (or fully equivalent properties, with only a difference of syntax, but not os semantics, so the conversions of formats can be more easily implemented and automated.)

@kocio-pl
Copy link
Collaborator

Let's keep this issue on topic. Your remarks are far beyond this ticket and even this project - whatever Mapnik should/will do, is outside of our scope.

We can however change the underlying technology, but that's a story for a new ticket, if you want. @pnorman even mentioned he would like to make a switch, but didn't say anything more specific yet.

@nebulon42
Copy link
Contributor

@verdy-p I have not fully read your lengthy discourse about other projects and general things because it's far beyond this project. Please stay on topic and accept the fact that there are things beyond this project that cannot be solved and discussed here. This is not a general issue tracker about OSM rendering but about this style specifically. If you continue to derail this discussion I will lock this ticket.

@verdy-p
Copy link

verdy-p commented Nov 19, 2016

But you propose no solution at all for handline line-heights correctly. This ticket is open for finding solutions, even if it involves finding cooperations with other projects from which you depend. It's a real problem since the begining, and I've just answered all your oppositions.
Apparently you don't want to solve the initial problem at all and don't want to do anything with other projects. I have tried to exhibit the problem and looking at how the fonts used are sorted. Nobody here wants to look at it. It does not matter at all if the demonstration is done on a Wiki or HTML or CSS: it just shows what can be done, and how such reflexion should be handled with maintainers of other projects.

And I don't see any reason why cartoCSS (or Mapnik) or other pseudo-CSS (MapCSS and other styling "protocols" like Mapnik-XML, or even the new styling protocol used now by MapBox) needs to deviate with standards by not supporting them at least with some equivalences and why OSM would even need to support two competing (and incompatible with each other) deviations. Convergence is needed.

Internationalisation of text rendering is a very huge problem that cannot be solved alone in this isolate project. You need to track here how you'll solve this problem (which is in fact a problem of interoperability which has been imho irreasonably ignored).

This ticket about handling line-height is a perfect example of the havoc that can happen, where everyone involded in this project ignores the real and constant need for convergence with standards, and rejects his own responsability. Others will take on if you don't want to solve it yourself, or even if you close this ticket, as it will reemerge (and will become even more urgent and complex to solve later when developers will start abandoning this CartoCSS project (something that has already happened with MapBox abandoning it). If you cumulate such ignored problems, the project will gradually fade out of use and will no longer receive any interest of developers: they'll have chosen something else (OSM itself already thinks about switching).

Repository owner locked and limited conversation to collaborators Nov 19, 2016
@nebulon42
Copy link
Contributor

As this discussion turned out to be non-productive I'm locking it temporarily. This does not mean that this is not an issue that should be solved. In fact this is a rather important problem on lower zoom levels that should be solved sooner than later.

Just a few remarks: Even if you feel there is immediate need to solve a specific problem it does not mean that someone will immediately jump to it. This is a volunteer-driven project. Even if there are interdependencies with other projects it does not mean that someone here has the power or the capacity or time to influence that projects. Largely, we have to work with what we have.

I appreciate your initial efforts but they where not immediately useful for the technology used here as there is little overlap with CSS. This is not something we could change overnight. If you feel this is wrong, feel free to do something against it. I'm also suggesting that you familiarize yourself with this project more to be able to come up with possible solutions in scope for this project.

Everybody is happy to help you if you have problems with the setup and the first steps.

Repository owner unlocked this conversation Nov 22, 2016
@nebulon42
Copy link
Contributor

Unlocking again that the discussion can proceed, hopefully on-topic.

@sommerluk
Copy link
Collaborator

Some thoughts about vertical line spacing:

  1. Mapniks line spacing algorithm claims to use the default line spacing of the font. And indeed it does. I’ve verified this for Noto by measuring the height of various labels in various scripts, and it works as expected. The observation of @simonpoole at New city labels sometimes overlap #2378 (comment) that labels at lower zoom levels “seems to have a proportionally different […] line spacing compared to higher zoom levels” is the result of an optical illusion (the label is very/too close to another label, and most of the characters in the second line to not have an ascender).

  2. A general typographic rule is that horizontally shorter lines should get narrower vertical line spacing and horizontally longer lines should get bigger vertical line spacing.

  3. Noto default line spacing is larger than the default line spacing of the previously used DejaVu fonts. This is a design decision of the Noto developers. In the 1990 years fonts had often narrower default line spacing – the minimal spacing to avoid collisions. The users where expected to set the real line spacing to something bigger. However many users of programs like Word or LibreOffice didn’t. So in Word the settings changed, and today the default line spacing is 115% of the line spacing of the font. And also font foundries started to use a larger default line spacing that is suitable for normal texts (about 60–80 characters per line). Noto does a good job by offering a usable default. Noto defines different individual default line spacing for different scripts (some Asian scripts have higher line spacing that Latin script). The problem for openstreetmap-carto is that it’s a special use case: Usually we do not render lines with 80 characters per line.

  4. Multi-line labels in openstreetmap-carto are normally horizontally shorter on lower zoom levels and horizontally larger on higher zoom levels. (text-wrap-width is usually smaller on lower zoom levels and greater on higher zoom levels)

  5. There are two ways to deal with line spacing: A) Use the default line spacing of the font and then maybe increase or decrease it (Default in Word/LibreOffice). B) Ignore the default line spacing of the font and use an independent fixed line spacing (Default in Indesign/Scribus). I think that option A is the best one for openstreetmap-carto. It gives us the possibility to take advantage of Notos different line spacing for different scripts. Option B would never look good at the same time for all scripts, but it would only look good for some scripts.

  6. It is yet possible to use negative floating point values for text-line-spacing in CartoCSS. The documentation says that it’s not possible, but this seems to be a bug in the documentation. I’ve tested negative floating point values, and it works fine. See Fix documentation of text-line-spacing mapbox/carto#452 and Bug in reference.json concerning text { line-spacing } mapnik/mapnik-reference#124 for details.

  7. I think the line spacing should depend on text-wrap-width. If text-wrap-width is small, the line spacing should also be small, if text-wrap-width is bigger, the line spacing should also be bigger. This will require to set the line spacing individually for each zoom level, but we are doing this anyway for the font size and the wrap width, so why not also for the line spacing.

  8. Notos default line spacing can be reduced up to ≈ −0.15 em. I’ve done some testing with various scripts, and I think with −0.15 em we will get almost no collisions. (In practice, for a label in font size 10 you would set text-line-spacing to −1.5, for a label in font size 14 you would set text-line-spacing to −2.1, and so on.) If we accept some seldom collisions, the line spacing can probably be reduced further.

  9. If we go for individual line spacing for each zoom level, then there is no need to make further feature request upstream at CartoCSS and Mapnik. We can live with what we have. Implementing upstream the features proposed by @verdy-p would than not create any benefit for openstreetmap-carto.

@verdy-p
Copy link

verdy-p commented Nov 23, 2016

There's still a problem: even if you use the "correct line spacing for
multiline labels", you completely ignore the effective line-height taken
for the top margin for the first line and the bottom margin for the last
line (or both margins for a single label), so collisions still occur. The
cartoCSS boxes are incorrectly computed and truncate part of these
line-heights.

This can easily explaing why a multiline label appearing above another
label in the same font size but just below it seem to "coalesce" and
associate incorrectly the lines. (the previous sample on low zoom level
around Luxembourg shows that clearly: the boxes for areas reserved by a
label (multiline or not) are not tall enough. If they were taller, some
labels below would simply not appear due to collision with these boxes, or
would be moved a bit more below (for example a city label displayed above
the central node would be placed instead below the same node.

The vertical position of boxes for multiline labels is not correct with
regard of the position of the central node, and the icon displayed for
these nodes (e.g. a small circle for the city) collides with the displayed
multiline label rendered on top of it. If the multiline label takes two
rows, that icon should be exactly in the middle between the two rows, but
here it appears to be clearly within the bottom of the first row.

2016-11-22 21:52 GMT+01:00 Lukas Sommer [email protected]:

Some thoughts about vertical line spacing:

Mapniks line spacing algorithm claims to use the default line spacing
of the font. And indeed it does. I’ve verified this for Noto by measuring
the height of various labels in various scripts, and it works as expected.
The observation of @simonpoole https://github.com/simonpoole at notofonts/gujarati#18
(comment)
#2378 (comment)
that labels at lower zoom levels “seems to have a proportionally different
[…] line spacing compared to higher zoom levels” is the result of an
optical illusion (the label is very/too close to another label, and most of
the characters in the second line to not have an ascender).
2.

A general typographic rule is that horizontally shorter lines should
get narrower vertical line spacing and horizontally longer lines should get
bigger vertical line spacing.
3.

Noto default line spacing is larger than the default line spacing of
the previously used DejaVu fonts. This is a design decision of the Noto
developers. In the 1990 years fonts had often narrower default line spacing
– the minimal spacing to avoid collisions. The users where expected to set
the real line spacing to something bigger. However many users of programs
like Word or LibreOffice didn’t. So in Word the settings changed, and today
the default line spacing is 115% of the line spacing of the font. And also
font foundries started to use a larger default line spacing that is
suitable for normal texts (about 60–80 characters per line). Noto does a
good job by offering a usable default. Noto defines different individual
default line spacing for different scripts (some Asian scripts have higher
line spacing that Latin script). The problem for openstreetmap-carto is
that it’s a special use case: Usually we do not render lines with 80
characters per line.
4.

Multi-line labels in openstreetmap-carto are normally horizontally
shorter on lower zoom levels and horizontally larger on higher zoom levels.
(text-wrap-width is usually smaller on lower zoom levels and greater on
higher zoom levels)
5.

There are two ways to deal with line spacing: A) Use the default line
spacing of the font and then maybe increase or decrease it (Default in
Word/LibreOffice). B) Ignore the default line spacing of the font and use
an independent fixed line spacing (Default in Indesign/Scribus). I think
that option A is the best one for openstreetmap-carto. It gives us the
possibility to take advantage of Notos different line spacing for different
scripts. Option B would never look good at the same time for all scripts,
but it would only look good for some scripts.
6.

It is yet possible to use negative floating point values for
text-line-spacing in CartoCSS. The documentation says that it’s not
possible, but this seems to be a bug in the documentation. I’ve tested
negative floating point values, and it works fine. See mapbox/carto#452
mapbox/carto#452 and
mapnik/mapnik-reference#124
mapnik/mapnik-reference#124 for details.
7.

I think the line spacing should depend on text-wrap-width. If
text-wrap-width is small, the line spacing should also be small, if
text-wrap-width is bigger, the line spacing should also be bigger. This
will require to set the line spacing individually for each zoom level, but
we are doing this anyway for the font size and the wrap width, so why not
also for the line spacing.
8.

Notos default line spacing can be reduced up to ≈ −0.15 em. I’ve done
some testing with various scripts, and I think with −0.15 em we will get
almost no collisions. (In practice, for a label in font size 10 you would
set text-line-spacing to −1.5, for a label in font size 14 you would set
text-line-spacing to −2.1, and so on.) If we accept some seldom collisions,
the line spacing can probably be reduced further.
9.

If we go for individual line spacing for each zoom level, then there
is no need to make further feature request upstream at CartoCSS and Mapnik.
We can live with what we have. Implementing upstream the features proposed
by @verdy-p https://github.com/verdy-p would than not create any
benefit for openstreetmap-carto.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2358 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUqG-DUOm2WAUWETgVFr2g3djrVe5Z5ks5rA1X6gaJpZM4KCMCD
.

@jojo4u
Copy link

jojo4u commented Dec 3, 2016

Some basics about Dejavu and Noto font metrics using ftdump from freetype package. The text height value is the most interesting. When divided by EM size the line height in em is calculated.

Dejavu (DejaVuSans.ttf) 2384/2048 = 1.16
All UI variants of Noto 2789/2048 = 1.36
Noto Sans CJK JP (NotoSansCJK-Regular.ttc) 1480/1000 = 1.48
Noto Kufi Arabic (NotoKufiArabic-Regular.ttf) 3885/2048 = 1.9 -> created #2479

I prepared an overview of the height of all Noto fonts:
https://gist.github.com/jojo4u/0b9284abc03278559a5ccd8dc49d4c0e

@kocio-pl
Copy link
Collaborator

kocio-pl commented Dec 3, 2016

I get error 404 with this gist link.

@jojo4u
Copy link

jojo4u commented Dec 4, 2016

Here is one example of a place in Myanmar which just is just touching now, so no space for -0.15 em. This is because Noto Sans Myanmar UI just uses all space of the general Noto UI height of 1.36. For Myanmar one could try to use non-UI variant which is much taller but may give more wiggle room. I can't test myself because there's no Geofabrik extract of Myanmar.
myanmar

@kocio-pl
Copy link
Collaborator

kocio-pl commented Dec 4, 2016

You can probably make it on your own by clipping Asia data:

https://wiki.openstreetmap.org/wiki/Osmconvert#Applying_Geographical_Borders

@jojo4u
Copy link

jojo4u commented Dec 4, 2016

I fixed the gist link

@sommerluk
Copy link
Collaborator

@jojo4u Thanks for the table! Great work!

@sommerluk
Copy link
Collaborator

The Myanmar example with −0.15 em:
grafik
Not ideal, but in my opinion still legible – the price we have to pay when reducing line spacing.

@verdy-p
Copy link

verdy-p commented Dec 6, 2016

The Myanmar UI collision is just the effect of an UI font version still not fully debugged. Ideally it should fit in 1.36em, with a small reduction of size for descenders and ascenders.

However this is clearly not a problem of OpenStreetmap Carto, but should be reported to Noto developers. The UI fonts in Noto are still in their first trial release, they've been published in an express way because of demands, even if they are still not ideal (notably for South-East Asian scripts)

The UI fonts are not ideal for Arabic Kufhi. But should even Arabic Kufhi be used in UI ? In my opinion only standard (western) Arabic, or Nasthalik (Eastern Arabic for Persian/Pashto/Urdu would seem needed (Kufhi is much more a "decorative" variant for Eastern Arabic... just like we have "swashed" versions of Latin also requiring huge line-heights, but normally not suitable for use in UI or labels on maps). I'm not convinced that Kufhi is useful for us (or even useful and really needed in Noto UI collection: it should not have been released at all, leaving only a non-UI version, usable for typesetted word processor documents, or possibly the presentation of long paragraphs of text on the web, or for special titling on book covers).

@jojo4u
Copy link

jojo4u commented Dec 6, 2016

The Myanmar -0.15 rendering seems acceptable.

@jojo4u
Copy link

jojo4u commented Dec 6, 2016

The Myanmar UI collision is just the effect of an UI font version still not fully debugged.

You refer to my screenshot and not line-height reduced by sommerluk?

The UI fonts are not ideal for Arabic Kufhi.

There is no UI variant for Kufi. Have a look at #2485.

@verdy-p
Copy link

verdy-p commented Dec 6, 2016

What I meant is that you used the huge Kufi font by default for rendering Arabic on Map, instead of more conventional (and UI!) fonts. Kufi however is best suited for rendering on traffic signs on roads, for easier reading by drivers, or for indoor signals in public areas, or for advertizing and titles of books. In all cases they are only short texts, but isolated on a clear background.

@jojo4u
Copy link

jojo4u commented Dec 9, 2016

Myanmar with non-UI and UI both with -0.15 em. Non-UI looks better alone but not when mixed with latin.

non-ui
image

non-ui 3
ui 3

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

No branches or pull requests

9 participants