moveY = lastY = points[1]; result.moveTo(moveX, moveY); nextAdvance = glyphVector.getGlyphMetrics(currentChar).getAdvance() * 0.5f; next = nextAdvance; break; float y = lastY + next * dy * r; float advance = nextAdvance; nextAdvance = currentChar < length - 1 ? glyphVector.getGlyphMetrics( currentChar + 1).getAdvance() * 0.5f : 0; t.setToTranslation(x, y);
GlyphMetrics metrics = vector.getGlyphMetrics(index); int lsb = (int)metrics.getLSB(); if (lsb > 0) lsb = 0; GlyphVector charVector = unicodeFont.getFont().layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); GlyphMetrics charMetrics = charVector.getGlyphMetrics(0); xOffset = charVector.getGlyphPixelBounds(0, GlyphPage.renderContext, 0, 0).x - unicodeFont.getPaddingLeft(); xAdvance = (int)(metrics.getAdvanceX() + unicodeFont.getPaddingAdvanceX() + unicodeFont.getPaddingLeft()
GlyphMetrics metrics = vector.getGlyphMetrics(index); int lsb = (int)metrics.getLSB(); if (lsb > 0) lsb = 0; GlyphVector charVector = unicodeFont.getFont().layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); GlyphMetrics charMetrics = charVector.getGlyphMetrics(0); xOffset = charVector.getGlyphPixelBounds(0, GlyphPage.renderContext, 0, 0).x - unicodeFont.getPaddingLeft(); xAdvance = (int)(metrics.getAdvanceX() + unicodeFont.getPaddingAdvanceX() + unicodeFont.getPaddingLeft()
double advance = glyphVector.getGlyphMetrics(0).getAdvance() * 0.5f;
try { final int numGlyphs = gv.getNumGlyphs(); float nextAdvance = gv.getGlyphMetrics(0).getAdvance() * 0.5f; double start = cursor.getCurrentOrdinate(); for (int i = 0; i < numGlyphs; i++) { nextAdvance = i < numGlyphs - 1 ? gv.getGlyphMetrics(i + 1).getAdvance() * 0.5f : 0; c = cursor.getCurrentPosition(c);
GlyphVector glyphVector = component.getGlyphVector(); final int numGlyphs = glyphVector.getNumGlyphs(); float nextAdvance = glyphVector.getGlyphMetrics(0).getAdvance() * 0.5f; double start = cursor.getCurrentOrdinate(); Shape[] outlines = new Shape[numGlyphs]; ? glyphVector.getGlyphMetrics(i + 1).getAdvance() * 0.5f : 0;
protected GlyphMetrics getGlyphMetrics(int i) { return glyphs.getGlyphMetrics(i); }
protected GlyphMetrics getGlyphMetrics(int i) { return glyphs.getGlyphMetrics(i); }
@Override public GVTGlyphMetrics getGlyphMetrics(int arg0) { return new GVTGlyphMetrics(this.vec.getGlyphMetrics(arg0), 100000); }
GlyphVector gv = myfont.createGlyphVector(fr, "5"); Rectangle2D bounds = gv.getGlyphMetrics(0).getBounds2D(); float height = bounds.height();
public GlyphMetrics getMetrics(int index){ return get(index).getGlyphMetrics(0); }
/** * @param string {@code String} to examine * @param font {@code Font} that is used to render the string * @param graphics {@link Graphics} that should be used to render the string * @return height of the tallest glyph in a string. If string is empty, returns 0 */ public static int getHighestGlyphHeight(@NotNull String string, @NotNull Font font, @NotNull Graphics graphics) { FontRenderContext frc = ((Graphics2D) graphics).getFontRenderContext(); GlyphVector gv = font.createGlyphVector(frc, string); int maxHeight = 0; for (int i = 0; i < string.length(); i++) { maxHeight = Math.max(maxHeight, (int) gv.getGlyphMetrics(i).getBounds2D().getHeight()); } return maxHeight; }
private Glyph getGlyph(final int unicodeID) { if (unicodeID >= unicodes2Glyphs.length) { return null; } final int glyphID = unicodes2Glyphs[unicodeID]; if (glyphID != undefined) { return glyphCache[glyphID]; } singleUnicode[0] = (char) unicodeID; final GlyphVector gv = font.createGlyphVector(getFontRenderContext(), singleUnicode); return getGlyph(unicodeID, gv, gv.getGlyphMetrics(0)); }
public float getGlyphPixelWidth(final char unicodeID) { final Glyph glyph = getGlyph(unicodeID); if (glyph != null) { return glyph.getAdvance(); } // Have to do this the hard / uncached way singleUnicode[0] = unicodeID; if( null == fontRenderContext ) { // FIXME: Never initialized! throw new InternalError("fontRenderContext never initialized!"); } final GlyphVector gv = font.createGlyphVector(fontRenderContext, singleUnicode); return gv.getGlyphMetrics(0).getAdvance(); }
protected double[] getAdvanceWidths() { if (widths == null) { // figure out the widths of the characters if not yet done widths = new double[256]; for (int i = 0; i < widths.length; i++) { widths[i] = glyphs.getGlyphMetrics(i).getAdvance(); // in case of undefined character set to width of undefined // symbol if (getCharName(i) == null) { widths[i] = getUndefinedWidth(); } } } return widths; }
public LabelItem(String label_, Point2D pos_, Java2dFont font, Color color_, Alignment alignment, Shape shape_) { this.color = color_; this.label = label_; this.awtFont = font.getAwtFont(); GlyphMetrics gm = awtFont.createGlyphVector(Java2dBackend.FRC, label.substring(0, 1)).getGlyphMetrics(0); Rectangle2D size = font.extents(label); double text_x = pos_.getX() - size.getWidth() * alignment.getXAlign(); double text_y = pos_.getY() + shape_.getInternalYOffset(label_, font, alignment); double rect_y = pos_.getY() + size.getHeight() * alignment.getYAlign() - (font.getAscent() + shape_.getYPadding()); rect = new Rectangle2D.Double( text_x + gm.getLSB() - shape_.getXPadding(), rect_y, size.getWidth() + 2 * shape_.getXPadding(), font.getLineHeight() + 2 * shape_.getYPadding()); this.pos = new Point2D.Double(text_x - rect.getX(), text_y - rect.getY()); this.shape = shape_; }
protected double[] getAdvanceWidths() { if (widths == null) { // figure out the widths of the characters if not yet done widths = new double[256]; for (int i = 0; i < widths.length; i++) { widths[i] = glyphs.getGlyphMetrics(i).getAdvance(); // in case of undefined character set to width of undefined // symbol if (getCharName(i) == null) { widths[i] = getUndefinedWidth(); } } } return widths; }
/** * @param c * @param font * @return GlyphVector using a default rendering context */ private SVGGlyph createGlyph(int c, Font font) { GlyphVector glyphVector = font.createGlyphVector( // flipping is done by SVGGlyph new FontRenderContext(null, true, true), // unicode to char String.valueOf((char) c)); // create and store the SVG Glyph return new SVGGlyph( glyphVector.getGlyphOutline(0), c, glyphVector.getGlyphMetrics(0)); }
/** * @param c * @param font * @return GlyphVector using a default rendering context */ private SVGGlyph createGlyph(int c, Font font) { GlyphVector glyphVector = font.createGlyphVector( // flipping is done by SVGGlyph new FontRenderContext(null, true, true), // unicode to char String.valueOf((char) c)); // create and store the SVG Glyph return new SVGGlyph( glyphVector.getGlyphOutline(0), c, glyphVector.getGlyphMetrics(0)); }
@Override public MissingGlyph getGlyph(String unicode) { FontRenderContext frc = new FontRenderContext(null, true, true); GlyphVector vec = sysFont.createGlyphVector(frc, unicode); Glyph glyph = (Glyph)glyphCache.get(unicode); if (glyph == null) { glyph = new Glyph(); glyph.setPath(vec.getGlyphOutline(0)); GlyphMetrics gm = vec.getGlyphMetrics(0); glyph.setHorizAdvX(gm.getAdvanceX()); glyph.setVertAdvY(gm.getAdvanceY()); glyph.setVertOriginX(0); glyph.setVertOriginY(0); glyphCache.put(unicode, glyph); } return glyph; }