private void drawTextNative()

in fop-core/src/main/java/org/apache/fop/render/pcl/PCLPainter.java [417:502]


    private void drawTextNative(int x, int y, int letterSpacing, int wordSpacing, int[][] dp,
            String text, FontTriplet triplet) throws IOException {
        Color textColor = state.getTextColor();
        if (textColor != null) {
            gen.setTransparencyMode(true, false);
            if (getDocumentHandler().getPCLUtil().isColorEnabled()) {
                gen.selectColor(textColor);
            } else {
                gen.selectGrayscale(textColor);
            }
        }

        gen.setTransparencyMode(true, true);
        setCursorPos(x, y);

        float fontSize = state.getFontSize() / 1000f;
        Font font = getFontInfo().getFontInstance(triplet, state.getFontSize());
        int l = text.length();

        StringBuffer sb = new StringBuffer(Math.max(16, l));
        if (dp != null && dp[0] != null && dp[0][0] != 0) {
            if (dp[0][0] > 0) {
                sb.append("\u001B&a+").append(gen.formatDouble2(dp[0][0] / 100.0)).append('H');
            } else {
                sb.append("\u001B&a-").append(gen.formatDouble2(-dp[0][0] / 100.0)).append('H');
            }
        }
        if (dp != null && dp[0] != null && dp[0][1] != 0) {
            if (dp[0][1] > 0) {
                sb.append("\u001B&a-").append(gen.formatDouble2(dp[0][1] / 100.0)).append('V');
            } else {
                sb.append("\u001B&a+").append(gen.formatDouble2(-dp[0][1] / 100.0)).append('V');
            }
        }
        for (int i = 0; i < l; i++) {
            char orgChar = text.charAt(i);
            currentX += getCharWidth(i, font, orgChar, text);
            char ch;
            float xGlyphAdjust = 0;
            float yGlyphAdjust = 0;
            if (font.hasChar(orgChar)) {
                ch = font.mapChar(orgChar);
            } else {
                if (CharUtilities.isFixedWidthSpace(orgChar)) {
                    //Fixed width space are rendered as spaces so copy/paste works in a reader
                    ch = font.mapChar(CharUtilities.SPACE);
                    int spaceDiff = font.getCharWidth(ch) - font.getCharWidth(orgChar);
                    xGlyphAdjust = -(10 * spaceDiff / fontSize);
                } else {
                    ch = font.mapChar(orgChar);
                }
            }
            sb.append(ch);

            if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) {
                xGlyphAdjust += wordSpacing;
            }
            xGlyphAdjust += letterSpacing;
            if (dp != null && i < dp.length && dp[i] != null) {
                xGlyphAdjust += dp[i][2] - dp[i][0];
                yGlyphAdjust += dp[i][3] - dp[i][1];
            }
            if (dp != null && i < dp.length - 1 && dp[i + 1] != null) {
                xGlyphAdjust += dp[i + 1][0];
                yGlyphAdjust += dp[i + 1][1];
            }

            if (xGlyphAdjust != 0) {
                if (xGlyphAdjust > 0) {
                    sb.append("\u001B&a+").append(gen.formatDouble2(xGlyphAdjust / 100.0)).append('H');
                } else {
                    sb.append("\u001B&a-").append(gen.formatDouble2(-xGlyphAdjust / 100.0)).append('H');
                }
            }
            if (yGlyphAdjust != 0) {
                if (yGlyphAdjust > 0) {
                    sb.append("\u001B&a-").append(gen.formatDouble2(yGlyphAdjust / 100.0)).append('V');
                } else {
                    sb.append("\u001B&a+").append(gen.formatDouble2(-yGlyphAdjust / 100.0)).append('V');
                }
            }

        }
        gen.getOutputStream().write(sb.toString().getBytes(gen.getTextEncoding()));

    }