while (currentChar < length && distance >= next) { Shape glyph = glyphVector.getGlyphOutline(currentChar); Point2D p = glyphVector.getGlyphPosition(currentChar); float px = (float) p.getX(); float py = (float) p.getY();
int length = gv.getNumGlyphs(); for (int i = 0; i < length; i++) { Point2D p = gv.getGlyphPosition(i); double theta = (double) i / (double) (length - 1) * Math.PI / 4; AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
double start = cursor.getCurrentOrdinate(); for (int i = 0; i < numGlyphs; i++) { Point2D p = gv.getGlyphPosition(i); float advance = nextAdvance; nextAdvance = cursor.moveTo(start + gv.getGlyphPosition(numGlyphs).getX()); } finally { painter.graphics.setTransform(oldTransform);
@Override public Point2D getGlyphPosition(int arg0) { return this.vec.getGlyphPosition(arg0); }
for (int i = 0; i < numGlyphs; i++) { outlines[i] = glyphVector.getGlyphOutline(i); Point2D p = glyphVector.getGlyphPosition(i); float advance = nextAdvance; if (tracking != null) { cursor.moveTo(start + glyphVector.getGlyphPosition(numGlyphs).getX());
public float getGlyphPosition(int i) { return (float)javaGV.getGlyphPosition(i).getX(); }
public double getX(int index){ return get(index).getGlyphPosition(0).getX(); }
public double getY(int index){ return get(index).getGlyphPosition(0).getY(); }
Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "dasdasdasd1"; Font font = new Font("Courier", Font.PLAIN, 12); g2d.translate(20, 20); FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector gv = font.createGlyphVector(frc, s); int length = gv.getNumGlyphs(); Rectangle2D barra=new Rectangle2D.Double(0, 0, 700, 500); g2d.draw(barra); for (int i = 0; i < length; i++) { Point2D p = gv.getGlyphPosition(i); AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY()); at.rotate((double) i / (double) (length - 1) * Math.PI / 3); Shape glyph = gv.getGlyphOutline(i); Shape transformedGlyph = at.createTransformedShape(glyph); g2d.fill(transformedGlyph); }
public static void adjust(GlyphVector gv){ // calc the adjust Factor int adjust = (int)Math.round(gv.getGlyphVisualBounds(0).getBounds2D().getMinX()); // Shift all the Glyphs in Vector for (int i = 0; i < gv.getNumGlyphs(); i++) { Point2D point = gv.getGlyphPosition(i); gv.setGlyphPosition( i, new Point2D.Double( point.getX() - adjust, point.getY())); } }
private void adjustGlyphPositions( String string, JustificationInfo info, GlyphVector vector) { float adjust = 0.0f; for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (i != 0) { Point2D point = vector.getGlyphPosition(i); vector.setGlyphPosition( i, new Point2D.Double(point.getX() + adjust, point.getY())); } if (c == ' ' || c == '\u00a0' || c == '\u3000') { adjust += info.getSpaceAdjust(); } else { adjust += info.getNonSpaceAdjust(); } } }
private void adjustGlyphPositions( String string, JustificationInfo info, GlyphVector vector) { float adjust = 0.0f; for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (i != 0) { Point2D point = vector.getGlyphPosition(i); vector.setGlyphPosition( i, new Point2D.Double(point.getX() + adjust, point.getY())); } if (c == ' ' || c == '\u00a0' || c == '\u3000') { adjust += info.getSpaceAdjust(); } else { adjust += info.getNonSpaceAdjust(); } } }
private void adjustGlyphPositions( String string, JustificationInfo info, GlyphVector vector) { float adjust = 0.0f; for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (i != 0) { Point2D point = vector.getGlyphPosition(i); vector.setGlyphPosition( i, new Point2D.Double(point.getX() + adjust, point.getY())); } if (c == ' ' || c == '\u00a0' || c == '\u3000') { adjust += info.getSpaceAdjust(); } else { adjust += info.getNonSpaceAdjust(); } } }
private void adjustGlyphPositions( String string, JustificationInfo info, GlyphVector vector) { float adjust = 0.0f; for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (i != 0) { Point2D point = vector.getGlyphPosition(i); vector.setGlyphPosition( i, new Point2D.Double(point.getX() + adjust, point.getY())); } if (c == ' ' || c == '\u00a0' || c == '\u3000') { adjust += info.getSpaceAdjust(); } else { adjust += info.getNonSpaceAdjust(); } } }
double glyphX = cachedGlyphVector.getGlyphPosition(i).getX(); double glyphY = cachedGlyphVector.getGlyphVisualBounds(i).getBounds2D().getHeight();
private void nextSegment( CharacterWiseState state, int length, double distance, GlyphVector glyphVector, double lastX, double lastY, double dx, double dy, double r, double angle, GeneralPath result ) { while ( state.currentChar < length && distance >= state.next ) { Shape glyph = glyphVector.getGlyphOutline( state.currentChar ); Point2D p = glyphVector.getGlyphPosition( state.currentChar ); double px = p.getX(); double py = p.getY(); double x = lastX + state.next * dx * r; double y = lastY + state.next * dy * r; double advance = state.nextAdvance; state.nextAdvance = state.currentChar < length - 1 ? glyphVector.getGlyphMetrics( state.currentChar + 1 ).getAdvance() * 0.5f : advance; AffineTransform t = new AffineTransform(); t.setToTranslation( x, y ); t.rotate( angle ); t.translate( -px - advance, -py + lineHeight / 4 ); appendShape( result, t.createTransformedShape( glyph ) ); state.next += ( advance + state.nextAdvance ); state.currentChar++; if ( linePlacement.repeat && state.currentChar >= length ) { state.currentChar = 0; state.next += linePlacement.gap; } } }
/** * This method is <b>EXPENSIVE</b>. * * @param previous * @param character * @return */ public long getKerning( final int previous, final int character ) { final int retvalC1 = CodePointUtilities.toChars( previous, cpBuffer, 0 ); if ( retvalC1 <= 0 ) { return 0; } final int retvalC2 = CodePointUtilities.toChars( character, cpBuffer, retvalC1 ); if ( retvalC2 > 0 ) { final int limit = ( retvalC1 + retvalC2 ); final GlyphVector gv = font.createGlyphVector( frc, new String( cpBuffer, 0, limit ) ); final long totalSize = FontStrictGeomUtility.toInternalValue( gv.getGlyphPosition( limit ).getX() ); final long renderedWidth = FontStrictGeomUtility.toInternalValue( gv.getOutline().getBounds2D().getWidth() ); return totalSize - renderedWidth; } else { return 0; } }
public Shape getEstringOutline(String displayText, float x, float y) { displayText = toUnicode(displayText); FontRenderContext frc = new FontRenderContext(new AffineTransform(), true, true); GlyphVector glyphVector = awtFont.createGlyphVector(frc, displayText); glyphVector.setGlyphPosition(0, new Point2D.Float(x, y)); // Iterate through displayText to calculate the the new advance value if // the displayLength is greater then one character. This in sures that // cid -> String will get displayed correctly. int displayLength = displayText.length(); float lastx; if (displayLength > 1) { Point2D p; float advance = 0; for (int i = 0; i < displayText.length(); i++) { // Position of the specified glyph relative to the origin of glyphVector p = glyphVector.getGlyphPosition(i); lastx = (float) p.getX(); // add fonts rise to the to glyph position (sup,sub scripts) glyphVector.setGlyphPosition( i, new Point2D.Double(lastx + advance, p.getY())); // subtract the advance because we will be getting it from the fonts width float adv1 = glyphVector.getGlyphMetrics(i).getAdvance(); double adv2 = echarAdvance(displayText.charAt(i)).getX(); advance += -adv1 + adv2 + lastx; } } return glyphVector.getOutline(); }
protected void drawChars(char[] string, float x, float y) { pipeline.use(gl, true); pipeline.setColor(gl, g2d.getUniformsObject().colorHook.getRGBA()); pipeline.setTransform(gl, g2d.getUniformsObject().transformHook.getGLMatrixData()); pipeline.bindBuffer(gl); GlyphVector glyphs = getFont().createGlyphVector(getFontRenderContext(), string); for (int i = 0; i < string.length; i++) { Triangles triangles = getTesselatedGlyph(string[i]); Point2D pt = glyphs.getGlyphPosition(i); pipeline.setLocation(gl, (float) pt.getX() + x, (float) pt.getY() + y); triangles.draw(gl); } pipeline.unbindBuffer(gl); pipeline.use(gl, false); }
protected void drawChars(char[] string, float x, float y) { pipeline.use(gl, true); pipeline.setColor(gl, g2d.getUniformsObject().colorHook.getRGBA()); pipeline.setTransform(gl, g2d.getUniformsObject().transformHook.getGLMatrixData()); pipeline.bindBuffer(gl); GlyphVector glyphs = getFont().createGlyphVector(getFontRenderContext(), string); for (int i = 0; i < string.length; i++) { Triangles triangles = getTesselatedGlyph(string[i]); Point2D pt = glyphs.getGlyphPosition(i); pipeline.setLocation(gl, (float) pt.getX() + x, (float) pt.getY() + y); triangles.draw(gl); } pipeline.unbindBuffer(gl); pipeline.use(gl, false); }