[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freetype] The text layout pipeline
From: |
Paul Pedriana |
Subject: |
[Freetype] The text layout pipeline |
Date: |
Wed, 27 Oct 2004 01:12:45 -0700 (PDT) |
I am trying to understand the complete text layout
pipeline. I think I have it figured out and would like
to present my view of it here. If anybody could
correct any problems with it or provide any additional
insight, I would greatly appreciate it. Sorry about
the
odd wrapping here, but my lamo free Yahoo email does
this. :(
1. Divide text into paragraphs.
* A paragraph is delimited by newline
characters or is simply any self-contained
text.
2. Divide the paragraph into runs of same script
and direction.
* These runs are given a direction embedding
level, based on Unicode TR9.
* It's not necessary that new paragraph
strings be created, it's only necessary to
know the run information.
* This step is only necessary if there is
complex script in the paragraph.
3. Split each of the above runs into runs of
same font style.
* If text is all of the same style but you need
multiple fonts to support the characters,
then split based on the font differences.
Note that this may require looking ahead to
the shaping phase to see if your font has
alternative ways of supporting a character
(e.g. a + ` instead of just à).
* This step is only necessary if multiple
styles are supported or substitution fonts
are supported.
4. Do shaping of text.
* This means making a new version of the
paragraph text which has the actual
characters used in display of the text.
* It will be useful or necessary to provide
a way to map items from this string back
to the original string.
* Use font info to decide if you can merge
characters (e.g. à instead of a + `) or
need to split characters (e.g. a + `
instead of just à).
* Do script-specific modifications, such as
Thai decoration substitutions and Arabic
contextual substitutions.
* Don't do insertions or removals of kashidas
or other characters which would be part of
justification of lines.
* No reordering is done here; the text is
shaped in logical order (not visual order).
* This step is only necessary if there is
complex script in the paragraph.
5. Do line breaking.
* Line breaking is done based on Unicode TR7,
with a dictionary approach for Thai.
* Line breaking is based on the shaped
character text, not the original text.
* Line breaking is done on the entire
paragraph and not individual runs.
* Line breaking is done based on the advance
widths of the shaped character text in
logical order (not visual order) and before
reordering is done.
* It seems to me that glyphs with strange
advance widths could cause this to do
imperfect breaking.
* This step is only necessary if the text
needs to wrap within some boundary.
6. Apply justification.
* This means inserting spaces and/or kashidas
between words and/or characters.
* This either generates a new set of advance
widths and/or inserts space and/or kashida
characters.
* This step is only necessary if the text is
justified (stretched to fit its bounds).
7. Generate a display list.
* This is based on the font's glyph metrics
and texture (bitmap) metrics.
* Information about font coloring or any
other rendering or texture shading settings
would be associated with this display list.
* Algorithmic effects such as underlines and
strikethroughs would be associated with this
display list.
* This step is only necessary if you need to
draw the text.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
- [Freetype] The text layout pipeline,
Paul Pedriana <=