Java Font Text Height getStringHeight(Graphics2D g, String str)

Here you can find the source of getStringHeight(Graphics2D g, String str)

Description

get String Height

License

Open Source License

Declaration

private static double getStringHeight(Graphics2D g, String str) 

Method Source Code

//package com.java2s;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;

import java.awt.Graphics2D;

public class Main {
    private static double getStringHeight(Graphics2D g, String str) {
        FontRenderContext frc = g.getFontRenderContext();
        GlyphVector gv = g.getFont().createGlyphVector(frc, str);
        return gv.getPixelBounds(null, 0, 0).getHeight();
    }/* www. java  2s  . c o  m*/
}

Related

  1. getStringDrawingHeight(Graphics graphics, String string)
  2. getStringHeight(Component c)
  3. getStringHeight(Graphics2D graphics2D)
  4. getTextHeight(String s, FontMetrics fm, Graphics g)
  5. getTextHeight(String text, Graphics g, String newLineSplit)
  6. stringHeight(Graphics2D g2d)