public LineMetrics getLineMetrics(Graphics2D gg, String text) { final FontRenderContext frc = gg.getFontRenderContext(); return font.getLineMetrics(text, frc); }
/** * Computes some metrics for this part of the line taking in account the provided rendering * context. This methods will always recompute the metrics even if the same font rendering * context is provided. */ LineMetrics computeLineMetrics(FontRenderContext fontRenderContext) { return gv.getFont().getLineMetrics(text, fontRenderContext); } }
double getFontAscent(Font font) { LineMetrics lm = font.getLineMetrics(DUMMY_TEXT, gd.getFontRenderContext()); return lm.getAscent(); }
double getFontHeight(Font font) { LineMetrics lm = font.getLineMetrics(DUMMY_TEXT, gd.getFontRenderContext()); return lm.getAscent() + lm.getDescent(); }
/** * Vertical centering is not trivial, because visually we want centering on characters such as * a,m,e, and not centering on d,g whose center is affected by the full ascent or the full * descent. This method tries to computes the y anchor taking into account those. */ public double getLinePlacementYAnchor() { TextStyle2D textStyle = getLabel().getTextStyle(); LineMetrics lm = textStyle .getFont() .getLineMetrics(textStyle.getLabel(), graphics.getFontRenderContext()); // gracefully handle font size = 0 if (lm.getHeight() > 0) { return (Math.abs(lm.getStrikethroughOffset()) + lm.getDescent() + lm.getLeading()) / lm.getHeight(); } else { return 0; } }
public LineMetricsAdapter(List<Font> fonts, String str, FontRenderContext ctx) { _lineMetrics = new ArrayList<LineMetrics>(fonts.size()); for (Font fnt : fonts) { _lineMetrics.add(fnt.getLineMetrics(str, ctx)); } }
@Override public GVTLineMetrics getLineMetrics(char[] arg0, int arg1, int arg2, FontRenderContext arg3) { return new GVTLineMetrics(this.baseFont.getLineMetrics(arg0, arg1, arg2, arg3)); }
@Override public GVTLineMetrics getLineMetrics(String arg0, int arg1, int arg2, FontRenderContext arg3) { return new GVTLineMetrics(this.baseFont.getLineMetrics(arg0, arg1, arg2, arg3)); }
@Override public GVTLineMetrics getLineMetrics(CharacterIterator arg0, int arg1, int arg2, FontRenderContext arg3) { return new GVTLineMetrics(this.baseFont.getLineMetrics(arg0, arg1, arg2, arg3)); }
/** * Returns a GVTLineMetrics object created with the specified String and * FontRenderContext. */ public GVTLineMetrics getLineMetrics(String str, FontRenderContext frc) { return new GVTLineMetrics(awtFont.getLineMetrics(str, frc), (float)scale); }
/** * Returns a GVTLineMetrics object created with the specified arguments. */ public GVTLineMetrics getLineMetrics(String str, int beginIndex, int limit, FontRenderContext frc) { return new GVTLineMetrics (awtFont.getLineMetrics(str, beginIndex, limit, frc), (float)scale); }
/** * Returns a GVTLineMetrics object created with the specified String and * FontRenderContext. */ public GVTLineMetrics getLineMetrics(String str, FontRenderContext frc) { return new GVTLineMetrics(awtFont.getLineMetrics(str, frc), (float)scale); }
/** * Returns a GVTLineMetrics object created with the specified arguments. */ public GVTLineMetrics getLineMetrics(String str, int beginIndex, int limit, FontRenderContext frc) { return new GVTLineMetrics (awtFont.getLineMetrics(str, beginIndex, limit, frc), (float)scale); }
/** * Returns a GVTLineMetrics object created with the specified arguments. */ public GVTLineMetrics getLineMetrics(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc) { return new GVTLineMetrics (awtFont.getLineMetrics(ci, beginIndex, limit, frc), (float)scale); }
private synchronized void initStrikethrough(Graphics g) { LineMetrics lm = font.getLineMetrics("aAyY", ((Graphics2D)g).getFontRenderContext()); // NOI18N strikethroughOffset = lm.getStrikethroughOffset(); strikethroughThickness = lm.getStrikethroughThickness(); inited |= ST_INITED; }
@Override public int getBaseline(int width, int height) { FontRenderContext fontRenderContext = Platform.getFontRenderContext(); LineMetrics lm = font.getLineMetrics("", fontRenderContext); return Math.round(margin.top + lm.getAscent()); }
private synchronized void initUnderline(Graphics g) { LineMetrics lm = font.getLineMetrics("aAyY", ((Graphics2D)g).getFontRenderContext()); // NOI18N underlineOffset = lm.getUnderlineOffset(); underlineThickness = lm.getUnderlineThickness(); inited |= UL_INITED; }
public FSFontMetrics getFSFontMetrics(FontContext fc, FSFont font, String string ) { Graphics2D graphics = ((Java2DFontContext)fc).getGraphics(); return new LineMetricsAdapter( ((AWTFSFont)font).getAWTFont().getLineMetrics( string, graphics.getFontRenderContext())); }
public int getInsertionPoint(int xArgument, int yArgument) { Font font = textAreaSkin.getFont(); FontRenderContext fontRenderContext = Platform.getFontRenderContext(); LineMetrics lm = font.getLineMetrics("", fontRenderContext); float rowHeight = lm.getAscent() + lm.getDescent(); int i = (int)Math.floor(yArgument / rowHeight); int n = rows.getLength(); return (i < 0 || i >= n) ? -1 : getRowInsertionPoint(i, xArgument); }
public JavaFont(String fontName, int fontStyle, int fontSize) { super(fontName, fontStyle, fontSize); myFont = UIManager.getCachedJavaFont(fontName, fontStyle, fontSize); frc = new java.awt.font.FontRenderContext(null, true, false); java.awt.font.LineMetrics metrics = myFont.getLineMetrics("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopwrstuvwxyz0123456789", frc); height = metrics.getHeight(); ascent = metrics.getAscent(); leading = metrics.getLeading(); descent = metrics.getDescent(); } public MetaFont deriveFontSize(int newSize, UIManager uiLoader)