Bug 131988 - TextLayout.setStyle(TextStyle, int, int) not working with StyleRange
Summary: TextLayout.setStyle(TextStyle, int, int) not working with StyleRange
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-15 12:25 EST by Dani Megert CLA
Modified: 2019-11-27 07:26 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2006-03-15 12:25:20 EST
I2006030314-0800

TextLayout.setStyle(TextStyle, int, int) is not working with StyleRange which is a public subclass of TextStyle. I could not find anything in the Javadoc which says it's not OK to use StyleRange here. However, when I use a StyleRange with some fontStyle it is simply ignored.
Comment 1 Felipe Heidrich CLA 2006-03-15 15:53:01 EST
That is right. TextLayout takes TextStyle, and TextStyle don't have fontStyle.
You can pass StyleRanges to TextLayout, it works fine. But StyleRange.start, StyleRange.length and StyleRange.fontStyle are not used (ignored).
See StyledTextRenderer#getStyleRange()  StyledTextRenderer#getFont() 

This that the only problem ? (fontStyle being ignored?)
Comment 2 Dani Megert CLA 2006-03-15 16:08:51 EST
Mmh - from an OO standpoint the current behavior is OK. I guess you can close this as a user error: I was used to use StyleRange and simply continued to use it when I had to do some computations using TextLayout and was then surprised that this thing didn't get bold even though I've set the fontStyle.

Feel free to close.
Comment 3 Felipe Heidrich CLA 2006-03-15 16:11:41 EST
closing.
Comment 4 Dani Megert CLA 2010-05-12 02:24:55 EDT
I'm reopening this either to reconsider ignoring the fontStyle or to make it very clear in the Javadoc. See bug 228397 comment 23 where another user tried to set the fontStyle on StyleRange and then legitimately expects to see it applied.
Comment 5 Andreas Fischl CLA 2013-10-06 05:51:08 EDT
Bug 350041 seems to be a duplicate of this bug (colors are fine; fontStyle works with a LineStyleListener but not with a StyledCellLabelProvider).

Besides, I second the previous commenters opinion: a user legitimately expects to se fontStyle applied.

Is there a workaround (e.g. by overwriting some methods in StyledCellLabelProvider)?
Comment 6 Andreas Fischl CLA 2013-10-06 06:42:39 EDT
Workaround: Set a new font (with the appropriate style) instead of using fontStyle.
Comment 7 Lars Vogel CLA 2019-11-27 07:26:15 EST
This bug hasn't had any activity in quite some time. Maybe the problem got
resolved, was a duplicate of something else, or became less pressing for some
reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it.
The information can be, for example, that the problem still occurs, that you
still want the feature, that more information is needed, or that the bug is
(for whatever reason) no longer relevant.

If the bug is still relevant, please remove the stalebug whiteboard tag.