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

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


        float xPos = 0;    // X position to draw
        int count = 0;

       
        for (int i=0; i < len; i++){
            Glyph gl = wcf.getGlyph(str.charAt(i));

            int advance = (int)(gl.getGlyphPointMetrics().getAdvance());
            if (advance ==0){
                continue;
            }
            char c = gl.getChar();

            fontIndex = wcf.getCharFontIndex(c, 0);
           
            if (fontIndex != charFontIndex) {
                charFontIndex = fontIndex;
               
                at.transform(positions, 0, positions, 0, count);

                int status = NativeFont.gdiPlusDrawDriverChars(graphicsInfo,
                        chars,
                        count,
                        font,
                        positions,
                        NativeFont.DriverStringOptionsCmapLookup,
                        matrix);
                if (status != 0 && debugOutput){
                    System.err.println("GDIPlus DrawDriverString error status = " +
                            status);
                }

                count = 0;
                font = gl.getPFont();
            }
            chars[count] = c;
            positions[count*2] = xPos;
            positions[count*2 + 1] = yPos;

View Full Code Here


    public int getMissingGlyphCode() {
        return getDefaultGlyph().getGlyphCode();
    }

    public Glyph getGlyph(char index) {
        Glyph result = null;

        Object key = new Integer(index);
        if (glyphs.containsKey(key)) {
            result = (Glyph) glyphs.get(key);
        } else {
View Full Code Here

        return result;
    }

    public Glyph getDefaultGlyph() {
        Glyph result;
        Object key = new Integer(defaultChar);
        if (glyphs.containsKey(key)) {
            result = (Glyph) glyphs.get(key);
        } else {
            if (this.fontType == FontManager.FONT_TYPE_T1){
View Full Code Here

        int xSrcSurf, ySrcSurf; // Start point in String rectangle
        int xDstSurf, yDstSurf; // Start point in Surface rectangle
        int clWidth, clHeight;

        for (int i = 0; i < glyphVector.getNumGlyphs(); i++) {
            Glyph gl = ((CommonGlyphVector) glyphVector).vector[i];

            if (gl.getPointWidth() == 0) {
                continue;
            }

            byte[] data = gl.getBitmap();
            if (data != null) {
                Point2D pos = glyphVector.getGlyphPosition(i);

                xSrcSurf = 0;//gl.bmp_left;
                ySrcSurf = 0;//gl.bmp_rows - gl.bmp_top;

                xDstSurf = x + (int)pos.getX() + (int) gl.getGlyphPointMetrics().getLSB();// + gl.bmp_left;
                yDstSurf = y - gl.bmp_top/*getPointHeight()*/  + (int) pos.getY();// - (gl.bmp_rows-gl.bmp_top);

                int textWidth = gl.bmp_width;
                int textHeight = gl.getPointHeight();

                // if Regions don't intersect
                if ((xDstSurf > cMaxX) || (yDstSurf > cMaxY) || (xDstSurf + textWidth < cMinX)
                        || (yDstSurf + textHeight < cMinY)) {
                    // Nothing to do
View Full Code Here

        int xBaseLine = x;
        int yBaseLine = y;

        for (char element : chars) {
            Glyph gl = font.getGlyph(element);
            GlyphMetrics pointMetrics = gl.getGlyphPointMetrics();
            if (gl.getWidth() == 0) {
                xBaseLine += pointMetrics.getAdvanceX();
                continue;
            }

            byte[] data = gl.getBitmap();
            if (data == null) {
                xBaseLine += pointMetrics.getAdvanceX();
            } else {

                xSrcSurf = 0;
                ySrcSurf = 0;

                xDstSurf = Math.round(xBaseLine + gl.getGlyphPointMetrics().getLSB());
                yDstSurf = yBaseLine - gl.bmp_top;

                int textWidth = gl.bmp_width;
                int textHeight = gl.getPointHeight();

                // if Regions don't intersect
                if ((xDstSurf > cMaxX) || (yDstSurf > cMaxY) || (xDstSurf + textWidth < cMinX)
                        || (yDstSurf + textHeight < cMinY)) {
                    // Nothing to do
View Full Code Here

     * doesn't exist in the WindowsFont 
     * @param index the specified character
     */
    @Override
    public Glyph getGlyph(char index) {
        Glyph result = null;
        Integer key = Integer.valueOf(index);
        if (glyphs.containsKey(key)) {
            result = glyphs.get(key);
        } else {
            if (this.addGlyph(index)) {
View Full Code Here

    /**
     * Returns default Glyph object of this WindowsFont.
     */
    @Override
    public Glyph getDefaultGlyph() {
        Glyph result;
        Integer defaultKey = Integer.valueOf(defaultChar);

        if (glyphs.containsKey(defaultKey)) {
            result = glyphs.get(defaultKey);
        } else {
View Full Code Here

     * @param y start Y position to draw
     */
    public void drawString(Graphics2D g, String str, float x, float y) {       
        char[] input = str.toCharArray();
        Character ch;
        Glyph glyph;
        DLInfo info;
        GlyphMetrics glMetrics;
        Color col = g.getColor();
        Font font = g.getFont();       
        int length = str.length();
        FontPeerImpl peer = ((FontPeerImpl)font.getPeer());
        AffineTransform fontAT = (AffineTransform)font.getTransform().clone();
        Point.Float pos = new Point.Float();
        Paint paint = g.getPaint();
        boolean isAntialias = g.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING) == RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
       
        try {
            fontAT.inverseTransform(new Point.Double(x + fontAT.getTranslateX(), y + fontAT.getTranslateY()), pos);
        } catch (NoninvertibleTransformException e) {  
//          TODO determinant equals 0 => point or line
            g.fill(font.createGlyphVector(g.getFontRenderContext(), str).getOutline(x, y));
            return;
        }
       
        fontAT.translate(pos.x,pos.y);
        g.transform(fontAT);
       
        HashCode hash = new HashCode();
        hash.append(peer);
        hash.append(getFactor(g.getTransform()));
        hash.append(paint);
        hash.append(isAntialias);
        Integer intHash = new Integer(hash.hashCode());
       
        GlyphHashtable glyphHash =
            intHash2glyphHash.containsKey(intHash) ?
                    (GlyphHashtable) intHash2glyphHash.get(intHash) : null;
        if ( glyphHash == null) {
            glyphHash = new GlyphHashtable();
            intHash2glyphHash. put(intHash, glyphHash);
        }
       
        activateVars();       
       
        for (int i = 0; i - length < 0; i ++) {
            ch = new Character(input[i]);
            if (ESCAPE.contains(ch)) continue;
            glyph = peer.getGlyph(input[i]);
           
            if (ch == ' ') {
                glMetrics = glyph.getGlyphPointMetrics();
                gl.glTranslated(
                        glMetrics.getAdvanceX(),
                        glMetrics.getAdvanceY(),
                        0
                );
                continue;
            }
           
            info = glyphHash.containsKey(ch) ? (DLInfo)glyphHash.get(ch) : null;
           
            if (info == null || !info.isValid()) {
                createColorGlyphDL(g, glyph, glyphHash, font, ch, col, isAntialias);
            } else {
                gl.glCallList(info.getDL());
            }           
           
            glMetrics = glyph.getGlyphPointMetrics();
            gl.glTranslated(
                    glMetrics.getAdvanceX(),
                    glMetrics.getAdvanceY(),
                    0
            );           
View Full Code Here

            throw new NullPointerException(Messages.getString("awt.296"));
        }       
            
        double texSize = getFactor(g.getTransform());
       
        Glyph newGlyph = ((FontPeerImpl)(font.deriveFont(
                (float)(font.getSize2D() * texSize))).getPeer())
                .getGlyph(ch.charValue());
       
        byte[] pixels = newGlyph.getBitmap();
       
        BufferedImage bim = getBufImg(
                pixels,
                newGlyph.getPointWidth(),
                newGlyph.getPointHeight(),
                col
                );
       
        Rectangle.Double rect = new Rectangle.Double(
                Math.round(glyph.getGlyphPointMetrics().getLSB()),
View Full Code Here

     * @param y start Y position to draw
     */
    public void drawString(Graphics2D g, String str, float x, float y) {       
        char[] input = str.toCharArray();
        Character ch;
        Glyph glyph;
        DLInfo info;
        GlyphMetrics glMetrics;
        Color col = g.getColor();
        Font font = g.getFont();       
        int lenght = str.length();
        FontPeerImpl peer = ((FontPeerImpl)font.getPeer());
        AffineTransform fontAT = (AffineTransform)font.getTransform().clone();
        Point.Float pos = new Point.Float();
        Paint paint = g.getPaint();
        boolean isAntialias = g.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING) == RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
       
        try {
            fontAT.inverseTransform(new Point.Double(x + fontAT.getTranslateX(), y + fontAT.getTranslateY()), pos);
        } catch (NoninvertibleTransformException e) {  
//          TODO determinant equals 0 => point or line
            g.fill(font.createGlyphVector(g.getFontRenderContext(), str).getOutline(x, y));
            return;
        }
       
        fontAT.translate(pos.x,pos.y);
        g.transform(fontAT);
       
        HashCode hash = new HashCode();
        hash.append(peer);
        hash.append(getFactor(g.getTransform()));
        hash.append(paint);
        hash.append(isAntialias);
        Integer intHash = new Integer(hash.hashCode());
       
        GlyphHashtable glyphHash =
            intHash2glyphHash.containsKey(intHash) ?
                    (GlyphHashtable) intHash2glyphHash.get(intHash) : null;
        if ( glyphHash == null) {
            glyphHash = new GlyphHashtable();
            intHash2glyphHash. put(intHash, glyphHash);
        }
       
        activateVars();       
       
        for (int i = 0; i - lenght < 0; i ++) {
            ch = new Character(input[i]);
            if (ESCAPE.contains(ch)) continue;
            glyph = peer.getGlyph(input[i]);
           
            if (ch == ' ') {
                glMetrics = glyph.getGlyphPointMetrics();
                gl.glTranslated(
                        glMetrics.getAdvanceX(),
                        glMetrics.getAdvanceY(),
                        0
                );
                continue;
            }
           
            info = glyphHash.containsKey(ch) ? (DLInfo)glyphHash.get(ch) : null;
           
            if (info == null || !info.isValid()) {
                createColorGlyphDL(g, glyph, glyphHash, font, ch, col, isAntialias);
            } else {
                gl.glCallList(info.getDL());
            }           
           
            glMetrics = glyph.getGlyphPointMetrics();
            gl.glTranslated(
                    glMetrics.getAdvanceX(),
                    glMetrics.getAdvanceY(),
                    0
            );           
View Full Code Here

TOP

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

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.