You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Andreas Delmelle <an...@telenet.be> on 2008/05/11 16:25:12 UTC
Re: svn commit: r655281 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/FOPropertyMapping.java src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java status.xml
On May 11, 2008, at 11:01, maxberger@apache.org wrote:
Hi Max
> Author: maxberger
> Date: Sun May 11 02:01:31 2008
> New Revision: 655281
>
> URL: http://svn.apache.org/viewvc?rev=655281&view=rev
> Log:
> 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 (?)
> /** {@inheritDoc} */
> public void initialize() {
> - Character fobj = (Character)this.fobj;
> -
> - FontInfo fi = fobj.getFOEventHandler().getFontInfo();
> - FontTriplet[] fontkeys = fobj.getCommonFont().getFontState
> (fi);
> - font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont
> ().fontSize.getValue(this));
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.
> + 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)
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.
Just my 2 cents.
Anyone?
Andreas
Re: Font-Selection strategies (Re: svn commit: r655281 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/FOPropertyMapping.java src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java status.xml)
Posted by Andreas Delmelle <an...@telenet.be>.
On May 13, 2008, at 07:32, Max Berger wrote:
Hi Max
> <snip />
>>> + 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?
I just noticed that the font-size is being passed somewhere, but
maybe FontManager does not need it at all. (? to be verified...)
>>
>> 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)
All the better ;-)
> 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 second would, of course, be the better option. I'm hoping Manuel
chimes in later, as he has already been looking at this, and may have
some ideas to share.
As far as I remember from earlier discussions, the trickiest part
will be to keep track of changes in the alignment context as the font
changes. If we can manage that, the line-layout algorithm should
automatically take care of the rest.
> 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.
Auto-selection would, as mentioned, use a 'broader context'. The
difference is that, with "character-by-character", each character in
a word could be put in a different font (the first of the specified
families that has a glyph for it). With "auto" we could do something
clever like try to determine whether there is a font-family that can
display whole words (or entire paragraphs), which may lead to much
nicer-looking results (less font-switching -> better overall
alignment). If the first font-family only has a glyph for 2 out of 5
characters in a word, but the second has matching glyphs for all 5,
with a value of "auto" we could decide to use the second.
That said, getting "character-by-character" to work correctly would
already be vast improvement over the current situation, where we
don't look at the characters at all, and just use the first specified
font.
Cheers
Andreas
Font-Selection strategies (Re: svn commit: r655281 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/FOPropertyMapping.java src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java status.xml)
Posted by Max Berger <ma...@berger.name>.
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