Closed Bug 1521723 Opened 6 years ago Closed 24 days ago

Implement the hyphenate-limit-chars property

Categories

(Core :: Layout: Text and Fonts, enhancement, P3)

66 Branch
enhancement

Tracking

()

RESOLVED FIXED
136 Branch
Tracking Status
relnote-firefox --- nightly+
firefox136 --- fixed

People

(Reporter: hallo, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, feature)

Attachments

(6 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0

Steps to reproduce:

  1. Use CSS Hyphenation for a sentence
  2. Find out that it is also uses Hyphenation for very short words
  3. Try to find a solution and fail to do so

Actual results:

The hyphenate-limit-chars property is currently not supported in Firefox. It should work as the -ms-hyphenate-limit-chars property in IE/Edge: https://msdn.microsoft.com/en-us/library/hh771865(v=vs.85).aspx

Expected results:

The hyphenate-limit-chars property should be supported in Firefox, so developers can decide how many characters a word should have before hyphens are used and how many characters before/after the break should be the minimum.

I've moved the bug to a new component and the guys from there will bet an idea of what should o whit this.

Component: Untriaged → Layout: Text and Fonts
Product: Firefox → Core
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: feature
Priority: -- → P3

Hmm, well, is this in any spec?

Hi do we have any news? Will this property be implemented soon?

kind regards

I took a stab at the CSS side of this (currently not hooked up to any actual layout behavior); WIP patch is above. Currently this seems to mostly work, but fails the transitions test at layout/style/test/test_transitions_per_property.html, so it's not 100% complete.

It's really annoying that this feature still doesn't exist in 2022.

Agreed. I can't believe there is so little innovation in the area of hyphenation.

Severity: normal → S3

Hey Jonathan, an Intent to Ship for hyphenate-limit-chars was just sent to blink-dev[1]. I assume this is something that you'll eventually get back to, but let us know if this was paused due to other concerns. Thanks!

(Also let me know if you would prefer us filing a formal position issue - seems unneeded in this case)

[1] https://groups.google.com/a/chromium.org/g/blink-dev/c/TjuGJ-8TeXk/m/X8gUvSejAwAJ

Flags: needinfo?(jfkthame)

Yes, I hope to get back to it at some point, but it hasn't been a top priority; not sure when I'll find some spare cycles.

Flags: needinfo?(jfkthame)

Bump. =)

Implementing this would make life a lot easier for many web editors and designers around the globe.

I'm using this definitions since years in hope that this feature some day will be implemented.
Hope this will be implemented in the future because the default hyphens: auto handling looks so terrible...

-webkit-hyphenate-limit-before: 4;
-webkit-hyphenate-limit-after: 5;
-ms-hyphenate-limit-chars: 10 4 5;
hyphenate-limit-chars: 10 4 5;

It's good that Edge and Chrome do support this, but at Firefox and Safari I have to exclude the support of hyphenation because the text layout without hyphenate-limit-chars is so disturbing and hard to read, that using hyphenation at all doesn't make sense.

Assignee: nobody → jfkthame
Attachment #9257491 - Attachment description: WIP: Bug 1521723 - Add CSS support for the hyphenate-limit-chars property. → Bug 1521723 - Add style-system support for the hyphenate-limit-chars property (not yet hooked up to layout). r=#layout
Status: NEW → ASSIGNED

The spec[1] explicitly says that the computed value is "three values,
each either the auto keyword or an integer", so we expect the computed
value to consistently return all three values, even if only one or two
were specified.

Conversely, when serializing the specified value there is no requirement
to return all three possible values, if the trailing ones have their
default values. The serialization rules in the CSSOM spec[2] say:

If component values can be omitted or replaced with a shorter
representation without changing the meaning of the value,
omit/replace them.

This is applicable to a case like hyphenate-limit-chars: auto auto auto.
[1] tells us that:

If the third value is missing, it is the same as the second.
If the second value is missing, then it is auto.

Therefore hyphenate-limit-chars: auto is the correct serialization;
the omitted second value will be considered auto, and the omitted
third value will be the same as the second, i.e. also auto.

[1] https://drafts.csswg.org/css-text-4/#hyphenate-char-limits
[2] https://www.w3.org/TR/cssom-1/#serializing-css-values

Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b0d3a445cbb7 Add style-system support for the hyphenate-limit-chars property (not yet hooked up to layout). r=layout-reviewers,emilio https://hg.mozilla.org/integration/autoland/rev/24a7788aaa86 Apply hyphenate-limit-chars settings to the potential breaks found by the hyphenator. r=layout-reviewers,emilio https://hg.mozilla.org/integration/autoland/rev/0d2f510b48cd Update references for auto-hyphenation reftests where hyphenate-limit-chars now blocks use of certain hyphenation points. r=layout-reviewers,emilio https://hg.mozilla.org/integration/autoland/rev/077f492c6eb5 Fix up incorrect expectations in WPT tests for hyphenate-limit-chars values. r=layout-reviewers,emilio https://hg.mozilla.org/integration/autoland/rev/938bbe1ece4e Remove metadata for WPT tests that now pass. r=layout-reviewers,TYLin https://hg.mozilla.org/integration/autoland/rev/a84e9b2644d1 Add a WPT test for interpolation of hyphenate-limit-chars values. r=layout-reviewers,emilio https://hg.mozilla.org/integration/autoland/rev/a4aa1d64b768 apply code formatting via Lando
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/50370 for changes under testing/web-platform/tests
Pushed by smolnar@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/351da7476c93 Fix non-unified build & devtools test failures. CLOSED TREE
Upstream PR merged by moz-wptsync-bot

:jfkthame could you consider nominating this for a release note? (Process info)

Flags: needinfo?(jfkthame)
Regressions: 1944849
Regressions: 1944862
No longer regressions: 1944862

(In reply to Donal Meehan [:dmeehan] from comment #24)

:jfkthame could you consider nominating this for a release note? (Process info)

Note that this is currently off-by-default for releases beyond Nightly...
https://searchfox.org/mozilla-central/rev/548b6981501f59e3c9f2f7851c013e7d53c4e72f/modules/libpref/init/StaticPrefList.yaml#9607-9611
...but it looks like the relnote "process info" that Donal linked would still suggest a release note, to spread word among Nightly users who read the release notes and maybe get us a bit more intentional testing from web developers on Nightly as a result.

(In reply to Daniel Holbert [:dholbert] from comment #25)

to spread word among Nightly users who read the release notes and maybe get us a bit more intentional testing from web developers on Nightly as a result.

Correct, we can still include release notes for nightly-only features. Relman ensures the release note does not ride the train to the beta release notes.

Release Note Request (optional, but appreciated)
[Why is this notable]:
Automatic hyphenation (CSS hyphens: auto) can be undesirable because it introduces too much hyphenation. This property allows authors who enable hyphenation to have better control over how frequently it is applied.

[Suggested wording]:
The hyphenate-limit-chars property enables authors to have greater control over the use of automatic hyphenation.

https://drafts.csswg.org/css-text-4/#hyphenate-char-limits
Some background articles/blog posts:
https://medium.com/clear-left-thinking/all-you-need-to-know-about-hyphenation-in-css-2baee2d89179#8434
https://justmarkup.com/articles/2019-01-28-a-look-at-css-hyphenation-in-2019/#too-much-hyphenation
https://generatedcontent.org/post/44751461516/finer-grained-control-of-hyphenation-with-css4

relnote-firefox: --- → ?
Flags: needinfo?(jfkthame)

Thanks, added to the Fx136 nightly release notes, please allow 30 minutes for the site to update.

Regressions: 1945227
Blocks: 1945341
Blocks: 1947183

Related Pull Requests

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: