Closed Bug 695639 Opened 14 years ago Closed 14 years ago

nsLayoutUtils::GetFontFacesForText does not use the proper offset into the textrun

Categories

(Core :: Layout: Text and Fonts, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(2 files, 1 obsolete file)

In nsLayoutUtils::GetFontFacesForText, we fail to re-add the appropriate ContentOffset after converting the original offset to a skipped offset; as a result, we get font information for the wrong range of characters in the textrun, in the case of a single run that's being rendered across multiple lines. This is the cause of the issue described in Fanolian's review of the fontinfo add-on at https://addons.mozilla.org/en-US/firefox/addon/fontinfo/; the results vary depending on window width because this affects how the textrun is wrapped.
Attachment #567992 - Flags: review?(roc)
Comment on attachment 567992 [details] [diff] [review] patch, add the frame's contentoffset when looking at the textrun Review of attachment 567992 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/nsLayoutUtils.cpp @@ +4276,5 @@ > PRUint32 skipStart = iter.ConvertOriginalToSkipped(fstart - offset); > PRUint32 skipEnd = iter.ConvertOriginalToSkipped(fend - offset); > aFontFaceList->AddFontsFromTextRun(textRun, > + offset + skipStart, > + skipEnd - skipStart, This can't be right, 'offset' is a DOM offset, and you're treating it as a textrun offset here. I think the problem is that you should be using the iterator returned from EnsureTextRun, which is set up with the right internal offsets for that text node.
Attachment #567992 - Flags: review?(roc) → review-
Ah, that makes much more sense - I was completely forgetting that EnsureTextRun could return something useful!
Attachment #567992 - Attachment is obsolete: true
Attachment #568322 - Flags: review?(roc)
Comment on attachment 568322 [details] [diff] [review] patch v2 - use the proper iterator to convert offsets Review of attachment 568322 [details] [diff] [review]: ----------------------------------------------------------------- needs a test too...
Attachment #568322 - Flags: review?(roc) → review+
Simple testcase using a string that wraps onto several lines; it fails without the patch here because it doesn't correctly find the Chinese font used to display the 你好 glyphs that are wrapped onto the second line.
Attachment #568423 - Flags: review?(roc)
Depends on: 736332
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: