Examples of GlyphMetrics


Examples of java.awt.font.GlyphMetrics

     */
    public GVTGlyphMetrics(float horizontalAdvance,
                           float verticalAdvance,
                           Rectangle2D bounds,
                           byte glyphType) {
        this.gm = new GlyphMetrics(horizontalAdvance, bounds, glyphType);
        this.verticalAdvance = verticalAdvance;
    }
View Full Code Here

Examples of java.awt.font.GlyphMetrics

                   vb.getMinY() - pt.getY(),
                   vb.getWidth(),
                   vb.getHeight());
        Point2D.Float adv =
            getGlyphStrike(ix).strike.getGlyphMetrics(glyphs[ix]);
        GlyphMetrics gm = new GlyphMetrics(true, adv.x, adv.y,
                                           vb,
                                           GlyphMetrics.STANDARD);
        return gm;
    }
View Full Code Here

Examples of java.awt.font.GlyphMetrics

        }

        public void runTest(Object ctx, int numReps) {
            GVContext gvctx = (GVContext)ctx;
            GlyphVector gv = gvctx.gv;
            GlyphMetrics gm;
            do {
                for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
                    gm = gv.getGlyphMetrics(i);
                }
            } while (--numReps >= 0);
View Full Code Here

Examples of java.awt.font.GlyphMetrics

        Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                        -metrics[1],
                                                        metrics[4],
                                                        metrics[5]);
        this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);
        this.glCode = glyphIndex;
        this.glChar = c;

        Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                        -pxlMetrics[1],
                                                        pxlMetrics[4],
                                                        pxlMetrics[5]);
        this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
    }
View Full Code Here

Examples of java.awt.font.GlyphMetrics

        Rectangle2D.Float rect  = new Rectangle2D.Float(metrics[0],
                                                        -metrics[1],
                                                        metrics[4],
                                                        metrics[5]);
        this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);

        this.glCode = glyphIndex;
        this.glChar = c;

        Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                        -pxlMetrics[1],
                                                        pxlMetrics[4],
                                                        pxlMetrics[5]);
        this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
    }
View Full Code Here

Examples of java.awt.font.GlyphMetrics

    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
            );           
           
        }
        deactivateVars();
View Full Code Here

Examples of java.awt.font.GlyphMetrics

            int advance = 0;

            GlyphVector gv = font.createGlyphVector(frc, new char[]{referenceChar});
            java.awt.Shape glyphOutline = gv.getGlyphOutline(0);

            GlyphMetrics metrics = gv.getGlyphMetrics(0);
            advance = (int)Math.rint(metrics.getAdvance()); //Do not scale here, DefineText needs values unscaled

            java.awt.Shape scaledShape = scaleTransform.createTransformedShape(glyphOutline);
            swfShape = createGlyphShape(scaledShape);

            GlyphEntry ge = new GlyphEntry();
View Full Code Here

Examples of java.awt.font.GlyphMetrics

            float[] metrics = getGlyphMetrics(glyphPointer);
           
//            System.out.println("x = " + metrics[0] + ", y = " + metrics[1]);
//            System.out.println("after x = " + Math.round(metrics[0]) + ", y = " + Math.round(metrics[1]));
           
            this.glMetrics = new GlyphMetrics(
                    true,
                    Math.round(metrics[0]),//metrics[0],
                    Math.round(metrics[1]),//metrics[1],
                    //new Rectangle2D.Double(initOutline().getBounds2D().getMinX(), initOutline().getBounds2D().getMinY(), initOutline().getBounds2D().getMaxX() + 5, initOutline().getBounds2D().getMaxY()),                   
                    initOutline().getBounds2D(),//new Rectangle2D.Float(metrics[2], -metrics[5]-1,metrics[4]- metrics[2] + 1, metrics[5] - metrics[3] + 1),
View Full Code Here

Examples of java.awt.font.GlyphMetrics

    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
            );           
           
        }
        deactivateVars();
View Full Code Here

Examples of java.awt.font.GlyphMetrics

        Rectangle rct  = new Rectangle(pxlMetrics[0],
                                                        -pxlMetrics[1],
                                                        pxlMetrics[4],
                                                        pxlMetrics[5]);

        this.glPointMetrics = new GlyphMetrics(pxlMetrics[2], rct, (byte)1);
        this.glMetrics = new GlyphMetrics((float)Math.ceil(pxlMetrics[2]), rct, (byte)0);

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.