{"action":"created","issue":{"url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto/issues/3181","repository_url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto","labels_url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto/issues/3181/labels{/name}","comments_url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto/issues/3181/comments","events_url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto/issues/3181/events","html_url":"https://github.com/gravitystorm/openstreetmap-carto/issues/3181","id":316034528,"number":3181,"title":"Better render names with an hyphen","user":{"login":"naoliv","id":982338,"avatar_url":"https://avatars2.githubusercontent.com/u/982338?v=4","gravatar_id":"","url":"https://api.github.com/users/naoliv","html_url":"https://github.com/naoliv","followers_url":"https://api.github.com/users/naoliv/followers","following_url":"https://api.github.com/users/naoliv/following{/other_user}","gists_url":"https://api.github.com/users/naoliv/gists{/gist_id}","starred_url":"https://api.github.com/users/naoliv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naoliv/subscriptions","organizations_url":"https://api.github.com/users/naoliv/orgs","repos_url":"https://api.github.com/users/naoliv/repos","events_url":"https://api.github.com/users/naoliv/events{/privacy}","received_events_url":"https://api.github.com/users/naoliv/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-19T20:46:54Z","updated_at":"2018-04-20T15:51:01Z","closed_at":"2018-04-19T20:55:33Z","author_association":"NONE","body":"Have this node as an example https://www.openstreetmap.org/node/3474947606 with the name as `São João del-Rei`\r\n\r\nFrom zoom level 15 to 9 we have this:\r\n![15](https://user-images.githubusercontent.com/982338/39016876-135bd022-43f8-11e8-8269-4f6358ac11a4.png)![14](https://user-images.githubusercontent.com/982338/39016875-13387f6e-43f8-11e8-9c58-3881eb3062d5.png)![13](https://user-images.githubusercontent.com/982338/39016874-1311835a-43f8-11e8-9253-0b72d83fe6d6.png)![12](https://user-images.githubusercontent.com/982338/39016872-12eef588-43f8-11e8-9ef8-776271580186.png)![11](https://user-images.githubusercontent.com/982338/39016871-12ccd142-43f8-11e8-85a7-4cb71dfb9e32.png)![10](https://user-images.githubusercontent.com/982338/39016870-12aacdc2-43f8-11e8-9a7c-97e337c1b046.png)![9](https://user-images.githubusercontent.com/982338/39016868-127e652a-43f8-11e8-94b3-32d470482935.png)\r\n\r\nThe name is being split at the `del-Rei` hyphen, while it most probably should not be (the renderer should consider it as a single word and not as a line-wrapping symbol).\r\n\r\nFor example, instead having this\r\n```\r\nSão João del-\r\n     Rei\r\n```\r\n_(due to the hyphen and the current rendering (above), it could be misinterpreted as `São João delRei`)_\r\n\r\nwe could have it split like this:\r\n```\r\nSão João\r\ndel-Rei\r\n```"},"comment":{"url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto/issues/comments/383139684","html_url":"https://github.com/gravitystorm/openstreetmap-carto/issues/3181#issuecomment-383139684","issue_url":"https://api.github.com/repos/gravitystorm/openstreetmap-carto/issues/3181","id":383139684,"user":{"login":"sommerluk","id":6830724,"avatar_url":"https://avatars0.githubusercontent.com/u/6830724?v=4","gravatar_id":"","url":"https://api.github.com/users/sommerluk","html_url":"https://github.com/sommerluk","followers_url":"https://api.github.com/users/sommerluk/followers","following_url":"https://api.github.com/users/sommerluk/following{/other_user}","gists_url":"https://api.github.com/users/sommerluk/gists{/gist_id}","starred_url":"https://api.github.com/users/sommerluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sommerluk/subscriptions","organizations_url":"https://api.github.com/users/sommerluk/orgs","repos_url":"https://api.github.com/users/sommerluk/repos","events_url":"https://api.github.com/users/sommerluk/events{/privacy}","received_events_url":"https://api.github.com/users/sommerluk/received_events","type":"User","site_admin":false},"created_at":"2018-04-20T15:51:01Z","updated_at":"2018-04-20T15:51:01Z","author_association":"COLLABORATOR","body":"The [responsible code](https://github.com/gravitystorm/openstreetmap-carto/blob/529e3f69718ff21de5a069f6d4cc086b152a6185/placenames.mss#L271) is:\r\n\r\n```CartoCSS\r\ntext-wrap-width: 45; // 4.5 em\r\n```\r\n\r\nThat means: If a line is gets longer than 45 pt, than Mapnik tries to do a line wrap afterwards. Apparently, there are two different kind of line wrap in Mapnik:\r\n- The [`text-wrap-character`](http://mapnik.org/mapnik-reference/#3.0.20/text-wrap-character) property defines at which characters a  line wrap can be done. Default is: space character only. The [`text-repeat-wrap-character`](http://mapnik.org/mapnik-reference/#3.0.20/text-repeat-wrap-character) defines what happens with this character. By default it is removed. (That means, a space character is removed where a line break happens.) openstreetmap-carto uses currently the default settings of Mapnik.\r\n- Apparently, after `U+002D HYPHEN-MINUS` line wraps are also allowed. I did not find any Mapnik property to fine-tune this behaviour.\r\n\r\nThe screenshot that you have posted shows – in my opinion – two independent problems:\r\n\r\n1. A line wrap is allowed after `U+002D HYPHEN-MINUS`. Indeed I agree that it would be better for cartographic purposes when there was no line wrap after hyphen. This would also avoid some confusion. Possible solutions:\r\n\r\n   a. Substitute `U+002D HYPHEN-MINUS` by `U+2011 NON-BREAKING HYPHEN`, which is meant to be visually an identical glyph, but which does not allow a line wrap. I’ve verified that Mapnik indeed does not make a line wrap at `U+2011 NON-BREAKING HYPHEN`. The substitution could be done within openstreetmap-carto in the SQL query.\r\n\r\n   b. Mapnik support for customizing hyphen line wrap. This would be more elegant than a substitution in the SQL query. That means open a ticket at Mapnik’s issue tracker. If they decide to implement it and after a new Mapnik version is released and later packaged for Linux distributions, after that we could make use of it in openstreetmap-carto.\r\n\r\n2. The line length is not always well balanced for multi-line labels. Imagine that the name of this village would be `São João del Rei`, without any hyphen. The rendering would be\r\n```\r\nSão João del\r\n     Rei\r\n```\r\nAlso here, it would be better to have\r\n```\r\nSão João del\r\n     Rei\r\n```\r\ninstead. This would require a line-breaking algorithm a little bit similar to the one that is used in TeX: Not simply consider the length of the current line and break everything that’s too long, but consider the consequences for the following lines as well, to get the best possible overall harmony. (Well, given that the labels in cartography a much shorter than entire book paragraphs typically done in TeX, the algorithm could maybe be much more simple than TeX’s algorithm.) There’s nothing we can do about that in openstreetmap-carto. This would have to be implemented in Mapnik…"}}
{"actor":{"display_login":"sommerluk"}}