Search in sources :

Example 36 with GlyphVector

use of java.awt.font.GlyphVector in project android_frameworks_base by crdroidandroid.

the class BidiRenderer method render.

/**
     * Renders the text to the right of the bounds with the given font.
     * @param font The font to render the text with.
     */
private void render(int start, int limit, Font font, int flag, float[] advances, int advancesIndex, boolean draw) {
    FontRenderContext frc;
    if (mGraphics != null) {
        frc = mGraphics.getFontRenderContext();
    } else {
        frc = Toolkit.getDefaultToolkit().getFontMetrics(font).getFontRenderContext();
        // Metrics obtained this way don't have anti-aliasing set. So,
        // we create a new FontRenderContext with anti-aliasing set.
        frc = new FontRenderContext(font.getTransform(), mPaint.isAntiAliased(), frc.usesFractionalMetrics());
    }
    GlyphVector gv = font.layoutGlyphVector(frc, mText, start, limit, flag);
    int ng = gv.getNumGlyphs();
    int[] ci = gv.getGlyphCharIndices(0, ng, null);
    if (advances != null) {
        for (int i = 0; i < ng; i++) {
            int adv_idx = advancesIndex + ci[i];
            advances[adv_idx] += gv.getGlyphMetrics(i).getAdvanceX();
        }
    }
    if (draw && mGraphics != null) {
        mGraphics.drawGlyphVector(gv, mBounds.right, mBaseline);
    }
    // Update the bounds.
    Rectangle2D awtBounds = gv.getLogicalBounds();
    RectF bounds = awtRectToAndroidRect(awtBounds, mBounds.right, mBaseline);
    // coordinates from the bounds as an offset.
    if (Math.abs(mBounds.right - mBounds.left) == 0) {
        mBounds = bounds;
    } else {
        mBounds.union(bounds);
    }
}
Also used : GlyphVector(java.awt.font.GlyphVector) Rectangle2D(java.awt.geom.Rectangle2D) FontRenderContext(java.awt.font.FontRenderContext)

Aggregations

GlyphVector (java.awt.font.GlyphVector)36 FontRenderContext (java.awt.font.FontRenderContext)18 Font (java.awt.Font)8 Graphics2D (java.awt.Graphics2D)8 Rectangle (java.awt.Rectangle)7 Rectangle2D (java.awt.geom.Rectangle2D)7 BufferedImage (java.awt.image.BufferedImage)5 Shape (java.awt.Shape)3 AffineTransform (java.awt.geom.AffineTransform)3 BasicStroke (java.awt.BasicStroke)2 FontMetrics (java.awt.FontMetrics)2 Image (java.awt.Image)2 Paint (java.awt.Paint)2 TextLayout (java.awt.font.TextLayout)2 Point2D (java.awt.geom.Point2D)2 Map (java.util.Map)2 Texture (com.badlogic.gdx.graphics.Texture)1 FontInfo (com.intellij.openapi.editor.impl.FontInfo)1 AbstractMockGlyphVector (com.intellij.testFramework.AbstractMockGlyphVector)1 MockFontLayoutService (com.intellij.testFramework.MockFontLayoutService)1