+ double sx = 1f * charWidth / fm.charsWidth(dc, 0, dc.length);
+ double sy = newHeight / asc;
+ double newAsc = asc * sy;
+ double newDec = dec * sy;
+ // it is not necessary to recalculated 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()]));
+
+ // original:
+
+ if (/** @j2sNative false && */ true) {
+ int hght = (int) (ht + (newAsc - newDec)); // Q: why " - newDec " ? (0,0) is on the font baseline, I think
+ Font font = ofont.deriveFont(AffineTransform.getScaleInstance(sx, sy));
+ g.setFont(font);
+ g.drawChars(dc, 0, dc.length, x * charWidth, hght);
+ ht += newHeight;
+ } else {
+ // SwingJS does not implement font.deriveFont()
+ // this is off by a very small amount.
+ int hght2 = (int) (ht2 + newAsc);
+ Graphics2D gg = (Graphics2D) g.create();
+ gg.setFont(ofont);
+ gg.transform(AffineTransform.getScaleInstance(sx, sy));
+ //System.out.println("sx " + sx + " sy " + sy + " " + hght + " " + lm.getDescent() + " " + dec + " " + newDec + " " + lm.getAscent() + " " + asc + " " + newAsc);
+ gg.drawString(s, (int) (x * charWidth / sx),
+ (int) (hght2 / sy));
+ gg.dispose();
+ ht2 += newHeight;
+ }
+