Closed Bug 1522857 Opened 7 years ago Closed 7 years ago

Firefox breaks right-aligned text after the space when font size is very large

Categories

(Core :: Layout, defect, P3)

65 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla66
Tracking Status
firefox-esr60 --- wontfix
firefox64 --- wontfix
firefox65 --- wontfix
firefox66 --- fixed

People

(Reporter: ced, Assigned: jfkthame)

References

Details

(Keywords: parity-chrome, parity-edge, regression)

Attachments

(4 files)

Attached image bug.png

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

Steps to reproduce:

Create a new html file then add this code:

<style>
h1 {
font: bold 300px sans-serif;
width: 900px;
text-align: right;
background: yellow;
}
</style>
<h1>Long title</h1>

Save and open this file in Firefox.

Actual results:

Firefox breaks the text after the first space, instead of before. The result is a miss-aligned text. It doesn't happen in other browsers.

Example: https://codepen.io/ced64k/pen/ErPgwX

Expected results:

Align all text to the right.

I can confirm the bug with Firefox 66 on windows 10

Status: UNCONFIRMED → NEW
Component: Untriaged → Layout
Ever confirmed: true
Product: Firefox → Core
Attached file html

I can reproduce on Windows10 if font-size >=246px

Regression window:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=d8ca3e1c469e&tochange=20d1a5916ef6

Suspect: bug 825875

Attachment #9039152 - Attachment filename: file_1522857.txt → file_1522857.html
Attachment #9039152 - Attachment mime type: text/plain → text/html

Wow, that's weird. The exact size where the problem kicks in also depends on the font used; it's 246px with Arial or Helvetica, but with Times [New Roman], it doesn't occur until 274px.

I'm guessing the issue may be triggered when the width of the <space> glyph becomes large enough that it no longer fits in a "simple" CompressedGlyph record in the textrun.

Priority: -- → P3

Yes @jfkthame I confirm, it only happens with large font-size.

Summary: Firefox breaks right-aligned text after the space → Firefox breaks right-aligned text after the space when font size is very large
Yep, as suspected -- the problem occurs when the space glyph doesn't fit the IsSimpleGlyph criteria. This means we take an alternate code path that handles generalized glyph records. Unfortunately, in that case we forgot to mark the resulting glyph record as being a space, and so when we're line-breaking, we don't recognize that it can be trimmed at the trailing edge of the line.
Attachment #9039182 - Flags: review?(jmuizelaar)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Just a simple reftest for this bug.
Attachment #9039210 - Flags: review?(jmuizelaar)
Attachment #9039210 - Flags: review?(jmuizelaar) → review+
Attachment #9039182 - Flags: review?(jmuizelaar) → review+
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/7761a0f081bf Ensure the CHAR_IS_SPACE flag is set properly in the textrun's mCharacterGlyphs array even when the space glyph does not fit into a simple CompressedGlyph record. r=jrmuizel https://hg.mozilla.org/integration/mozilla-inbound/rev/960911b3928c Reftest for trimming of space at line-break with large font size. r=jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: