[Laszlo-dev] interesting background notes
cort at notebookmargins.com
Thu Jun 9 19:32:14 PDT 2005
When looking into what to do for richinputtext I examined some text systems.
Here is a summary of my notes.
Pango is a lib for layout and text rendering. It's the core of text and font
handling for GTK Internationalization support is a big goal of it and it has
some good thoughts in that regard.
The PangoAttrList structure represents a list of attributes that apply to a
section of text like the TextStyle Object. The attributes are, in general,
allowed to overlap in an arbitrary fashion, however, if the attributes are
manipulated only through pango_attr_list_change(), the overlap between
properties will meet stricter criteria.
Since the PangoAttrList structure is stored as a linear list, it is not
suggested for storing attributes for large amounts of text. In general, they
say you should not use a single PangoAttrList for more than one paragraph of
Frequently, you want to display some text to the user with attributes
applied to part of the text (for example, you might want bold or italicized
words). With the base Pango interfaces, you could create a PangoAttrList and
apply it to the text; the problem is that you'd need to apply attributes to
some numeric range of characters, for example "characters 12-17." This is
apparently broken from an internationalization standpoint; once the text is
translated, the word you wanted to italicize could be in a different
The solution is to include the text attributes in the string to be
translated. Pango provides this feature with a small markup language. You
can parse a marked-up string into the string text plus a PangoAttrList using
the function pango_parse_markup().
A simple example of a marked-up string might be: "<span foreground="blue"
size="x-large">Blue text</span> is <i>cool</i>!"
AttributeSet, creates sets of attributes like the TextStyle with basic set
operations(add, remove,contains,...) but only for read only operation
MutableAttributeSet, allow you to create custom attributes and add them and
delete them to AttributeSets, has a convienience implementation called
Style interface extends MutableAttributeSet, allows you to give an attribute
set a name and add and remove changeListeners
Attributes are categorized as character or paragraph attributes.
AttributesAtIndex returns a NSDictionary containing the attribute name and
values for characters at a specific index.
You can either get a string with the "string" method or a range with a
method called "effectiveRange".
You can call setAttributesInRange:range to change attribute values or
Use span's and classes with style objects like TextStyle that cascade down
the document structure.
Limitations of the Flash player
The Flash player's biggest limitation has always been with text, hopefully
that will change soon with v8, but there are never any quarantees. In
addition to the slowness of string operations, some things that we can not
do properly in a general way with individual text fields are
align = justified,
background color for just a portion of text
Aggregations of text fields can be used to implement these sorts of things
or special techniques can be used to support these sorts of things, but not
typically in a very general way. For example if someone has embeddend 4
versions of a font, one for each variation then one can implement
superscript, subscript or strikethrough for that font by using different
faces for each section of the text that needs to appear in it's
particularway, but it's not very general as you have to have those different
fonts created and embeded.
More information about the Laszlo-dev