# core/textstringtexturecache (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/core/textstringtexturecache/

문자열 텍스처 캐시.
- 원본은 글꼴(모드, 글꼴 글, 굽는 배율, 선 굵기)마다 글자 덩어리를 글리프 아틀라스(1024 x 1024 장, 8 장까지)에 한 번만 굽고, 글은 글리프 사각형 목록(엔트리, LRU 상한 1024)으로 그린다.
- 데스크탑은 글자 모양 짓기(textshaping.rs: 양방향 정렬, rustybuzz 모양 짓기)로 글리프를 놓고, 처음 보는 글리프만 래스터화해(맥 CoreText, 윈도우 DirectWrite, 리눅스 skrifa) 아틀라스 칸에 굽는다.
  칸은 원본과 같은 글자 덩어리마다 하나다. 한글, 한자, 가나, 숫자, 문장 부호, 이모지는 글자 묶음마다, 라틴과 키릴 같은 글자는 낱말째 한 칸이다.
  칸 열쇠는 덩어리에 든 글리프마다 (얼굴, 글리프 번호, 크기, 스키아 서브픽셀 1/4 칸)과 첫 글리프에서의 정수 자리 차이, 방식과 선 굵기, 안티앨리어싱이다.
  (원본은 스키아의 칸 경계를 모두 담는 1/8 자리 칸을 열쇠로 쓴다. 러스트는 스키아가 쓰는 칸 자체를 알아 같은 래스터를 더 적게 굽는다)
  이웃 덩어리의 잉크가 닿으면 칸마다 따로 그려 소수 자리의 선형 거르기와 겹친 잉크 섞기가 문자열째와 조금 다를 수 있다. (원본과 같다, 스키아 글리프 캐시와 TextMeshPro 의 꼴)
  칸마다 위아래에 가장자리 줄을 한 줄씩 되풀이해 굽는다. (세로 소수 자리에서 칸 끝을 넘어 뽑아도 아틀라스의 다른 줄이 아니라 예전 CLAMP_TO_EDGE 처럼 가장자리 줄이 나온다)
  256px 넘는 글꼴, 오른쪽에서 왼쪽 글, 웹(브라우저 Canvas2D 로 굽는다)은 원본처럼 문자열째 칸 하나에 굽는다.
  장 정책(가장 나중에 연 장에만 이어 놓기, 차면 새 장, 8 장을 넘으면 가장 오래 안 쓴 장을 비우기), 엔트리 상한, 엔트리 키 구성(방식, 문단 방향, 폰트 문자열, 선 두께, 배율, 글)은 원본과 같다.
  원본은 키를 문자열로 이어 붙인다. 여기서는 찾을 때마다 문자열을 만들지 않게 키의 해시로 찾고, 같은 해시 안에서 키를 하나씩 맞춰 본다.
- 글자는 흰색으로 굽고, 그릴 때 색을 곱한다. (색이 바뀌어도 다시 굽지 않는다)
  색 글리프(이모지)는 제 색으로 흰 글자 위에 얹어 굽는다. 원본도 흰색으로 fillText 한 캔버스를 올리므로 이모지는 제 색으로 구워지고 그릴 때 같은 색이 곱해진다.
  외곽선(Stroke)으로 구울 때도 색 글리프는 테를 긋지 않고 색 그대로 얹는다. (크롬 strokeText 와 같다)
- 폰트 문자열은 Canvas2D font 와 같은 꼴(CSS font 줄임 꼴)을 읽는다. 예: "16px DOSGothic", "bold 24px default", "italic 500 16px default", "12pt 'A B', C, sans-serif"
  크기는 px 밖의 CSS 단위(ex, ch, cap, ic, lh, rem, 뷰포트 단위 포함), 이름 크기, calc() 도 크롬 캔버스처럼 읽고 "/줄높이"는 넘긴다.
  쉼표로 이은 이름 목록은 글자마다 앞 이름의 얼굴부터 찾는다. (브라우저의 글꼴 목록과 같다, parse_font_string)
- 글꼴은 원본 document.fonts 처럼 이름 하나 아래에 얼굴(굵기, 기울기, 글자 범위)을 여럿 올린다. (register_font_face)
  고르기는 CSS 의 차례를 따르고, 기울인 얼굴이 없으면 가짜 기울임(기울기 1/4), 굵은 얼굴이 없으면 가짜 굵게를 글리프마다 입힌다. (textshaping.rs)
- 이름의 얼굴들에 없는 글자는 기본 폰트, 시스템 글꼴 사슬, 표준 글꼴(데스크탑, 크롬의 -webkit-standard), 대체 폰트 순으로 찾는다. (브라우저의 글꼴 대체와 같은 자리)
  이름 목록에서 얼굴을 하나도 찾지 못하면(default 가 아닌 없는 이름뿐이면) 크롬처럼 표준 글꼴을 기본 폰트보다 먼저 둔다.
  데스크탑 시스템 글꼴 사슬(set_system_font_chain)은 원본 SYSTEM_FONT_STRING 의 이름을 운영체제 글꼴에서 찾은 것이고, 기본 글꼴 이름 default 를 청했을 때만 기본 폰트 뒤에 잇는다.
  켜면 폰트 문자열의 올리지 않은 이름도 운영체제 글꼴에서 찾는다. 얼굴은 그 굵기와 기울기의 글자를 처음 쓸 때 읽는다. (platform/desktop/systemfont.rs)
  대체 글꼴은 운영체제가 고른다. (set_system_font_fallback_enabled, 굵게를 청하면 굵은 얼굴을 따로 묻는다) 크롬처럼 첫 글꼴(빈칸을 가진 첫 얼굴)과 폰트 문자열마다 따로 묻고,
  대체 얼굴은 운영체제가 그 얼굴을 고른 글자만 그린다. 이름 목록의 얼굴이 정준 분해로 그리는 글자(ï 를 i 와 U+0308 로)는 묻지 않는다. 후보 파일을 주면(add_fallback_font_candidate) 그것을 먼저 쓴다.
  후보 파일은 쓸 때 읽는다. 이모지 표시 글자는 색 글리프 표가 있는 후보를, 그 밖의 글자는 색 글리프 표가 없는 후보를 먼저 읽는다. (표 목록만 먼저 엿본다)
- 글꼴 얼굴을 새로 올리면 그 이름을 쓰는 폰트 문자열로 구웠고 그 얼굴의 글자 범위에 든 글자가 있는 문자열만 버린다. (원본 invalidateFontFaces)
  원본처럼 set_rebake_text_on_font_load 로 켰을 때만 한다. (엔진이 EngineConfiguration.rebake_text_on_font_load 로 켠다, 기본 끔)
  끄면 받기 전에 다른 글꼴로 구운 글자는 캐시에서 밀려날 때까지 그대로 남는다. 얼굴 지우기와 차례 바꾸기는 켜짐과 상관없이 버린다.
  기본 폰트와 대체 폰트를 바꾸면 모두 버린다.
- 웹은 원본처럼 늘 브라우저 Canvas2D 로 굽고 잰다. (platform/web/systemfont.rs) 올린 글꼴 바이트는 document.fonts 에 FontFace 로 올려 브라우저가 고르고 그린다.
  올린 글꼴이 받아지면(loadingdone) 프레임 시작에 구운 글을 버린다. 데스크탑은 위의 모양 짓기와 래스터로 굽는다.
- 글자 안티앨리어싱(set_text_antialias_enabled, 원본 setTextAntialiasEnabled): 끄면 구운 글자의 알파를 문턱값 128 로 0 과 255 로 가르고 텍스처를 NEAREST 로 뽑는다.
  도트 글꼴을 설계 크기의 정수 배로 그리는 프로젝트가 끈다. 원본은 모듈 전역 값이고 이미 구운 글자는 그대로 둔다.
  여기서는 캐시가 들고, 켜짐 여부를 키에 넣어 바꾼 다음 그리는 글자부터 바로 그 방식으로 굽는다. (rasterize_text 는 원본 ShadowText 처럼 받지 않는다)
- 글 재기(measure_text)는 폰트 문자열과 글이 같으면 다시 재지 않는다. (원본 measureTextMetrics 의 캐시, 2048 개)
  원본은 넘칠 때마다 가장 오래 안 쓴 하나를 버린다. 여기서는 넘치면 오래 안 쓴 반을 한 번에 버린다. (하나씩 찾으면 넘친 뒤로 잴 때마다 2048 개를 훑는다)
  글꼴을 새로 등록하면 비운다. (원본은 웹 글꼴이 받아지면 비운다) measure_text 가 &self 라 캐시는 RefCell 에 든다.
- 얼굴을 그때그때 받기(watch_unresolved_family_characters, take_unresolved_family_characters): 원본 브라우저는 올려 둔 FontFace 의 글자 범위에 든 글자를 그릴 때 그 얼굴을 받는다.
  러스트 판은 지켜보는 이름으로 재거나 구운 글에서 올린 얼굴의 범위에 들지 않은 글자를 모으고, UIFont 가 update 에서 꺼내 그 글자의 조각을 받는다.
- Graphic 없이 재기(measure_text_without_graphic): 원본은 어디서든 공용 2D 캔버스로 글을 잰다. 러스트 판은 글꼴을 등록할 때마다
  글꼴 목록(Rc)을 스레드 하나의 전역에 알려 두고, 그 목록으로 잰다. UI 레이아웃이 그리기 전에 글 줄 수를 알아야 할 때 쓴다. (UIConfirmWindow)

## TextEntry (struct) (Clone, Debug)

글 배치 엔트리 하나. (원본 getEntry 의 엔트리, 길이 단위는 모두 논리 픽셀, 베이크 배율로 나눈 값)
- 문자열을 통째로 구웠을 때의 사각형(quad_width, quad_height, pen_offset_x, baseline_offset_y)과,
  그 사각형 왼쪽 위 기준의 글리프 사각형(glyph_textures, glyph_rects)을 준다. 글리프는 글리프 아틀라스에 한 번만 구워 여러 문자열이 나눠 쓴다.
- 사각형 왼쪽 위는 (펜 x - pen_offset_x, 기준선 y - baseline_offset_y) 에 놓고, 글리프마다 그 자리에 glyph_rects 를 더해 그린다. (Graphic::draw_text_entry)

예제: 엔트리의 글리프 사각형을 펜 자리와 기준선에 놓기

```rust
use vanilla::core::textstringtexturecache::{TextDrawKind, TextStringTextureCache};
use vanilla::{Rect, ShapingDirection};

fn calculate_glyph_quads(text_string_texture_cache: &mut TextStringTextureCache, gl: &vanilla::GlContext, pen_x: f64, baseline_y: f64) -> Vec<Rect> {
	let Some(entry) = text_string_texture_cache.get_entry(gl, TextDrawKind::Fill, "Score", "24px default", 0.0, 2.0, ShapingDirection::LeftToRight) else {
		return Vec::new();
	};
	let quad_x = pen_x - entry.pen_offset_x;
	let quad_y = baseline_y - entry.baseline_offset_y;
	entry.glyph_rects.iter().map(|glyph_rect| Rect::create(quad_x + glyph_rect[0], quad_y + glyph_rect[1], glyph_rect[2] - glyph_rect[0], glyph_rect[3] - glyph_rect[1])).collect()
}
```

- `pub glyph_textures: Rc<[crate::core::graphic::GlTexture]>` (field, since 0.4.0): 글리프마다 든 아틀라스 장 텍스처. (glyph_rects 와 같은 차례, 흰 글자의 프리멀티플라이드 RGBA, 색 글리프는 제 색)
  - returns Rc<[crate::core::graphic::GlTexture]>
- `pub glyph_rects: Rc<[[f64; 8]]>` (field, since 0.4.0): 글리프 사각형. (문자열 사각형 왼쪽 위 기준 논리 좌표의 왼, 위, 오른, 아래와 아틀라스 텍스처 좌표 u0, v0, u1, v1)
  - returns Rc<[[f64; 8]]>
- `pub advance_width: f64` (field, since 0.3.2): 전진폭.
  - returns f64
- `pub font_ascent: f64` (field, since 0.3.2): 글꼴의 기준선 위 길이. (양수)
  - returns f64
- `pub font_descent: f64` (field, since 0.3.2): 글꼴의 기준선 아래 길이. (양수)
  - returns f64
- `pub pen_offset_x: f64` (field, since 0.3.2): 문자열 사각형 왼쪽에서 펜 원점까지의 거리.
  - returns f64
- `pub baseline_offset_y: f64` (field, since 0.3.2): 문자열 사각형 위에서 기준선까지의 거리.
  - returns f64
- `pub quad_width: f64` (field, since 0.3.2): 문자열 사각형 너비. (통째로 구웠을 때의 텍스처 너비를 굽는 배율로 나눈 값)
  - returns f64
- `pub quad_height: f64` (field, since 0.3.2): 문자열 사각형 높이. (통째로 구웠을 때의 텍스처 높이를 굽는 배율로 나눈 값)
  - returns f64

## TextAtlasStatistics (struct) (Clone, Copy, Debug, Default, PartialEq, Eq)

글리프 아틀라스 통계. (원본 readAtlasStatistics 의 돌려준 값, 시험과 통계용)

예제: 아무것도 굽지 않은 캐시의 통계

```rust
use vanilla::core::textstringtexturecache::TextStringTextureCache;

let text_string_texture_cache = TextStringTextureCache::new();
let text_atlas_statistics = text_string_texture_cache.read_atlas_statistics();
assert_eq!(text_atlas_statistics.atlas_page_count, 0);
assert_eq!(text_atlas_statistics.entry_count, 0);
```

- `pub atlas_page_count: usize` (field, since 0.4.0): 아틀라스 장 수.
  - returns usize
- `pub glyph_count: usize` (field, since 0.4.0): 든 글리프 수.
  - returns usize
- `pub baked_glyph_count: u64` (field, since 0.4.0): 지금까지 구운 글리프 수.
  - returns u64
- `pub upload_count: u64` (field, since 0.4.0): 지금까지 아틀라스에 올린 수. (이어 놓은 새 글리프 여럿이 한 번)
  - returns u64
- `pub entry_count: usize` (field, since 0.4.0): 글 배치 엔트리 수.
  - returns usize

## TextRaster (struct) (Clone, Debug)

글 모양 래스터. (덮인 정도 0 ~ 255, 길이 단위는 굽는 배율을 곱한 픽셀)
- coverage 는 색 글리프를 뺀 글자의 덮인 정도다. 색 글리프(이모지)가 있으면 color_pixels 에 제 색으로 든다. (프리멀티플라이드 RGBA, 같은 크기)

예제: 글 모양 래스터 받기

```rust
use vanilla::core::textstringtexturecache::TextStringTextureCache;
use vanilla::platform::find_fallback_font_file;
use vanilla::ShapingDirection;

if let Some(source) = find_fallback_font_file("A", 400, false, false) {
	let font_bytes = std::fs::read(&source.path).expect("font file");
	let mut text_string_texture_cache = TextStringTextureCache::new();
	text_string_texture_cache.set_default_font(false, font_bytes).expect("font");
	let text_raster = text_string_texture_cache.rasterize_text("Hi", "20px default", 2.0, 2, ShapingDirection::LeftToRight).expect("raster");
	assert_eq!(text_raster.coverage.len(), (text_raster.width * text_raster.height) as usize);
	assert!(text_raster.origin_x >= 2.0);
	assert!(text_raster.baseline_y > 0.0);
}
```

- `pub coverage: Vec<u8>` (field, since 0.4.0): 덮인 정도. (0 ~ 255, width * height 개, 위 줄부터)
  - returns Vec<u8>
- `pub color_pixels: Option<Vec<u8>>` (field, since 0.4.0): 색 글리프 층. (프리멀티플라이드 RGBA, width * height * 4 바이트, 색 글리프가 없으면 None)
  - returns Option<Vec<u8>>
- `pub width: i32` (field, since 0.4.0): 래스터 너비. (픽셀)
  - returns i32
- `pub height: i32` (field, since 0.4.0): 래스터 높이. (픽셀)
  - returns i32
- `pub origin_x: f64` (field, since 0.4.0): 래스터 왼쪽에서 펜 원점까지의 거리. (픽셀)
  - returns f64
- `pub baseline_y: f64` (field, since 0.4.0): 래스터 위에서 기준선까지의 거리. (픽셀)
  - returns f64
- `pub advance_width: f64` (field, since 0.4.0): 전진폭. (픽셀)
  - returns f64
- `pub font_ascent: f64` (field, since 0.4.0): 글꼴의 기준선 위 길이. (픽셀, 양수)
  - returns f64
- `pub font_descent: f64` (field, since 0.4.0): 글꼴의 기준선 아래 길이. (픽셀, 양수)
  - returns f64

## TextMetrics (struct) (Clone, Copy, Debug, Default)

문자열 측정 결과. (Canvas2D TextMetrics)
- actual_bounding_box_* 는 펜 원점(왼쪽 정렬, 알파벳 기준선)에서 글리프가 실제로 닿는 거리다. (왼쪽, 위, 아래는 그쪽으로 양수)

예제: 글을 재고 실제로 닿는 거리 보기

```rust
use vanilla::core::textstringtexturecache::TextStringTextureCache;
use vanilla::platform::find_fallback_font_file;

if let Some(source) = find_fallback_font_file("A", 400, false, false) {
	let font_bytes = std::fs::read(&source.path).expect("font file");
	let mut text_string_texture_cache = TextStringTextureCache::new();
	text_string_texture_cache.set_default_font(false, font_bytes).expect("font");
	let text_metrics = text_string_texture_cache.measure_text("20px default", "Hg");
	assert!(text_metrics.width > 0.0);
	assert!(text_metrics.font_ascent > 0.0);
	assert!(text_metrics.actual_bounding_box_ascent > 0.0);
	assert!(text_metrics.actual_bounding_box_descent > 0.0);
}
```

- `pub width: f64` (field, since 0.3.2): 전진폭. (픽셀)
  - returns f64
- `pub font_ascent: f64` (field, since 0.3.2): 글꼴의 기준선 위 길이. (첫 얼굴의 줄 높이 값, 양수)
  - returns f64
- `pub font_descent: f64` (field, since 0.3.2): 글꼴의 기준선 아래 길이. (첫 얼굴의 줄 높이 값, 양수)
  - returns f64
- `pub actual_bounding_box_left: f64` (field, since 0.4.0): 펜 원점에서 글리프 왼쪽 끝까지. (왼쪽이 양수)
  - returns f64
- `pub actual_bounding_box_right: f64` (field, since 0.4.0): 펜 원점에서 글리프 오른쪽 끝까지. (오른쪽이 양수)
  - returns f64
- `pub actual_bounding_box_ascent: f64` (field, since 0.4.0): 기준선에서 글리프 위 끝까지. (위가 양수)
  - returns f64
- `pub actual_bounding_box_descent: f64` (field, since 0.4.0): 기준선에서 글리프 아래 끝까지. (아래가 양수)
  - returns f64

## FontDescription (struct) (Clone, Debug)

폰트 문자열 해석 결과.
- font_weight 는 CSS 굵기다. ("bold" 700, 숫자, 없으면 400) is_bold 는 굵기가 600 이상인지다.

예제: 폰트 문자열 해석하기

```rust
use vanilla::core::textstringtexturecache::parse_font_string;

let font_description = parse_font_string("italic bold 20px \"My Font\", sans-serif");
assert_eq!(font_description.font_size, 20.0);
assert_eq!(font_description.font_weight, 700);
assert!(font_description.is_bold);
assert!(font_description.is_italic);
assert_eq!(font_description.family_name, "My Font");
assert_eq!(font_description.family_name_list, vec!["My Font", "sans-serif"]);
```

- `pub font_size: f32` (field, since 0.3.2): 글자 크기. (픽셀)
  - returns f32
- `pub font_weight: u16` (field, since 0.4.0): CSS 굵기. (1 ~ 1000, 없으면 400)
  - returns u16
- `pub is_bold: bool` (field, since 0.3.2): 굵기가 600 이상인지.
  - returns bool
- `pub is_italic: bool` (field, since 0.4.0): italic 이나 oblique 인지.
  - returns bool
- `pub family_name: String` (field, since 0.3.2): 목록의 첫 이름.
  - returns String
- `pub family_name_list: Vec<String>` (field, since 0.4.0): 쉼표로 이은 이름 목록. (앞 이름부터 찾는다)
  - 따옴표 친 이름이 일반 이름(serif, sans-serif, cursive, fantasy, monospace, system-ui, -webkit-body, math)과 같은 글자면 따옴표를 남긴다. ("'monospace'" → "\"monospace\"")
    크롬처럼 따옴표 친 것은 그 이름의 글꼴로, 따옴표 없는 것은 일반 이름으로 찾는다.
  - returns Vec<String>

## FontFileSource (struct) (Clone, Debug, PartialEq, Eq)

글꼴 파일 하나의 얼굴. (데스크탑 시스템 글꼴, platform 이 찾아 준다)
- face_index 를 모르면(맥) post_script_name 으로 모음 안의 얼굴을 찾고, 그것도 없으면 굵기와 기울기로 고른다.

예제: 운영체제가 고른 글꼴 파일을 시스템 글꼴 이름의 얼굴 후보로 더하기

```rust
use vanilla::core::textstringtexturecache::TextStringTextureCache;
use vanilla::platform::find_fallback_font_file;

let mut text_string_texture_cache = TextStringTextureCache::new();
assert!(!text_string_texture_cache.has_system_font());
if let Some(source) = find_fallback_font_file("A", 400, false, false) {
	assert!(source.path.exists());
	text_string_texture_cache.add_system_font_candidate("GameSans", 400, false, source);
	assert!(text_string_texture_cache.has_system_font());
}
```

- `pub path: std::path::PathBuf` (field, since 0.4.0): 글꼴 파일 경로.
  - returns std::path::PathBuf
- `pub face_index: Option<u32>` (field, since 0.4.0): 글꼴 모음(TTC) 안의 얼굴 번호. (모르면 None)
  - returns Option<u32>
- `pub post_script_name: Option<String>` (field, since 0.4.0): 얼굴의 PostScript 이름. (모르면 None)
  - returns Option<String>

## FamilyFontFace (struct) (Clone, Debug, PartialEq, Eq)

시스템 글꼴 이름이 가진 얼굴 하나. (운영체제가 알려 주는 굵기와 기울임, 얼굴을 고르는 CSS 굵기 규칙의 후보)

예제: 굵은 얼굴 하나 지어 보기

```rust
use vanilla::core::textstringtexturecache::{FamilyFontFace, FontFileSource};

let face = FamilyFontFace {
	source: FontFileSource { path: std::path::PathBuf::from("GameSans-Bold.ttf"), face_index: None, post_script_name: None },
	weight: 700,
	is_italic: false,
};
assert_eq!(face.weight, 700);
```

- `pub source: FontFileSource` (field, since 0.4.0): 글꼴 파일과 얼굴.
  - returns FontFileSource
- `pub weight: u16` (field, since 0.4.0): 얼굴의 CSS 굵기. (100 ~ 900)
  - returns u16
- `pub is_italic: bool` (field, since 0.4.0): 기울인 얼굴이면 true.
  - returns bool

## TextStringTextureCache (struct) (Default)

문자열 텍스처 캐시. (원본 TextStringTextureCache, 글꼴 얼굴 등록, 글 재기, 문자열을 텍스처로 굽기)
- Graphic 이 하나 든다. (get_text_string_texture_cache) 굽기(get_entry)는 GL 이 있어야 하고, 글꼴 등록과 재기와 래스터는 GL 없이 된다.

예제: 글꼴을 올리고 글 재기

```rust
use vanilla::core::textstringtexturecache::TextStringTextureCache;
use vanilla::platform::find_fallback_font_file;

let mut text_string_texture_cache = TextStringTextureCache::new();
assert!(text_string_texture_cache.register_font("GameFont", false, vec![0, 1, 2, 3]).is_err());
if let Some(source) = find_fallback_font_file("A", 400, false, false) {
	let font_bytes = std::fs::read(&source.path).expect("font file");
	text_string_texture_cache.register_font("GameFont", false, font_bytes).expect("font");
	assert_eq!(text_string_texture_cache.get_font_face_count("gamefont"), 1);
	let text_metrics = text_string_texture_cache.measure_text("20px GameFont", "Hello");
	assert!(text_metrics.width > 0.0);
}
```

- `pub fn new() -> TextStringTextureCache` (constructor, since 0.3.2): 생성.
  - returns TextStringTextureCache: 글꼴도 구운 문자열도 없는 캐시. (안티앨리어싱 켬, 다시 굽기 끔, 웹은 브라우저로 굽는다)
- `pub fn begin_frame(&mut self)` (method, since 0.3.2): 프레임 시작. (LRU 순서를 프레임 번호로 센다)
- `pub fn is_browser_raster(&self) -> bool` (method, since 0.4.0): 브라우저 Canvas2D 로 굽고 재는지. (웹은 원본처럼 늘 참, 데스크탑은 거짓)
  - returns bool: 웹이면 true, 데스크탑이면 false.
- `pub fn register_font(&mut self, family_name: &str, is_bold: bool, font_bytes: Vec<u8>) -> Result<(), String>` (method, since 0.3.2): 폰트 등록. (폰트 문자열의 이름으로 찾는다. 대소문자 구분 없음, 굵으면 굵기 700 얼굴, 아니면 400)
  - `family_name` &str: 폰트 문자열에서 쓸 이름. (앞뒤 빈칸과 따옴표는 뗀다)
  - `is_bold` bool: true 면 굵기 700 얼굴, false 면 400 얼굴.
  - `font_bytes` Vec<u8>: 글꼴 파일 바이트. (ttf, otf, ttc 는 0 번 얼굴, woff, woff2 는 풀어서 읽는다)
  - returns Result<(), String>: 올렸으면 Ok. 글꼴을 읽지 못하면 Err(까닭) 이고 아무것도 바뀌지 않는다.
- `pub fn register_font_face(&mut self, family_name: &str, font_face_descriptors: FontFaceDescriptors, font_bytes: Vec<u8>) -> Result<(), String>` (method, since 0.4.0): 글꼴 얼굴 등록. (원본 new FontFace(family, url, descriptors) 를 document.fonts 에 더하기)
  - 같은 이름에 같은 열쇠(source_key), 굵기, 기울기의 얼굴이 있으면 바꾼다. 없으면 맨 뒤(가장 먼저 그리는 자리)에 둔다.
    set_font_face_order 로 차례를 정한 이름이면 그 차례에 맞춰 놓는다.
  - set_rebake_text_on_font_load 로 켰으면 그 이름을 쓰는 폰트 문자열로 구웠고 이 얼굴의 글자 범위에 든 글자가 있는 문자열은 버린다. (다음에 그릴 때 이 얼굴로 다시 굽는다)
  - `family_name` &str: 이름. (앞뒤 빈칸과 따옴표는 떼고 대소문자는 가리지 않는다)
  - `font_face_descriptors` FontFaceDescriptors: 얼굴의 굵기, 기울기, 글자 범위, 열쇠.
  - `font_bytes` Vec<u8>: 글꼴 파일 바이트. (ttf, otf, ttc 는 0 번 얼굴, woff, woff2 는 풀어서 읽는다)
  - returns Result<(), String>: 올렸으면 Ok. 글꼴을 읽지 못하면 Err(까닭) 이고 아무것도 바뀌지 않는다.

  예제: 라틴 글자 범위 얼굴 올리고 지우기

  ```rust
  use vanilla::core::textstringtexturecache::TextStringTextureCache;
  use vanilla::platform::find_fallback_font_file;
  use vanilla::FontFaceDescriptors;
  
  if let Some(source) = find_fallback_font_file("A", 400, false, false) {
  	let font_bytes = std::fs::read(&source.path).expect("font file");
  	let mut text_string_texture_cache = TextStringTextureCache::new();
  	let mut font_face_descriptors = FontFaceDescriptors::create_from_css("400", "normal", "U+0000-00FF");
  	font_face_descriptors.source_key = String::from("latin");
  	text_string_texture_cache.register_font_face("GameFont", font_face_descriptors, font_bytes).expect("font");
  	assert_eq!(text_string_texture_cache.get_font_face_count("GameFont"), 1);
  	assert!(text_string_texture_cache.unregister_font_face("GameFont", "latin"));
  	assert_eq!(text_string_texture_cache.get_font_face_count("GameFont"), 0);
  }
  ```

- `pub fn unregister_font_face(&mut self, family_name: &str, source_key: &str) -> bool` (method, since 0.4.0): 글꼴 얼굴 지우기. (원본 document.fonts.delete, 열쇠가 같은 얼굴 모두, 지운 것이 있으면 true)
  - `family_name` &str: 이름. (앞뒤 빈칸은 떼고 대소문자는 가리지 않는다)
  - `source_key` &str: 지울 얼굴의 열쇠. (FontFaceDescriptors 의 source_key)
  - returns bool: 지운 얼굴이 있으면 true.
- `pub fn set_font_face_order(&mut self, family_name: &str, source_key_list: &[String])` (method, since 0.4.0): 한 이름의 얼굴 차례 정하기. (얼굴 열쇠 목록, 뒤가 먼저 그린다. 원본 uifont 가 document.fonts 에서 빼고 차례대로 다시 더하는 것)
  - 목록에 없는 얼굴은 목록의 얼굴보다 뒤로(나중에 그리게) 밀리지 않고 앞에 남는다. 아직 받지 않은 얼굴의 열쇠도 넣어 둘 수 있다. (받으면 그 자리에 놓인다)
  - 차례가 바뀌면 그 이름으로 구운 문자열을 모두 버린다.
  - `family_name` &str: 이름. (앞뒤 빈칸은 떼고 대소문자는 가리지 않는다)
  - `source_key_list` &[String]: 얼굴 열쇠 목록. (뒤가 먼저 그린다)
- `pub fn clear(&mut self)` (method, since 0.4.0): 모든 엔트리와 글리프 버리기. (원본 clear, 아틀라스 장 텍스처는 다음 굽기 때 지운다)
- `pub fn set_default_font(&mut self, is_bold: bool, font_bytes: Vec<u8>) -> Result<(), String>` (method, since 0.3.2): 기본 폰트 설정. (이름을 찾지 못한 폰트 문자열과 글자 대체에 쓴다, 굵으면 굵기 700 얼굴)
  - `is_bold` bool: true 면 굵기 700 얼굴, false 면 400 얼굴. (같은 굵기의 기울이지 않은 얼굴은 바꾼다)
  - `font_bytes` Vec<u8>: 글꼴 파일 바이트. (ttf, otf, ttc 는 0 번 얼굴, woff, woff2 는 풀어서 읽는다)
  - returns Result<(), String>: 설정했으면 Ok. (구운 문자열은 모두 버린다) 글꼴을 읽지 못하면 Err(까닭).
- `pub fn add_fallback_font(&mut self, font_bytes: Vec<u8>) -> Result<(), String>` (method, since 0.3.2): 대체 폰트 추가. (앞 폰트들에 없는 글자를 찾는다)
  - `font_bytes` Vec<u8>: 글꼴 파일 바이트. (ttf, otf, ttc 는 0 번 얼굴, woff, woff2 는 풀어서 읽는다)
  - returns Result<(), String>: 더했으면 Ok. (구운 문자열은 모두 버린다) 글꼴을 읽지 못하면 Err(까닭).
- `pub fn set_text_antialias_enabled(&mut self, value: bool)` (method, since 0.4.0): 글자 안티앨리어싱 켬 / 끔. (원본 setTextAntialiasEnabled, 바꾼 다음 그리는 글자부터 그 방식으로 굽는다)
  - `value` bool: true 면 켠다. (기본 켬)
- `pub fn is_text_antialias_on(&self) -> bool` (method, since 0.4.0): 글자 안티앨리어싱이 켜져 있는지. (원본 isTextAntialiasOn)
  - returns bool: 켜져 있으면 true.
- `pub fn set_rebake_text_on_font_load(&mut self, is_rebake_text_on_font_load: bool)` (method, since 0.4.0): 글꼴 얼굴을 새로 올리면 그 얼굴의 글자로 구운 문자열을 버릴지 설정. (원본 EngineConfiguration.rebakeTextOnFontLoad, 엔진이 그래픽을 넘겨받을 때 정한다)
  - `is_rebake_text_on_font_load` bool: true 면 버린다. (기본 끔)
- `pub fn get_font_registration_count(&self) -> u64` (method, since 0.4.0): 글꼴을 등록한 횟수. (등록, 지우기, 차례, 기본 글꼴, 대체 글꼴. 재 둔 글 폭을 다시 잴지 가린다)
  - returns u64: 등록한 횟수. (new 뒤 0 에서 늘기만 한다)
- `pub fn set_system_font_chain(&mut self, family_name_list: Vec<String>)` (method, since 0.4.0): 시스템 글꼴 사슬 정하기. (데스크탑, 원본 SYSTEM_FONT_STRING 처럼 기본 글꼴 이름 default 를 청한 폰트 문자열에서 기본 폰트 뒤에 이름 차례로 찾는다)
  - 켜면 폰트 문자열의 올리지 않은 이름도 운영체제 글꼴에서 찾는다. ("16px Arial" 이 시스템의 Arial 로 그려진다, 브라우저와 같다)
  - 얼굴은 그 굵기와 기울기의 글자를 처음 그리거나 잴 때 읽는다.
  - `family_name_list` Vec<String>: 기본 폰트 뒤에 찾을 이름 차례. (대소문자는 가리지 않는다)
- `pub fn add_system_font_candidate(&mut self, family_name: &str, weight: u16, is_italic: bool, source: FontFileSource)` (method, since 0.4.0): 시스템 글꼴 이름에 얼굴 후보 파일 더하기. (데스크탑, 그 이름을 사슬 맨 뒤에 둔다. 운영체제에서 찾지 않고 파일을 주는 경우)
  - 얼굴 번호가 없으면 PostScript 이름, 그것도 없으면 청한 굵기와 기울기로 모음 안의 얼굴을 고른다. 가변 글꼴은 굵기를 축 값으로 만든다.
  - `family_name` &str: 시스템 글꼴 이름. (앞뒤 빈칸은 떼고 대소문자는 가리지 않는다)
  - `weight` u16: 이 후보의 굵기. (CSS 굵기 1 ~ 1000)
  - `is_italic` bool: 기울인 얼굴인지.
  - `source` FontFileSource: 글꼴 파일과 얼굴. (같은 파일, 굵기, 기울기의 후보는 한 번만 든다)
- `pub fn set_system_font_fallback_enabled(&mut self, value: bool)` (method, since 0.4.0): 운영체제 대체 글꼴 켬 / 끔. (데스크탑, 켜면 어느 글꼴에도 없는 글자를 운영체제가 고른 글꼴로 그린다. 대체 글꼴 후보 파일이 있으면 그것이 먼저다)
  - `value` bool: true 면 켠다. (기본 끔)
- `pub fn has_system_font(&self) -> bool` (method, since 0.4.0): 시스템 글꼴 사슬이나 후보가 있는지. (데스크탑)
  - returns bool: 사슬에 찾은 이름이나 후보가 있는 이름이 있거나, 사슬을 켰고 이름이 하나라도 있으면 true.
- `pub fn add_fallback_font_candidate(&mut self, font_path: std::path::PathBuf)` (method, since 0.4.0): 대체 글꼴 후보 파일 더하기. (데스크탑, 원본 브라우저가 글꼴에 없는 글자를 시스템 글꼴로 그리는 자리)
  - 바로 읽지 않는다. 등록된 어느 글꼴에도 없는 글자를 재거나 구울 때 앞의 후보부터 읽어 대체 폰트로 더한다. (큰 한중일 글꼴을 처음에 읽지 않게)
  - 없는 파일, 읽지 못하는 파일은 넘긴다.
  - `font_path` std::path::PathBuf: 글꼴 파일 경로. (더할 때 색 글리프 표가 있는지만 엿본다)
- `pub fn has_default_font(&self) -> bool` (method, since 0.3.2): 기본 폰트가 있는지.
  - returns bool: 기본 폰트 얼굴이 하나라도 있으면 true.
- `pub fn get_font_face_count(&self, family_name: &str) -> usize` (method, since 0.4.0): 이름에 올린 얼굴 수. (그 이름이 없으면 0)
  - `family_name` &str: 이름. (앞뒤 빈칸은 떼고 대소문자는 가리지 않는다)
  - returns usize: 얼굴 수.
- `pub fn measure_text(&self, font_string: &str, text: &str) -> TextMetrics` (method, since 0.3.2): 문자열 측정. (문단 방향은 왼쪽에서 오른쪽, 원본 measureTextMetrics 도 방향을 주지 않는다)
  - `font_string` &str: 폰트 문자열. (Canvas2D font 꼴, parse_font_string)
  - `text` &str: 잴 글.
  - returns TextMetrics: 잰 값. (픽셀) 데스크탑에서 그릴 얼굴이 하나도 없으면 모두 0 이다.

  예제: 같은 글은 한 번만 잰다

  ```rust
  use vanilla::core::textstringtexturecache::TextStringTextureCache;
  use vanilla::platform::find_fallback_font_file;
  
  if let Some(source) = find_fallback_font_file("A", 400, false, false) {
  	let font_bytes = std::fs::read(&source.path).expect("font file");
  	let mut text_string_texture_cache = TextStringTextureCache::new();
  	text_string_texture_cache.set_default_font(false, font_bytes).expect("font");
  	let small_metrics = text_string_texture_cache.measure_text("20px default", "abc");
  	text_string_texture_cache.measure_text("20px default", "abc");
  	assert_eq!(text_string_texture_cache.get_measure_count(), 1);
  	let large_metrics = text_string_texture_cache.measure_text("40px default", "abc");
  	assert!(large_metrics.width > small_metrics.width);
  	assert_eq!(text_string_texture_cache.get_measure_count(), 2);
  }
  ```

- `pub fn get_measure_count(&self) -> usize` (method, since 0.4.0): 잰 글 수. (캐시에 든 것, 시험과 통계용)
  - returns usize: 캐시에 든 잰 글 수. (넘치면 반을 버린다, 상한 2048)
- `pub fn get_entry(&mut self, gl: &GlContext, text_draw_kind: TextDrawKind, text: &str, font_string: &str, line_width: f64, bake_scale: f64, direction: ShapingDirection) -> Option<TextEntry>` (method, since 0.3.2): 글 배치 엔트리 반환. (없으면 배치하고 처음 보는 글리프만 아틀라스에 굽는다, direction 은 문단 방향. 원본 getEntry 의 textDirection)
  - 글리프 아틀라스: 1024 x 1024 장에 글리프를 한 번만 굽는다. 가장 나중에 연 장에만 이어 놓고, 차면 새 장, 8 장을 넘으면 가장 오래 안 쓴 장을 비운다.
    비운 장의 텍스처는 버릴 목록에 두고 다음 get_entry 때 지운다. (Graphic 은 쌓아 둔 묶음을 먼저 내보내고 바로 지운다)
  - 글리프 자리는 셰이퍼가 준 자리를 크롬 스키아처럼 정수 자리와 서브픽셀 4 칸으로 나눈다. 글자 덩어리(한글, 숫자 같은 글자는 글자마다, 라틴 낱말은 낱말째)마다 한 칸에 굽는다. 256px 넘는 글꼴과 오른쪽에서 왼쪽 글은 문자열째 굽는다.
  - `gl` &GlContext: 텍스처를 만들 GL 컨텍스트.
  - `text_draw_kind` TextDrawKind: 굽는 방식.
  - `text` &str: 구울 글.
  - `font_string` &str: 폰트 문자열. (Canvas2D font 꼴, parse_font_string)
  - `line_width` f64: 외곽선 두께. (논리 픽셀, Stroke 로 구울 때만 쓰지만 키에는 늘 든다)
  - `bake_scale` f64: 굽는 배율. (글자 크기에 곱한 크기로 굽고, TextEntry 의 길이는 이것으로 나눈 값이다)
  - `direction` ShapingDirection: 문단 방향.
  - returns Option<TextEntry>: 글 배치 엔트리. (같은 키면 캐시의 것) 글이 비었거나, 데스크탑에서 그릴 얼굴이 하나도 없거나, 텍스처를 만들지 못하면 None.

  예제: 같은 키로 다시 부르면 굽지도 올리지도 않는다

  ```rust
  use vanilla::core::textstringtexturecache::{TextDrawKind, TextStringTextureCache};
  use vanilla::ShapingDirection;
  
  fn bake_outline(text_string_texture_cache: &mut TextStringTextureCache, gl: &vanilla::GlContext) {
  	text_string_texture_cache.get_entry(gl, TextDrawKind::Stroke, "Hello", "bold 20px default", 3.0, 1.5, ShapingDirection::LeftToRight);
  	let first_statistics = text_string_texture_cache.read_atlas_statistics();
  	text_string_texture_cache.get_entry(gl, TextDrawKind::Stroke, "Hello", "bold 20px default", 3.0, 1.5, ShapingDirection::LeftToRight);
  	assert_eq!(text_string_texture_cache.read_atlas_statistics(), first_statistics);
  }
  ```

- `pub fn rasterize_text(&self, text: &str, font_string: &str, bake_scale: f64, padding: i32, direction: ShapingDirection) -> Option<TextRaster>` (method, since 0.4.0): 글의 모양만 래스터로 받기. (텍스처로 올리지 않는다, 그림자를 깐 글처럼 따로 굽는 쪽이 쓴다)
  - 웹은 원본처럼 브라우저 Canvas2D 로 받는다. 데스크탑에서 글꼴이 하나도 없으면 None.
  - `text` &str: 글.
  - `font_string` &str: 폰트 문자열. (Canvas2D font 꼴, parse_font_string)
  - `bake_scale` f64: 굽는 배율. (글자 크기에 곱한다)
  - `padding` i32: 가장자리 여백. (픽셀, 1 보다 작으면 1)
  - `direction` ShapingDirection: 문단 방향.
  - returns Option<TextRaster>: 래스터. 글이 비었거나 데스크탑에서 그릴 얼굴이 하나도 없으면 None.
- `pub fn rasterize_text_with_color(&self, text: &str, font_string: &str, bake_scale: f64, padding: i32, direction: ShapingDirection, color: Color) -> Option<TextRaster>` (method, since 0.4.0): 글자 색을 알려 글의 모양만 래스터로 받기. (rasterize_text 와 같고, 맥 데스크탑은 크롬처럼 글자 색 밝기로 덮인 정도를 감마 전보정한다)
  - 원본이 글 색 그대로 Canvas2D 에 굽는 쪽(그림자를 깐 글, 2D 캔버스의 fillText)이 쓴다. 흰색으로 굽고 색을 곱하는 글은 rasterize_text 와 같다.
  - `text` &str: 글.
  - `font_string` &str: 폰트 문자열. (Canvas2D font 꼴, parse_font_string)
  - `bake_scale` f64: 굽는 배율. (글자 크기에 곱한다)
  - `padding` i32: 가장자리 여백. (픽셀, 1 보다 작으면 1)
  - `direction` ShapingDirection: 문단 방향.
  - `color` Color: 글자 색. (알파는 쓰지 않는다, 그라데이션이나 패턴으로 칠하면 원본 스키아처럼 회색 0.5)
  - returns Option<TextRaster>: 래스터. 글이 비었거나 데스크탑에서 그릴 얼굴이 하나도 없으면 None.

  예제: 검은 글의 덮인 정도 받기

  ```rust
  use vanilla::core::textstringtexturecache::TextStringTextureCache;
  use vanilla::platform::find_fallback_font_file;
  use vanilla::{Color, ShapingDirection};
  
  if let Some(source) = find_fallback_font_file("A", 400, false, false) {
  	let mut text_string_texture_cache = TextStringTextureCache::new();
  	text_string_texture_cache.set_default_font(false, std::fs::read(&source.path).expect("font file")).expect("font");
  	let text_raster = text_string_texture_cache.rasterize_text_with_color("Ag", "24px default", 1.0, 2, ShapingDirection::LeftToRight, Color::black()).expect("raster");
  	assert_eq!(text_raster.coverage.len(), (text_raster.width * text_raster.height) as usize);
  	assert!(text_raster.coverage.iter().any(|value| *value == 255));
  }
  ```

- `pub fn rasterize_character(&self, character: &str, font_string: &str) -> Option<(textshaping::GlyphRaster, f32, f32, f32)>` (method, since 0.4.0): 글리프 하나 래스터. (글자 아틀라스가 쓴다, 글리프 번호는 글자로 찾는다. 웹은 브라우저 Canvas2D 로, 데스크탑에서 글꼴이 하나도 없으면 None)
  - 돌려주는 것: (래스터, 전진폭, 글꼴 위 길이, 글꼴 아래 길이) 길이 단위는 픽셀.
  - `character` &str: 글자 묶음 하나. (결합 부호가 붙어 여러 글리프가 되어도 한 장에 모은다)
  - `font_string` &str: 폰트 문자열. (Canvas2D font 꼴, parse_font_string)
  - returns Option<(textshaping::GlyphRaster, f32, f32, f32)>: (래스터, 전진폭, 글꼴 위 길이, 글꼴 아래 길이). 그릴 글리프가 없으면(빈칸) 빈 래스터. 데스크탑에서 그릴 얼굴이 하나도 없으면 None.

  예제: 글자 하나의 래스터와 전진폭

  ```rust
  use vanilla::core::textstringtexturecache::TextStringTextureCache;
  use vanilla::platform::find_fallback_font_file;
  
  if let Some(source) = find_fallback_font_file("A", 400, false, false) {
  	let font_bytes = std::fs::read(&source.path).expect("font file");
  	let mut text_string_texture_cache = TextStringTextureCache::new();
  	text_string_texture_cache.set_default_font(false, font_bytes).expect("font");
  	let (glyph_raster, advance_width, font_ascent, _) = text_string_texture_cache.rasterize_character("A", "32px default").expect("glyph");
  	assert!(glyph_raster.width > 0 && glyph_raster.height > 0);
  	assert!(advance_width > 0.0 && font_ascent > 0.0);
  	let (space_raster, space_advance_width, _, _) = text_string_texture_cache.rasterize_character(" ", "32px default").expect("space");
  	assert_eq!(space_raster.width, 0);
  	assert!(space_advance_width > 0.0);
  }
  ```

- `pub fn get_entry_count(&self) -> usize` (method, since 0.3.2): 글 배치 엔트리 수.
  - returns usize: 캐시에 든 글 배치 엔트리 수. (상한 1024)
- `pub fn read_atlas_statistics(&self) -> TextAtlasStatistics` (method, since 0.4.0): 글리프 아틀라스 통계. (원본 readAtlasStatistics, 시험과 통계용: 장 수, 글리프 수, 지금까지 구운 글리프 수, 지금까지 올린 수, 엔트리 수)
  - returns TextAtlasStatistics: 지금의 통계.

  예제: 처음 굽는 글은 아틀라스 장을 열고 엔트리 하나를 더한다

  ```rust
  use vanilla::core::textstringtexturecache::{TextDrawKind, TextStringTextureCache};
  use vanilla::ShapingDirection;
  
  fn bake_once(text_string_texture_cache: &mut TextStringTextureCache, gl: &vanilla::GlContext) {
  	let entry_count = text_string_texture_cache.read_atlas_statistics().entry_count;
  	text_string_texture_cache.get_entry(gl, TextDrawKind::Fill, "Score 100", "20px default", 0.0, 1.0, ShapingDirection::LeftToRight);
  	let text_atlas_statistics = text_string_texture_cache.read_atlas_statistics();
  	assert!(text_atlas_statistics.atlas_page_count >= 1);
  	assert!(text_atlas_statistics.baked_glyph_count >= 1);
  	assert_eq!(text_atlas_statistics.entry_count, entry_count + 1);
  }
  ```

## Functions and constants

- `pub fn watch_unresolved_family_characters(family_name: &str)` (method, since 0.4.0): 이름의 얼굴이 없는 글자 지켜보기 시작. (원본 브라우저는 FontFace 를 document.fonts 에 올려 두면 캔버스가 그 글꼴로 글을 그릴 때 그 글자의 범위에 든 얼굴을 받기 시작한다)
  - 러스트 판은 얼굴을 받은 뒤에 올리므로, 지켜보는 이름으로 재거나 구운 글에서 올린 얼굴의 글자 범위에 들지 않은 글자를 모아 받는 쪽(UIFont)이 꺼내 받는다.
  - `family_name` &str: 지켜볼 이름. (앞뒤 빈칸은 떼고 대소문자는 가리지 않는다)
- `pub fn take_unresolved_family_characters(family_name: &str) -> String` (method, since 0.4.0): 지켜보는 이름에서 얼굴이 없던 글자 꺼내기. (꺼내면 비운다, 지켜보지 않는 이름이면 빈 글)
  - `family_name` &str: 지켜보는 이름. (앞뒤 빈칸은 떼고 대소문자는 가리지 않는다)
  - returns String: 모인 글자를 코드 포인트 차례로 이은 글. (빈칸과 제어 글자는 모으지 않는다)

  예제: 올린 얼굴이 없는 이름으로 잰 글자 모으기

  ```rust
  use vanilla::core::textstringtexturecache::{take_unresolved_family_characters, watch_unresolved_family_characters, TextStringTextureCache};
  
  watch_unresolved_family_characters("GameFont");
  let text_string_texture_cache = TextStringTextureCache::new();
  text_string_texture_cache.measure_text("16px GameFont", "b a");
  assert_eq!(take_unresolved_family_characters("gamefont"), "ab");
  assert_eq!(take_unresolved_family_characters("GameFont"), "");
  assert_eq!(take_unresolved_family_characters("OtherFont"), "");
  ```

- `pub fn measure_normal_line_height_without_graphic(font_string: &str) -> Option<f64>` (method, since 0.4.0): Graphic 없이 CSS line-height normal 의 줄 높이 재기. (폰트 문자열, 크롬은 첫째로 쓸 수 있는 글꼴(primary font)의 LineSpacing)
  - 데스크탑은 그릴 때와 같은 얼굴 고르기의 첫 얼굴로 셈한다. (LoadedFont::calculate_normal_line_height) 글꼴이 하나도 없으면 None 이다.
  - 웹은 브라우저가 놓은 줄 높이를 읽는다. (platform/web/systemfont.rs)
  - `font_string` &str: Canvas2D font 꼴 글. ("bold 16px sans-serif" 처럼)
  - returns Option<f64>: 줄 높이. (CSS 픽셀) 데스크탑은 글꼴을 등록한 글자 캐시가 없거나 고를 얼굴이 없으면, 웹은 문서가 없거나 잰 높이가 0 이하면 None.
- `pub fn measure_text_without_graphic(font_string: &str, text: &str) -> Option<TextMetrics>` (method, since 0.4.0): Graphic 없이 글 재기. (폰트 문자열과 글, 원본의 공용 캔버스 measureText 자리)
  - 그릴 때와 같은 얼굴 고르기와 모양 잇기로 잰다.
  - 웹은 브라우저 Canvas2D 로 잰다. 데스크탑은 글꼴이 하나도 없으면 None 이다. (그릴 때도 글이 나오지 않는 상태)
  - `font_string` &str: 폰트 문자열. (Canvas2D font 꼴, parse_font_string)
  - `text` &str: 잴 글.
  - returns Option<TextMetrics>: 잰 값. (픽셀) 데스크탑에서 이 스레드에 글꼴을 등록한 캐시가 아직 없거나, 그 폰트 문자열로 고를 얼굴이 하나도 없으면 None.

  예제: 글꼴을 등록한 뒤 Graphic 없이 재기

  ```rust
  use vanilla::core::textstringtexturecache::{measure_text_without_graphic, TextStringTextureCache};
  use vanilla::platform::find_fallback_font_file;
  
  assert!(measure_text_without_graphic("16px default", "Hello").is_none());
  if let Some(source) = find_fallback_font_file("A", 400, false, false) {
  	let font_bytes = std::fs::read(&source.path).expect("font file");
  	let mut text_string_texture_cache = TextStringTextureCache::new();
  	text_string_texture_cache.set_default_font(false, font_bytes).expect("font");
  	let text_metrics = measure_text_without_graphic("16px default", "Hello").expect("metrics");
  	assert!(text_metrics.width > 0.0);
  }
  ```

- `pub fn parse_font_string(font_string: &str) -> FontDescription` (method, since 0.3.2): 폰트 문자열 해석. (Canvas2D font 의 CSS font 줄임 꼴, "bold 16px DOSGothic" → 크기 16, 굵기 700, 이름 DOSGothic)
  - 크기 앞의 낱말: normal, italic / oblique(뒤의 각도는 넘긴다)는 기울임, small-caps, 늘이기 낱말(condensed 등)은 넘긴다.
    bold / bolder 는 700, lighter 는 100, 숫자는 굵기(1 ~ 1000). 그 밖의 낱말이 오면 틀린 문자열이다.
  - 크기: 절대 길이(px, pt, pc, in, cm, mm, q), 글꼴에 대는 길이(em, ex, ch, cap, ic, lh, rem, rex, rch, rcap, ric, rlh), %, 뷰포트 단위, 이름 크기, larger, smaller,
    calc() 같은 CSS 수학 함수. 뒤의 "/줄높이"는 읽고 넘긴다. (캔버스는 줄높이를 쓰지 않는다) 셈은 parse_css_font_size 가 크롬과 같게 한다.
    원본이 글을 굽고 재는 캔버스는 문서에 붙이지 않아 부모 글꼴이 크롬의 마지막 대체 글꼴(맥 Times) 10px 이고, 뿌리는 문서의 표준 글꼴 16px 이다.
    웹은 절대 길이 밖의 크기를 브라우저 캔버스에 넣고 다시 읽어 받는다. (platform/web/systemfont.rs 의 resolve_font_size)
  - 크기 뒤는 쉼표로 이은 이름 목록이다. 따옴표 이름은 따옴표를 떼고, 따옴표 없는 이름은 낱말을 빈칸 하나로 잇는다. 그리는 쪽이 목록의 앞 이름부터 찾는다.
  - 틀린 문자열(크기나 이름이 없음, 음수 크기, 모르는 낱말)은 캔버스의 처음 값 "10px sans-serif" 로 본다.
  - `font_string` &str: 폰트 문자열.
  - returns FontDescription: 해석 결과. 틀린 문자열이면 크기 10, 굵기 400, 이름 sans-serif.

  예제: CSS 단위, 줄높이, 틀린 문자열

  ```rust
  use vanilla::core::textstringtexturecache::parse_font_string;
  
  assert_eq!(parse_font_string("12pt a").font_size, 16.0);
  assert_eq!(parse_font_string("1in a").font_size, 96.0);
  let line_height_description = parse_font_string("bold 16px/20px a, b");
  assert_eq!(line_height_description.font_size, 16.0);
  assert_eq!(line_height_description.family_name_list, vec!["a", "b"]);
  let invalid_description = parse_font_string("16px");
  assert_eq!(invalid_description.font_size, 10.0);
  assert_eq!(invalid_description.family_name, "sans-serif");
  ```

- `pub fn set_font_viewport_size(width: f32, height: f32)` (method, since 0.4.0): 폰트 문자열의 뷰포트 단위(vw, vh 같은)가 대는 창 크기 정하기. (논리 픽셀, 원본 window.innerWidth / innerHeight 자리. 데스크탑 플랫폼이 창 크기가 바뀔 때 부른다)
  - `width` f32: 창 너비. (논리 픽셀)
  - `height` f32: 창 높이. (논리 픽셀)

## TextDrawKind (enum) (Clone, Copy, Debug, PartialEq, Eq, Hash)

굽는 방식.

- `Fill`: 채워 굽기. (원본 fillText)
- `Stroke`: 외곽선으로 굽기. (원본 strokeText, 두께는 line_width)
