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.


Reply via email to