Andreas,
Am 11.05.2008 um 16:25 schrieb Andreas Delmelle:
Support character-by-character font-selection strategy on
fo:character element
Good thinking!
FWIW, I've also been thinking in a similar direction, but maybe a
bit more generic, as utility method in the FontManager maybe (?)
yes, indeed. See the TODO comment in the code. The reason I
implemented it there were:
- proof-of-concept
- had no idea where it would really belong
The piece of code that you moved to a separate method here here was
indeed a temporary solution of my moving this logic out of the FO
tree, since I feel it did not really belong there. I just needed to
get the same behavior as before, when it was housed in CommonFont,
which always returned the first font-family in the list.
Thanks for that! This really helped getting this started
+ private Font selectFontForCharacter(Character fobj) {
Now that we have a FontManager, what if we add something to it like:
public Font selectFontForCharacter(FontTriplet[] triplets, char, int)
+1, what would be the int be for?
That way the loop in question finally moves to where I think it
actually belongs... and a similar approach could then be applied to
the TextLayoutManager. As an initial step, we could already make
sure that the selected font is always one that can display the first
character.
I don't like a "partial" implementation (the first character version)
For the textlayoutmanager: I saw that similar functionality in there
multiple times, for paragraphs, page-references, etc. They all seem
to create the same result, just based on content (paragraph) or
context (page-references). So the first step here would be to refactor
the common functionality out as well.
Now the real question is about the possible font selection stragety.
We'd have to implement "auto" and "characte-by-character"
they are defined as follow:
auto: is vendor-specific, but should use a "broader context"
char-by-char: select first font-match for evey character.
First the question is about line metrics: In a paragraph, we could use
- the line metrics for the font of the first char for the whole
paragraph -> easiest implementation, but the result may look bad
- the line metrics of all fonts used in a line (I have no idea how
that would work) -> best result
- the line metrics maximia for all fonts used in a paragraph (medium
to implement, medium result)
the next question is: what is auto-selection strategy?
would it be:
- select font based on the first character? now that i think about it,
I really like it - it would be really fast, and produce a correct
result IF the symbols are enclosed in their own fo:block
- select a font that can display the whole paragraph (if possible)
- switch for every word? This would probably give good results, but
may not make so much difference to char-by-char.
- make it the same as character-by-character? This would possibly be
slower, and produce some overhead, so its a bad idea for "default"
behavior.
hope this makes sense.
Andreas
Max