2024-06-12

This commit is contained in:
2024-06-12 13:10:10 +09:00
parent 57cc9ca7ff
commit 7e1d726c23
44 changed files with 146 additions and 31 deletions

View File

@@ -0,0 +1,31 @@
# Font
```java
Font font = Font.createFont(Font.TRUETYPE_FONT, new File("Abc.ttf"));
return font.deriveFont(12.f);
```
* `getFamily()`
* `getFontName()`
* `getAttributes()`
* `graphics2D.getFont()` / `graphics2D.setFont(Font)`
* `Font.createFont(int,InputStream)`
* `deriveFont()`
* `graphicsEnvironment.getAvailableFontFamilyNames()`
* `graphicsEnvironment.getAllFonts()`
```java
HashMap<TextAttribute,Object> map = new HashMap<>();
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
font = font.deriveFont(map);
```
## FontMetrics
```java
FontMetrics fontMetrics = graphics2D.getFontMetrics(font);
int textHeight = fontMetrics.getHeight();
int textWidth = fontMetrics.stringWidth("Hello");
```