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 Manuel Mall <mm...@arcus.com.au> on 2005/09/20 15:37:22 UTC

text-altitude/-depth properties

This is probably a question for Finn.

I am looking into replacing the use font.getAscender() / 
font.getDescender() in the relevant LMs with the use of the appropriate 
properties text-altitude and text-depth. I would like to avoid having 
to write in all the LMs code like:

int textAltitude;
if (fobj.getTextAltitude().getEnum() == EN_USE_FONT_METRICS) {
   textAltitude = fobj.getCommonFont().....getAscender();
} else {
   textAltitude = fobj.getTextAltitude().getValue(this);
}

What's the best way to move this sort of logic into the property system 
so the LMs only need to call:
    textAltitude = fobj.getTextAltitude().getValue(this);
and the enum is resolved as part of the getValue call?

Thanks

Manuel

Re: text-altitude/-depth properties

Posted by Finn Bock <bc...@worldonline.dk>.
[Manuel]

> This is probably a question for Finn.
> 
> I am looking into replacing the use font.getAscender() / 
> font.getDescender() in the relevant LMs with the use of the appropriate 
> properties text-altitude and text-depth. I would like to avoid having 
> to write in all the LMs code like:
> 
> int textAltitude;
> if (fobj.getTextAltitude().getEnum() == EN_USE_FONT_METRICS) {
>    textAltitude = fobj.getCommonFont().....getAscender();
> } else {
>    textAltitude = fobj.getTextAltitude().getValue(this);
> }
> 
> What's the best way to move this sort of logic into the property system 
> so the LMs only need to call:
>     textAltitude = fobj.getTextAltitude().getValue(this);
> and the enum is resolved as part of the getValue call?

My gut feeling is that it should *not* be moved to the property system. 
Perhaps it should be placed in CommonFont which already has some of the 
intersection of properties and font state info. OTOH CommonFont is well 
defined and does not include text-altitude.

How about putting it on CommonFont as a static method:

static int getTextAltitude(Font font, Length textAltitude,
                     PercentBaseContext pbc) {
     if (textAltitude.getEnum() == EN_USE_FONT_METRICS) {
         return fs.getAscender();
     } else {
         return textAltitude.getValue(pbc);
     }

Or perhaps it should be placed in a "FontHelper" class in layoutmgr.

regards,
finn