public class Fonts extends Object
| Constructor and Description |
|---|
Fonts() |
| Modifier and Type | Method and Description |
|---|---|
static Font |
createFont()
创建默认字体
|
static Font |
createFont(File fontFile)
根据文件创建字体
首先尝试创建
Font.TRUETYPE_FONT字体,此类字体无效则创建Font.TYPE1_FONT |
static Font |
createFont(InputStream fontStream)
根据文件创建字体
首先尝试创建
Font.TRUETYPE_FONT字体,此类字体无效则创建Font.TYPE1_FONT |
static Font |
createFont(String name,
int size)
创建指定名称的字体
|
static Font |
createSansSerifFont(int size)
创建SansSerif字体
|
static Dimension |
getDimension(FontMetrics metrics,
String text)
获得字体对应字符串的长宽信息
|
public static Font createFont()
public static Font createSansSerifFont(int size)
size - 字体大小public static Font createFont(String name, int size)
name - 字体名称size - 字体大小public static Font createFont(File fontFile)
Font.TRUETYPE_FONT字体,此类字体无效则创建Font.TYPE1_FONTfontFile - 字体文件Fontpublic static Font createFont(InputStream fontStream)
Font.TRUETYPE_FONT字体,此类字体无效则创建Font.TYPE1_FONTfontStream - 字体流Fontpublic static Dimension getDimension(FontMetrics metrics, String text)
metrics - FontMetricstext - 字符串Copyright © 2022. All rights reserved.