Here you can find the source of getMaxFontHeight(final java.awt.Font font)
public static int getMaxFontHeight(final java.awt.Font font)
//package com.java2s; /*/*w w w . j av a2 s. co m*/ * Copyright 2014 dorkbox, llc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { /** * Gets the maximum font height used by of ALL characters, as recorded by the font. */ public static int getMaxFontHeight(final java.awt.Font font) { // Because font metrics is based on a graphics context, we need to create a small, temporary image to determine the width and height BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); FontMetrics metrics = g.getFontMetrics(font); int height = metrics.getMaxAscent() + metrics.getMaxDescent(); g.dispose(); return height; } }