2024-03-30

This commit is contained in:
2024-03-30 19:57:14 +09:00
parent d4055752a9
commit 57cc9ca7ff
90 changed files with 4829 additions and 105 deletions

31
doc/33_font.md Normal file
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");
```