Java Code Examples for java.awt.font.GlyphVector#getNumGlyphs()

The following examples show how to use java.awt.font.GlyphVector#getNumGlyphs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathGraphics.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: PathGraphics.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 3
Source File: PathGraphics.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 4
Source File: PathGraphics.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 5
Source File: PathGraphics.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 6
Source File: PathGraphics.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 7
Source File: PathGraphics.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private boolean samePositions(GlyphVector gv, int[] gvcodes,
                              int[] origCodes, float[] origPositions) {

    int numGlyphs = gv.getNumGlyphs();
    float[] gvpos = gv.getGlyphPositions(0, numGlyphs, null);

    /* this shouldn't happen here, but just in case */
    if (numGlyphs != gvcodes.length ||  /* real paranoia here */
        origCodes.length != gvcodes.length ||
        origPositions.length != gvpos.length) {
        return false;
    }

    for (int i=0; i<numGlyphs; i++) {
        if (gvcodes[i] != origCodes[i] || gvpos[i] != origPositions[i]) {
            return false;
        }
    }
    return true;
}
 
Example 8
Source File: DirectArrowDrawer.java    From ReactionDecoder with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawText(Graphics2D g, String text, Point2d c, Vector2d v, Vector2d nV) {
    AffineTransform originalTransform = g.getTransform();
    double angle = getAngle(v);

    Rectangle2D textBounds = getTextBounds(g, text);
    double distance = textBounds.getWidth() / 2;
    Point2d start = new Point2d(c.x, c.y);
    if (angle < toRadians(90) || angle > toRadians(270)) {
        start.scaleAdd(distance, nV, c);
    } else {
        start.scaleAdd(distance, v, c);
        double angDeg = (180 + toDegrees(angle)) % 360;
        angle = toRadians(angDeg);
    }

    g.translate(start.x, start.y);
    g.rotate(angle);

    Font font = g.getFont();
    FontRenderContext frc = g.getFontRenderContext();
    GlyphVector gv = font.createGlyphVector(frc, text);
    int length = gv.getNumGlyphs();
    for (int i = 0; i < length; i++) {
        g.fill(gv.getGlyphOutline(i));
    }

    g.rotate((2 * PI) - angle);
    g.setTransform(originalTransform);
}
 
Example 9
Source File: TextMeasureTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    AffineTransform tx;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            tx = gv.getGlyphTransform(i);
        }
    } while (--numReps >= 0);
}
 
Example 10
Source File: TextMeasureTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Rectangle2D r;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            r = gv.getGlyphPixelBounds(i, null, 0, 0); // !!! add opt to provide different frc?
        }
    } while (--numReps >= 0);
}
 
Example 11
Source File: TextMeasureTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphLogicalBounds(i);
        }
    } while (--numReps >= 0);
}
 
Example 12
Source File: StandardGlyphVector.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility used by getStandardGV.
 * Constructs a StandardGlyphVector from a generic glyph vector.
 * Do not call this from new contexts without considering the comment
 * about "userGlyphs".
 */
private StandardGlyphVector(GlyphVector gv, FontRenderContext frc) {
    this.font = gv.getFont();
    this.frc = frc;
    initFontData();

    int nGlyphs = gv.getNumGlyphs();
    this.userGlyphs = gv.getGlyphCodes(0, nGlyphs, null);
    if (gv instanceof StandardGlyphVector) {
        /* userGlyphs will be OK because this is a private constructor
         * and the returned instance is used only for rendering.
         * It's not constructable by user code, nor returned to the
         * application. So we know "userGlyphs" are valid as having
         * been either already validated or are the result of layout.
         */
        this.glyphs = userGlyphs;
    } else {
        this.glyphs = getValidatedGlyphs(this.userGlyphs);
    }
    this.flags = gv.getLayoutFlags() & FLAG_MASK;

    if ((flags & FLAG_HAS_POSITION_ADJUSTMENTS) != 0) {
        this.positions = gv.getGlyphPositions(0, nGlyphs + 1, null);
    }

    if ((flags & FLAG_COMPLEX_GLYPHS) != 0) {
        this.charIndices = gv.getGlyphCharIndices(0, nGlyphs, null);
    }

    if ((flags & FLAG_HAS_TRANSFORMS) != 0) {
        AffineTransform[] txs = new AffineTransform[nGlyphs]; // worst case
        for (int i = 0; i < nGlyphs; ++i) {
            txs[i] = gv.getGlyphTransform(i); // gv doesn't have getGlyphsTransforms
        }

        setGlyphTransforms(txs);
    }
}
 
Example 13
Source File: TextMeasureTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    AffineTransform tx;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            tx = gv.getGlyphTransform(i);
        }
    } while (--numReps >= 0);
}
 
Example 14
Source File: TextMeasureTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    AffineTransform tx;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            tx = gv.getGlyphTransform(i);
        }
    } while (--numReps >= 0);
}
 
Example 15
Source File: TextMeasureTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphOutline(i);
        }
    } while (--numReps >= 0);
}
 
Example 16
Source File: TextMeasureTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphOutline(i);
        }
    } while (--numReps >= 0);
}
 
Example 17
Source File: TextMeasureTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    AffineTransform tx;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            tx = gv.getGlyphTransform(i);
        }
    } while (--numReps >= 0);
}
 
Example 18
Source File: TextMeasureTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphOutline(i);
        }
    } while (--numReps >= 0);
}
 
Example 19
Source File: UnicodeFont.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Queues the backup glyphs in the specified text to be loaded. Note that
 * the glyphs are not actually loaded until {@link #loadGlyphs()} is called.
 * 
 * @param text The text containing the glyphs to be added
 */
private void addBackupGlyphs(String text) {
	if (text == null) throw new IllegalArgumentException("text cannot be null.");
	if (backup == null)
		return;

	char[] chars = text.toCharArray();
	GlyphVector vector = backup.getFont().layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
	for (int i = 0, n = vector.getNumGlyphs(); i < n; i++) {
		int codePoint = text.codePointAt(vector.getGlyphCharIndex(i));
		Rectangle bounds = getGlyphBounds(vector, i, codePoint);
		Glyph glyph = getGlyph(vector.getGlyphCode(i), codePoint, bounds, vector, i, backup);
	}
}
 
Example 20
Source File: TextMeasureTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    GVContext gvctx = (GVContext)ctx;
    GlyphVector gv = gvctx.gv;
    Shape s;
    do {
        for (int i = 0, e = gv.getNumGlyphs(); i < e; ++i) {
            s = gv.getGlyphOutline(i);
        }
    } while (--numReps >= 0);
}