Decodes TTF font data
(chr: char, font_id: FontId, bytes: DecodeBytes)
| 1383 | /// Decodes TTF font data |
| 1384 | /// |
| 1385 | fn decode_font_data_ttf(chr: char, font_id: FontId, bytes: DecodeBytes) -> Result<(DecoderState, Option<Draw>), DecoderError> { |
| 1386 | // Decode the next byte |
| 1387 | let bytes = bytes.decode(chr)?; |
| 1388 | |
| 1389 | // Generate the result once finished |
| 1390 | if bytes.ready() { |
| 1391 | let bytes = bytes.to_bytes()?; |
| 1392 | let font = CanvasFontFace::from_bytes(bytes); |
| 1393 | Ok((DecoderState::None, Some(Draw::Font(font_id, FontOp::UseFontDefinition(font))))) |
| 1394 | } else { |
| 1395 | Ok((DecoderState::FontOpTtf(font_id, bytes), None)) |
| 1396 | } |
| 1397 | } |
| 1398 | |
| 1399 | /// |
| 1400 | /// Decides a text layout instruction |