Package org.apache.harmony.awt.gl.font

Examples of org.apache.harmony.awt.gl.font.WindowsFont


        CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
        int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
        int fontIndex = charFontIndex;

        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
        long font = physFont.getFontHandle();

        win32.SelectObject(hdc, font);

        int ascent = physFont.getAscent(); // Font ascent
        int offs = 0;       // width of substring with the same font header
        int yOffset = y - ascent; // Y offset to draw (y - font.ascent)
        int xOffset = x;    // X offset to draw
        int start = 0;
        int count = 0;
       
        for (int i=0; i < len; i++){
            char c = str.charAt(i);
            Glyph gl = wcf.getGlyph(c);

            int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
            if (glWidth ==0){
                continue;
            }

            fontIndex = wcf.getCharFontIndex(c, 0);
           
            if (fontIndex != charFontIndex){
                charFontIndex = fontIndex;
                win32.TextOutW(hdc, xOffset, yOffset,
                        str.substring(start, start + count), count);

                xOffset += offs;
                offs = 0;
                count = 1;
                start = i;

                physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
                font = physFont.getFontHandle();
                win32.SelectObject(hdc, font);
                yOffset = y - physFont.getAscent();
            } else {
                count++;
            }

            offs += glWidth;
View Full Code Here


    @SuppressWarnings("deprecation")
    public void gdipDrawNormalChars(Graphics2D g, Font fnt, char str[],
            int len, float x, float y) {
        long graphicsInfo = ((WinGDIPGraphics2D)g).getGraphicsInfo();

        WindowsFont wf = (WindowsFont)(fnt.getPeer());
        long font = wf.getFontHandle();
       
        char[] chars = new char[len];
        double positions[] = new double[len*2];
        double matrix[] = new double[6];
       
        AffineTransform at = new AffineTransform(fnt.getTransform());
        at.getMatrix(matrix);
        at.preConcatenate(AffineTransform.getTranslateInstance(x, y));

        float xPos = 0;
        float yPos = 0;
      
        int count = 0;
        for (int i=0; i < len; i++){
            char c = str[i];
            Glyph gl = wf.getGlyph(c);

            // We compare advances because width
            // of a char can be 0 (e.g. "Space" char)
            float advance = gl.getGlyphPointMetrics().getAdvance();
            if ( advance != 0){
View Full Code Here

       
        CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
        int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
        int fontIndex = charFontIndex;

        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
       
        long font = physFont.getFontHandle();
        float yPos = 0;    // Y position to draw (y - font.ascent)
        float xPos = 0;    // X position to draw
        int count = 0;

       
View Full Code Here

        y += trans.getTranslateY();

        win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
        win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);
       
        WindowsFont wf = (WindowsFont)gv.getFont().getPeer();

        int ascent = wf.getAscent();
        long font = wf.getFontHandle();
        long oldFont = win32.SelectObject(hdc, font);

        for (int i=0; i < gv.getNumGlyphs(); i++){
            Glyph gl = ((CommonGlyphVector)gv).vector[i];
            char chr = gl.getChar();
View Full Code Here

        AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform();

        x += (int)Math.round(trans.getTranslateX());
        y += (int)Math.round(trans.getTranslateY());

        WindowsFont wf = (WindowsFont)(g.getFont().getPeer());
        long font = wf.getFontHandle();
       
        long gi = ((WinGDIPGraphics2D)g).getGraphicsInfo();
        long hdc = NativeFont.gdiPlusGetHDC(gi);

        win32.SelectObject(hdc, font);

        win32.SetTextColor(hdc, getGDIColor(g.getColor().getRGB()));
        win32.SetBkMode(hdc, WindowsDefs.TRANSPARENT);

        /*
         * Work around for escape-subsequences. If e.g. we draw
         * string "\n\uFFFF" - instead of default glyph for \uFFFF
         * GDI draws small vertical rectangle. For this reason we draw
         * chars one by one to avoid this situation.
         *
         * GDI draws all glyphs starting from 0. First 32 glyphs are taken from
         * another font, hence we have to check if the glyph exists in chosen
         * font and if success draw it, otherwise we draw default glyph,
         * except esc-subsequence chars.
         * */
        char[] chars = new char[str.length()];
        int j = 0;
        for (int i=0; i < str.length(); i++){
            char c = str.charAt(i);
            Glyph gl = wf.getGlyph(c);

            // We compare Advances because Width
            // of a char can be 0 (e.g. "Space" char)
            if (gl.getGlyphMetrics().getAdvance() != 0){
                chars[j] = gl.getChar();
                j++;
            }
        }
        String out = new String(chars, 0, j);

        win32.TextOutW(hdc, x, y - wf.getAscent(), out, j);
        NativeFont.gdiPlusReleaseHDC(gi, hdc);

    }
View Full Code Here

        CompositeFont wcf = (CompositeFont)(g.getFont().getPeer());
        int charFontIndex = wcf.getCharFontIndex(str.charAt(0), 0);
        int fontIndex = charFontIndex;

        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
        long font = physFont.getFontHandle();

        win32.SelectObject(hdc, font);

        int ascent = physFont.getAscent(); // Font ascent
        int offs = 0;       // width of substring with the same font header
        int yOffset = y - ascent; // Y offset to draw (y - font.ascent)
        int xOffset = x;    // X offset to draw
        int start = 0;
        int count = 0;
       
        for (int i=0; i < len; i++){
            char c = str.charAt(i);
            Glyph gl = wcf.getGlyph(c);

            int glWidth = Math.round(gl.getGlyphPointMetrics().getAdvance());
            if (glWidth ==0){
                continue;
            }

            fontIndex = wcf.getCharFontIndex(c, 0);
           
            if (fontIndex != charFontIndex){
                charFontIndex = fontIndex;
                win32.TextOutW(hdc, xOffset, yOffset,
                        str.substring(start, start + count), count);

                xOffset += offs;
                offs = 0;
                count = 1;
                start = i;

                physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
                font = physFont.getFontHandle();
                win32.SelectObject(hdc, font);
                yOffset = y - physFont.getAscent();
            } else {
                count++;
            }

            offs += glWidth;
View Full Code Here

            gdipDrawNormalChars(g, gv.getFont(),
                    ((CommonGlyphVector)gv).charVector, len, x, y);
            return;
        }

        WindowsFont wf = (WindowsFont)gv.getFont().getPeer();
        long font = wf.getFontHandle();
        AffineTransform fontAT = gv.getFont().getTransform();

        double matrix[] = new double[6];
        double fontMatrix[] = new double[6];
        char chars[] = new char[len];
View Full Code Here

        int size = len;
        double positions[] = new double[size*2];
        char chars[] = new char[size];
        int count = 0;
        WindowsFont physFont = (WindowsFont)wcf.fPhysicalFonts[charFontIndex];
       
        long font = physFont.getFontHandle();

        AffineTransform fontAT = fnt.getTransform();

        double matrix[] = new double[6];
        double fontMatrix[] = new double[6];
View Full Code Here

     */
    @SuppressWarnings("deprecation")
    public void gdipDrawNormalString(Graphics2D g, String str, float x, float y) {
        long graphicsInfo = ((WinGDIPGraphics2D)g).getGraphicsInfo();

        WindowsFont wf = (WindowsFont)(g.getFont().getPeer());
        long font = wf.getFontHandle();
        int len = str.length();
       
        char[] chars = new char[len];
        double positions[] = new double[len*2];
        double matrix[] = new double[6];
        AffineTransform at = new AffineTransform(g.getFont().getTransform());
        at.getMatrix(matrix);

        float xPos = 0;
        float yPos = 0;
      
        int count = 0;
        for (int i=0; i < len; i++){
            char c = str.charAt(i);
            Glyph gl = wf.getGlyph(c);

            // We compare Advances because Width
            // of a char can be 0 (e.g. "Space" char)
            float advance = gl.getGlyphPointMetrics().getAdvance();
            if ( advance != 0){
View Full Code Here

TOP

Related Classes of org.apache.harmony.awt.gl.font.WindowsFont

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.