double sy = newHeight / asc;
double newAsc = asc * sy;
double newDec = dec * sy;
- // it is not necessary to recalculated lm for the new font.
+ // it is not necessary to recalculate lm for the new font.
// note: lm.getBaselineOffsets()[lm.getBaselineIndex()]) must be 0
// by definition. Was:
- // int hght = (int) (ht + (newAsc - newDec - lm.getBaselineOffsets()[lm.getBaselineIndex()]));
+ // int hght = (int) (ht + (newAsc - newDec);
+ // - lm.getBaselineOffsets()[lm.getBaselineIndex()]));
- final int hght = (int) (ht + (newAsc - newDec));
if (Jalview.isJS())
{
/*
* so use a scaling transform to draw instead,
* this is off by a very small amount
*/
+ final int hght = (int) (ht2 + (newAsc - newDec));
Graphics2D gg = (Graphics2D) g.create();
gg.setFont(ofont);
- gg.translate(x*charWidth, hght);
+ int xShift = (int) (x * charWidth / sx);
+ int yShift = (int) (hght / sy);
gg.transform(AffineTransform.getScaleInstance(sx, sy));
- gg.drawString(s, 0, 0);
- gg.translate(-x*charWidth, -hght);
+ gg.drawString(s, xShift, yShift);
gg.dispose();
ht2 += newHeight;
}
else
{
+ final int hght = (int) (ht + (newAsc - newDec));
Font font = ofont
.deriveFont(AffineTransform.getScaleInstance(sx, sy));
g.setFont(font);