Decodes the DrawText command (which is one of the more complicated ones, with a font ID, a string and a set of coordinates to deal with)
(chr: char, font_id: DecodeFontId, string: DecodeString, mut coords: String)
| 1262 | /// to deal with) |
| 1263 | /// |
| 1264 | fn decode_font_draw_text(chr: char, font_id: DecodeFontId, string: DecodeString, mut coords: String) -> Result<(DecoderState, Option<Draw>), DecoderError> { |
| 1265 | use PartialResult::*; |
| 1266 | |
| 1267 | match (font_id, string.ready(), coords.len()) { |
| 1268 | (MatchMore(font_id), _, _) => Ok((DecoderState::FontDrawText(Self::decode_font_id(chr, font_id)?, string, coords), None)), |
| 1269 | (FullMatch(font_id), false, _) => Ok((DecoderState::FontDrawText(FullMatch(font_id), string.decode(chr)?, coords), None)), |
| 1270 | |
| 1271 | (FullMatch(font_id), true, 0) | |
| 1272 | (FullMatch(font_id), true, 1) | |
| 1273 | (FullMatch(font_id), true, 2) | |
| 1274 | (FullMatch(font_id), true, 3) | |
| 1275 | (FullMatch(font_id), true, 4) | |
| 1276 | (FullMatch(font_id), true, 5) | |
| 1277 | (FullMatch(font_id), true, 6) | |
| 1278 | (FullMatch(font_id), true, 7) | |
| 1279 | (FullMatch(font_id), true, 8) | |
| 1280 | (FullMatch(font_id), true, 9) | |
| 1281 | (FullMatch(font_id), true, 10) => { coords.push(chr); Ok((DecoderState::FontDrawText(FullMatch(font_id), string, coords), None)) }, |
| 1282 | |
| 1283 | (FullMatch(font_id), true, _) => { |
| 1284 | coords.push(chr); |
| 1285 | |
| 1286 | let mut coords = coords.chars(); |
| 1287 | let x = Self::decode_f32(&mut coords)?; |
| 1288 | let y = Self::decode_f32(&mut coords)?; |
| 1289 | |
| 1290 | Ok((DecoderState::None, Some(Draw::DrawText(font_id, string.to_string()?, x, y)))) |
| 1291 | } |
| 1292 | } |
| 1293 | } |
| 1294 | |
| 1295 | /// |
| 1296 | /// Decodes the 'begin layout' instruction |