int stringWidth = (int) Math.ceil(c.getTextRenderer(). getLogicalBounds(c.getGraphics(), c.getGraphics().getFont(), text).getWidth());   IdentValue decoration = c.getCurrentStyle().getIdent(CSSName.TEXT_DECORATION);  if (decoration == IdentValue.UNDERLINE) { float down = lm.getUnderlineOffset(); float thick = lm.getUnderlineThickness();    g.fillRect(ix, iy - (int) down + 2, stringWidth, (int) thick); } else if (decoration == IdentValue.LINE_THROUGH) { float down = lm.getStrikethroughOffset(); float thick = lm.getStrikethroughThickness(); g.fillRect(ix, iy + (int) down, stringWidth, (int) thick); } else if (decoration == IdentValue.OVERLINE) { float down = lm.getAscent(); float thick = lm.getUnderlineThickness(); g.fillRect(ix, iy - (int) down, stringWidth, (int) thick); }
    public static void paintText(Context c, int ix, int iy, InlineTextBox inline, LineMetrics lm) {        String text = inline.getSubstring();        Graphics g = c.getGraphics();        //adjust font for current settings        Font oldfont = c.getGraphics().getFont();        c.getGraphics().setFont(FontUtil.getFont(c));        Color oldcolor = c.getGraphics().getColor();        c.getGraphics().setColor(c.getCurrentStyle().getColor());        //baseline is baseline! iy -= (int) lm.getDescent();        //draw the line        if (text != null && text.length() > 0) {            c.getTextRenderer().drawString(c.getGraphics(), text, ix, iy);        }        //draw any text decoration        int stringWidth = (int) Math.ceil(c.getTextRenderer().                getLogicalBounds(c.getGraphics(),                        c.getGraphics().getFont(),                        text).getWidth());        // override based on settings        IdentValue decoration = c.getCurrentStyle().getIdent(CSSName.TEXT_DECORATION);        if (decoration == IdentValue.UNDERLINE) {            float down = lm.getUnderlineOffset();            float thick = lm.getUnderlineThickness();                        // correct the vertical pos of the underline by 2px, as without that             // the underline sticks right against the text.            g.fillRect(ix, iy - (int) down + 2, stringWidth, (int) thick);        } else if (decoration == IdentValue.LINE_THROUGH) {            float down = lm.getStrikethroughOffset();            float thick = lm.getStrikethroughThickness();            g.fillRect(ix, iy + (int) down, stringWidth, (int) thick);        } else if (decoration == IdentValue.OVERLINE) {            float down = lm.getAscent();            float thick = lm.getUnderlineThickness();            g.fillRect(ix, iy - (int) down, stringWidth, (int) thick);        }        c.getGraphics().setColor(oldcolor);        if (c.debugDrawFontMetrics()) {            g.setColor(Color.red);            g.drawLine(ix, iy, ix + inline.width, iy);            iy += (int) Math.ceil(lm.getDescent());            g.drawLine(ix, iy, ix + inline.width, iy);            iy -= (int) Math.ceil(lm.getDescent());            iy -= (int) Math.ceil(lm.getAscent());            g.drawLine(ix, iy, ix + inline.width, iy);        }        // restore the old font        c.getGraphics().setFont(oldfont);    }