MCPcopy Create free account
hub / github.com/Logicalshift/flo_draw / decode_font_data_ttf

Method decode_font_data_ttf

canvas/src/decoding.rs:1385–1397  ·  view source on GitHub ↗

Decodes TTF font data

(chr: char, font_id: FontId, bytes: DecodeBytes)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

decodeMethod · 0.80
readyMethod · 0.80
to_bytesMethod · 0.80

Tested by

no test coverage detected