Java Folder Size Get fontSize(Font f)

Here you can find the source of fontSize(Font f)

Description

{ method

License

Apache License

Parameter

Parameter Description
text the string
f Font to use

Return

height + width }

Declaration

@SuppressWarnings(value = "deprecated")
public static Dimension fontSize(Font f) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.*;

public class Main {
    /**// w  w  w. j  a  v a  2s . c om
     * { method
     *
     * @param text the string
     * @param f    Font to use
     * @return height + width
     *         }
     * @name measureText
     * @function measure a text string in some font -
     * useful for non awt objects
     */
    @SuppressWarnings(value = "deprecated")
    public static Dimension fontSize(Font f) {
        Toolkit g = Toolkit.getDefaultToolkit(); // defaultGraphics();
        if (g == null) {
            return (new Dimension(10, 10));
        }
        FontMetrics metrics = g.getFontMetrics(f);
        return (new Dimension(metrics.charWidth('W'), metrics.getHeight()));
    }
}

Related

  1. emSize(Font font, double em)
  2. folderSize(File directory)
  3. folderSize(File directory)
  4. folderSize(File directory)
  5. fontSize(Font f)
  6. setFileChooserFont(Component[] comp, int newFontSize)
  7. setFontOfPixelHeight(Graphics2D g, int style, double targetSize)
  8. setFontSize(Component c, float size)