Community
Participate
Working Groups
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.
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.
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.
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).
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.
> 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 ***