Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Line-break ideographic text by character #6828

Merged
merged 4 commits into from
Nov 14, 2016
Merged

Line-break ideographic text by character #6828

merged 4 commits into from
Nov 14, 2016

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Oct 26, 2016

Automatically insert a line break after any supported Chinese, Japanese, or Yi character in a point-placed label as needed to stay within the text-max-width. Balance the lines unless non-ideographic text such as Latin letters are present.

golf
Compare the label on the map to the popover title, which shows the queried feature’s name. A line break is absent from the feature but applied automatically by the renderer.

Ported from mapbox/mapbox-gl-js#3420. Fixes #1223. Depends on mapbox/mapbox-gl-test-suite#153.

Before merging:

/cc @lucaswoj @xrwang

@1ec5 1ec5 added Core The cross-platform C++ core, aka mbgl Google Maps parity For feature parity with the Google Maps SDK for Android or iOS labels Oct 26, 2016
@1ec5 1ec5 self-assigned this Oct 26, 2016
@mention-bot
Copy link

@1ec5, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @kelvinabrokwa and @kkaefer to be potential reviewers.

kkaefer
kkaefer previously approved these changes Oct 27, 2016
namespace i18n {

/// Returns whether a line break can be inserted after any character in the given string.
/// If false, line breaking should occur on word boundaries instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using triple slashes in core

@@ -143,7 +153,8 @@ void GlyphSet::lineWrap(Shaping &shaping, const float lineHeight, const float ma
|| shape.glyph == 0xb7 /* middle dot */
|| shape.glyph == 0x200b /* zero-width space */
|| shape.glyph == 0x2010 /* hyphen */
|| shape.glyph == 0x2013 /* en dash */) {
|| shape.glyph == 0x2013 /* en dash */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move all of those as well to a sister function of allowsIdeographicBreaking in the i18n namespace

@kkaefer kkaefer dismissed their stale review October 27, 2016 23:23

Failing tests

@1ec5
Copy link
Contributor Author

1ec5 commented Oct 27, 2016

The failing test is:

@brunoabinader
Copy link
Member

Worth noticing I am temporarily ignoring text-max-width/ideographic-breaking for GL native as part of updating mesa to use OSMesa: mapbox/mapbox-gl-test-suite@51546ca. We can undo it once this PR gets merged.

@jfirebaugh
Copy link
Contributor

The test-suite failure was prexisting. It's tracked in #6796 and the test case is now ignored for native. If you rebase this PR, I expect test-suite will pass.

Was that the only remaining obstacle to merging this?

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 7, 2016

Was that the only remaining obstacle to merging this?

I also need to address @kkaefer’s feedback, but that should be it.

@kkaefer
Copy link
Contributor

kkaefer commented Nov 10, 2016

Are there any tests that specifically test breaking by character?

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 10, 2016

There are rendering tests in the test suite for the overall ideographic breaking feature, but no comprehensive test that goes character by character. The rendering tests were disabled on the native side in mapbox/mapbox-gl-test-suite@3b005f1, but I verified that they passed before pinning to that commit.

@kkaefer
Copy link
Contributor

kkaefer commented Nov 10, 2016

Can we enable these tests when merging?

@1ec5
Copy link
Contributor Author

1ec5 commented Nov 10, 2016

Yes, it's on the to-do list above.

@1ec5 1ec5 added this to the android-v4.2.0 milestone Nov 12, 2016
@1ec5
Copy link
Contributor Author

1ec5 commented Nov 12, 2016

Putting this on the Android SDK v4.2.0 milestone because it blocks #6996.

@kkaefer
Copy link
Contributor

kkaefer commented Nov 14, 2016

@1ec5 any reason why we're not reenabling the tests as part of this PR rather than doing to after merge?

1ec5 added a commit to mapbox/mapbox-gl-test-suite that referenced this pull request Nov 14, 2016
@1ec5
Copy link
Contributor Author

1ec5 commented Nov 14, 2016

any reason why we're not reenabling the tests as part of this PR rather than doing to after merge?

OK, I’ve pointed this PR to the 1ec5-換行-1223 branch in gl-test-suite, in which I’ve reenabled the tests. Once I get the green light, I’ll fast-forward-merge that branch, then update the commit hash in package.json, then merge this PR.

@jfirebaugh jfirebaugh removed this from the android-v4.2.0 milestone Nov 14, 2016
1ec5 added a commit to mapbox/mapbox-gl-test-suite that referenced this pull request Nov 14, 2016
Allow a line break to be inserted after any supported Chinese, Japanese, or Yi character in a point-placed label. Balance the lines unless non-ideographic text such as Latin letters are present.

Fixes #1223.
@1ec5 1ec5 merged commit dbd2235 into master Nov 14, 2016
@1ec5 1ec5 deleted the 1ec5-換行-1223 branch November 14, 2016 22:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS Google Maps parity For feature parity with the Google Maps SDK for Android or iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants