Package java.awt.font

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


    @Override
    public GlyphMetrics getGlyphMetrics(){
        if (glMetrics == null) {
            float[] metrics = getGlyphMetrics(glyphPointer);
           
            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

   * @param unicodeFont The font this glyph forms part of
   */
  public Glyph(int codePoint, Rectangle bounds, GlyphVector vector, int index, UnicodeFont unicodeFont) {
    this.codePoint = codePoint;

    GlyphMetrics metrics = vector.getGlyphMetrics(index);
    int lsb = (int)metrics.getLSB();
    if (lsb > 0) lsb = 0;
    int rsb = (int)metrics.getRSB();
    if (rsb > 0) rsb = 0;

    int glyphWidth = bounds.width - lsb - rsb;
    int glyphHeight = bounds.height;
    if (glyphWidth > 0 && glyphHeight > 0) {
View Full Code Here

        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

        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

        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
                } else {
                    if (xDstSurf >= cMinX) {
                        clWidth = Math.min(textWidth, cMaxX - xDstSurf);
                    } else {
                        xSrcSurf += cMinX - xDstSurf;
                        clWidth = Math.min(cMaxX - cMinX, textWidth - (cMinX - xDstSurf));
                        xDstSurf = cMinX;
                    }
                    if (yDstSurf >= cMinY) {
                        clHeight = Math.min(textHeight, cMaxY - yDstSurf);
                    } else {
                        ySrcSurf += cMinY - yDstSurf;
                        clHeight = Math.min(cMaxY - cMinY, textHeight - (cMinY - yDstSurf));
                        yDstSurf = cMinY;
                    }

                    // Drawing on the Raster
                    for (int h=0; h<clHeight; h++){
                        for (int w=0; w < clWidth ; w++) {
                            byte currByte = data[(ySrcSurf + h)*gl.bmp_pitch + (xSrcSurf+w)/8];
                            boolean emptyByte = ((currByte & (1 << (7 - ((xSrcSurf+w) % 8)))) != 0);
                            if (emptyByte) {
                                raster.setDataElements(xDstSurf+w, yDstSurf+h, color);
                            } else {
                                // Nothing to do
                            }
                        }
                    }
                }
                xBaseLine += pointMetrics.getAdvanceX();
            }
        }
    }
View Full Code Here

            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

     */
    public final void testGlyphMetricsBooleanFloatFloatRectangle2DByte() {
        boolean horizontal = false;
        float advanceX = -5;
        float advanceY = 5;
        GlyphMetrics gm = new GlyphMetrics(horizontal, advanceX, advanceY, bounds, glyphType);
        assertEquals(bounds, gm.getBounds2D());
        assertEquals(advanceY, gm.getAdvance(), 0F);
        assertEquals(glyphType, gm.getType());
        assertEquals(advanceX, gm.getAdvanceX(), 0F);
        assertEquals(advanceY, gm.getAdvanceY(), 0F);
    }
View Full Code Here

    /*
     * Test method for 'java.awt.font.GlyphMetrics.GlyphMetrics(float, Rectangle2D, byte)'
     */
    public final void testGlyphMetricsFloatRectangle2DByte() {
        GlyphMetrics gm = new GlyphMetrics(advance, bounds, glyphType);
        assertEquals(bounds, gm.getBounds2D());
        assertEquals(advance, gm.getAdvance(), 0F);
        assertEquals(glyphType, gm.getType());
    }
View Full Code Here

    /*
     * Test method for 'java.awt.font.GlyphMetrics.getBounds2D()'
     */
    public final void testGetBounds2D() {
        GlyphMetrics gm = new GlyphMetrics(advance, bounds, GlyphMetrics.LIGATURE);
        assertEquals(bounds, gm.getBounds2D());
       
    }
View Full Code Here

TOP

Related Classes of java.awt.font.GlyphMetrics

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.