Bug 74787 - Need more information from TextLayout
Summary: Need more information from TextLayout
Status: RESOLVED DUPLICATE of bug 82104
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 74784
  Show dependency tree
 
Reported: 2004-09-23 11:39 EDT by Randy Hudson CLA
Modified: 2005-05-10 10:08 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2004-09-23 11:39:41 EDT
We need the ability to re-implement TextLayout.draw(GC,...).  TextLayout is 
only suitable for rendering text inside a rectangular region.  Sometimes the 
region is not rectangular, or there are other features in the text which must 
be rendered differently than provided.  Also, simulated scaling looks like crap 
when creating a "scaled" version of a TextLayout.

So, I think we need to be able to give a string, and get the nesting levels 
back.  Everything else we can do ourself such as measuring substrings and 
arranging/wrapping the lines.
Comment 1 Felipe Heidrich CLA 2004-10-13 14:34:15 EDT
Not clear what do you need.
Do you want an API that returns the embedding levels of each character of a 
string ? In this case use TextLayout#getLevel().

Note: After getting the levels you still need to reorder, shape, and then draw 
the string. 
Note: Just because a bunch of character have the same level it doesn't mean 
they can be shapped and drawn together (Japanese and English both have the 
same level).
Note: You still need to handle alignment, wrap, and justification manually.


Comment 2 Randy Hudson CLA 2004-10-13 14:57:36 EDT
calling getLevel() is too slow because I would have to call that for every 
character. I want some data structure back indicating ranges at the same 
level.  For example, the typical case is all characters are at level 1, so 
calling getLevel() N times would be bad performance.

What does "shaped and drawn together" mean? I'm not sure what shaping means. 
Are you saying I can't mix Katakana and English in a signel call to 
GC.drawString?

I understand that I must reorder the runs and lay them out correctly on the 
screen.
Comment 3 Felipe Heidrich CLA 2004-10-13 16:10:22 EDT
Shape is to transform the characters (unicode codes) into glyphs (glyph 
indices in a given font).  In this process is when people specify if arabic 
glyphs should assume initial, final, medial, isolate form for example.
In a group of character is very possible that you have two scripts in there 
that can not be shaped with the same font, so you need slipt the text in 
smaller parts (usually called "runs"). Likely you will need fallback font for 
each script, etc.

Anyhow, if you are using drawText() and textExtent() it should be fine cause 
in most platforms the OS will handle most of the work for you.

TextLayout will cache the level of all the characters in the first time 
something is asked to it, so the performance should be reasonable (unless 
something causes TextLayout to clear the cache, for example, adding a new 
attribute).



Comment 4 Randy Hudson CLA 2004-10-13 16:51:25 EDT
The performance will not be good.  First, TextLayout will actually perform a 
layout, which involves measuring text. I do not need this to happen. I only 
need itemize() to occur. I am going to re-measure everything myself once I know 
the "runs".

Second, the only API is character based.  If there are 1000 characters in a 
single run, then I will have to call getLevel() 1000 times.  What I want just 
some of the info in styleitems once itemize() has happened.

Imagine you are trying to render and layout a paragraph in which some 
characters can be images, widgets, etc.  Or, the paragraph must be layed-out 
inside an oval or something. Or some word must have a fat yellow border around 
it.
Comment 5 Randy Hudson CLA 2005-05-10 10:08:02 EDT
> TextLayout will cache the level of all the characters in the first time 
> something is asked to it, so the performance should be reasonable

Performance is not reasonable, see benchmark in 82104.

*** This bug has been marked as a duplicate of 82104 ***