Re: [Fresco-devel] Text styles/cloning graphics
Stefan Seefeld <[email protected]>
| Newsgroups | gmane.comp.video.fresco.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Tobias,
Tobias Hunger wrote:
> Of course we would like to use decorators to encode the style of the glyphs.
> Basically we would like to use a table with entries like this (please suggest
> some better names;-):
>
> struct StyleItem {
> Graphic_ptr style;
> size_t start;
> size_t end;
> }
>
> with style being a decorator (or sequence of decorators) that are to be
> applied to the characters in range [start, end].
>
> Lets say we had this text: "The car is red." and this SytleItem { style =
> bold, start = 5, end = 8 }. We'd get something like this returned.
who is 'we' and what do you get this returned from ? Or, could you
please provide some more context as to the situation you'd want this
to be used ? (a html parser that generates a scene graph, an editor that
wants to change the style of a marked text range, a user who asks the
TextKit for a paragraph, etc...)
> hBox
> |
> +-+-+-+--+----+-+-+-+-+-+-+-+
> | | | | | | | | | | | | |
> T h e _ bold _ i s _ r e d .
> |
> hBox
> |
> +-+-+
> | | |
> c a r
>
> I think this is a very natural approach to use for Fresco. With a bit of work
> we could use this mechanism to include buttons to generate hyperlinks, etc.
> as sytling information!
>
> The problem is the following: There could be a linebreak happening inside a
> range covered by the style. This will result in a scenegraph layout like
> this:
>
> vBox
> |
> +---------...---------+
> | |
> hBox hBox
> | |
> +-...-+ +-...-+
> | | | |
> bold bold
> | |
> hBox hBox
> | |
> +-...-+ +-...-+
> | | | |
>
> You see the problem: We need to duplicate the 'bold' decorator!
right. But I think it's a bit early to jump to the conclusion that we
need a clone method. I don't yet fully understand the context in which
that could happen. Just 'clone' won't be enough, anyway. How do you
specify whether you want a shallow or a deep clone (or any specific
depth) ?
> How about making that possible with a clone() method on the Graphics? That
> might be useful for other things as well, don't you think? Or is the whole
> decorator approach wrong?
Dunno. It's not trivial, to say the least. An editor that lets you
change text style would just insert new decorator nodes, when done
naively, which results in undefined behavior if the style precedence
isn't well defined. But the real problem is that you don't have any
control over the 'style' nodes in the graph, i.e. you can't normalize
it, i.e. remove dead nodes (such as a 'blue' decorator wrapping a 'red'
decorator...).
How do other systems solve this ?
Regards,
Stefan