use crate::basics::{VertexSource, PATH_CMD_LINE_TO, PATH_CMD_MOVE_TO, PATH_CMD_STOP};
use crate::bounding_rect::bounding_rect_single;
use crate::conv_stroke::ConvStroke;
use crate::conv_transform::ConvTransform;
use crate::math_stroke::{LineCap, LineJoin};
use crate::trans_affine::TransAffine;
#[rustfmt::skip]
static GSV_DEFAULT_FONT: &[u8] = &[
0x40,0x00,0x6c,0x0f,0x15,0x00,0x0e,0x00,0xf9,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0d,0x0a,0x0d,0x0a,0x46,0x6f,0x6e,0x74,0x20,0x28,
0x63,0x29,0x20,0x4d,0x69,0x63,0x72,0x6f,0x50,0x72,
0x6f,0x66,0x20,0x32,0x37,0x20,0x53,0x65,0x70,0x74,
0x65,0x6d,0x62,0x2e,0x31,0x39,0x38,0x39,0x00,0x0d,
0x0a,0x0d,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x00,0x12,0x00,0x34,0x00,0x46,0x00,0x94,0x00,
0xd0,0x00,0x2e,0x01,0x3e,0x01,0x64,0x01,0x8a,0x01,
0x98,0x01,0xa2,0x01,0xb4,0x01,0xba,0x01,0xc6,0x01,
0xcc,0x01,0xf0,0x01,0xfa,0x01,0x18,0x02,0x38,0x02,
0x44,0x02,0x68,0x02,0x98,0x02,0xa2,0x02,0xde,0x02,
0x0e,0x03,0x24,0x03,0x40,0x03,0x48,0x03,0x52,0x03,
0x5a,0x03,0x82,0x03,0xec,0x03,0xfa,0x03,0x26,0x04,
0x4c,0x04,0x6a,0x04,0x7c,0x04,0x8a,0x04,0xb6,0x04,
0xc4,0x04,0xca,0x04,0xe0,0x04,0xee,0x04,0xf8,0x04,
0x0a,0x05,0x18,0x05,0x44,0x05,0x5e,0x05,0x8e,0x05,
0xac,0x05,0xd6,0x05,0xe0,0x05,0xf6,0x05,0x00,0x06,
0x12,0x06,0x1c,0x06,0x28,0x06,0x36,0x06,0x48,0x06,
0x4e,0x06,0x60,0x06,0x6e,0x06,0x74,0x06,0x84,0x06,
0xa6,0x06,0xc8,0x06,0xe6,0x06,0x08,0x07,0x2c,0x07,
0x3c,0x07,0x68,0x07,0x7c,0x07,0x8c,0x07,0xa2,0x07,
0xb0,0x07,0xb6,0x07,0xd8,0x07,0xec,0x07,0x10,0x08,
0x32,0x08,0x54,0x08,0x64,0x08,0x88,0x08,0x98,0x08,
0xac,0x08,0xb6,0x08,0xc8,0x08,0xd2,0x08,0xe4,0x08,
0xf2,0x08,0x3e,0x09,0x48,0x09,0x94,0x09,0xc2,0x09,
0xc4,0x09,0xd0,0x09,0xe2,0x09,0x04,0x0a,0x0e,0x0a,
0x26,0x0a,0x34,0x0a,0x4a,0x0a,0x66,0x0a,0x70,0x0a,
0x7e,0x0a,0x8e,0x0a,0x9a,0x0a,0xa6,0x0a,0xb4,0x0a,
0xd8,0x0a,0xe2,0x0a,0xf6,0x0a,0x18,0x0b,0x22,0x0b,
0x32,0x0b,0x56,0x0b,0x60,0x0b,0x6e,0x0b,0x7c,0x0b,
0x8a,0x0b,0x9c,0x0b,0x9e,0x0b,0xb2,0x0b,0xc2,0x0b,
0xd8,0x0b,0xf4,0x0b,0x08,0x0c,0x30,0x0c,0x56,0x0c,
0x72,0x0c,0x90,0x0c,0xb2,0x0c,0xce,0x0c,0xe2,0x0c,
0xfe,0x0c,0x10,0x0d,0x26,0x0d,0x36,0x0d,0x42,0x0d,
0x4e,0x0d,0x5c,0x0d,0x78,0x0d,0x8c,0x0d,0x8e,0x0d,
0x90,0x0d,0x92,0x0d,0x94,0x0d,0x96,0x0d,0x98,0x0d,
0x9a,0x0d,0x9c,0x0d,0x9e,0x0d,0xa0,0x0d,0xa2,0x0d,
0xa4,0x0d,0xa6,0x0d,0xa8,0x0d,0xaa,0x0d,0xac,0x0d,
0xae,0x0d,0xb0,0x0d,0xb2,0x0d,0xb4,0x0d,0xb6,0x0d,
0xb8,0x0d,0xba,0x0d,0xbc,0x0d,0xbe,0x0d,0xc0,0x0d,
0xc2,0x0d,0xc4,0x0d,0xc6,0x0d,0xc8,0x0d,0xca,0x0d,
0xcc,0x0d,0xce,0x0d,0xd0,0x0d,0xd2,0x0d,0xd4,0x0d,
0xd6,0x0d,0xd8,0x0d,0xda,0x0d,0xdc,0x0d,0xde,0x0d,
0xe0,0x0d,0xe2,0x0d,0xe4,0x0d,0xe6,0x0d,0xe8,0x0d,
0xea,0x0d,0xec,0x0d,0x0c,0x0e,0x26,0x0e,0x48,0x0e,
0x64,0x0e,0x88,0x0e,0x92,0x0e,0xa6,0x0e,0xb4,0x0e,
0xd0,0x0e,0xee,0x0e,0x02,0x0f,0x16,0x0f,0x26,0x0f,
0x3c,0x0f,0x58,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,
0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,
0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,
0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x10,0x80,
0x05,0x95,0x00,0x72,0x00,0xfb,0xff,0x7f,0x01,0x7f,
0x01,0x01,0xff,0x01,0x05,0xfe,0x05,0x95,0xff,0x7f,
0x00,0x7a,0x01,0x86,0xff,0x7a,0x01,0x87,0x01,0x7f,
0xfe,0x7a,0x0a,0x87,0xff,0x7f,0x00,0x7a,0x01,0x86,
0xff,0x7a,0x01,0x87,0x01,0x7f,0xfe,0x7a,0x05,0xf2,
0x0b,0x95,0xf9,0x64,0x0d,0x9c,0xf9,0x64,0xfa,0x91,
0x0e,0x00,0xf1,0xfa,0x0e,0x00,0x04,0xfc,0x08,0x99,
0x00,0x63,0x04,0x9d,0x00,0x63,0x04,0x96,0xff,0x7f,
0x01,0x7f,0x01,0x01,0x00,0x01,0xfe,0x02,0xfd,0x01,
0xfc,0x00,0xfd,0x7f,0xfe,0x7e,0x00,0x7e,0x01,0x7e,
0x01,0x7f,0x02,0x7f,0x06,0x7e,0x02,0x7f,0x02,0x7e,
0xf2,0x89,0x02,0x7e,0x02,0x7f,0x06,0x7e,0x02,0x7f,
0x01,0x7f,0x01,0x7e,0x00,0x7c,0xfe,0x7e,0xfd,0x7f,
0xfc,0x00,0xfd,0x01,0xfe,0x02,0x00,0x01,0x01,0x01,
0x01,0x7f,0xff,0x7f,0x10,0xfd,0x15,0x95,0xee,0x6b,
0x05,0x95,0x02,0x7e,0x00,0x7e,0xff,0x7e,0xfe,0x7f,
0xfe,0x00,0xfe,0x02,0x00,0x02,0x01,0x02,0x02,0x01,
0x02,0x00,0x02,0x7f,0x03,0x7f,0x03,0x00,0x03,0x01,
0x02,0x01,0xfc,0xf2,0xfe,0x7f,0xff,0x7e,0x00,0x7e,
0x02,0x7e,0x02,0x00,0x02,0x01,0x01,0x02,0x00,0x02,
0xfe,0x02,0xfe,0x00,0x07,0xf9,0x15,0x8d,0xff,0x7f,
0x01,0x7f,0x01,0x01,0x00,0x01,0xff,0x01,0xff,0x00,
0xff,0x7f,0xff,0x7e,0xfe,0x7b,0xfe,0x7d,0xfe,0x7e,
0xfe,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x02,0x00,0x03,
0x01,0x02,0x06,0x04,0x02,0x02,0x01,0x02,0x00,0x02,
0xff,0x02,0xfe,0x01,0xfe,0x7f,0xff,0x7e,0x00,0x7e,
0x01,0x7d,0x02,0x7d,0x05,0x79,0x02,0x7e,0x03,0x7f,
0x01,0x00,0x01,0x01,0x00,0x01,0xf1,0xfe,0xfe,0x01,
0xff,0x02,0x00,0x03,0x01,0x02,0x02,0x02,0x00,0x86,
0x01,0x7e,0x08,0x75,0x02,0x7e,0x02,0x7f,0x05,0x80,
0x05,0x93,0xff,0x01,0x01,0x01,0x01,0x7f,0x00,0x7e,
0xff,0x7e,0xff,0x7f,0x06,0xf1,0x0b,0x99,0xfe,0x7e,
0xfe,0x7d,0xfe,0x7c,0xff,0x7b,0x00,0x7c,0x01,0x7b,
0x02,0x7c,0x02,0x7d,0x02,0x7e,0xfe,0x9e,0xfe,0x7c,
0xff,0x7d,0xff,0x7b,0x00,0x7c,0x01,0x7b,0x01,0x7d,
0x02,0x7c,0x05,0x85,0x03,0x99,0x02,0x7e,0x02,0x7d,
0x02,0x7c,0x01,0x7b,0x00,0x7c,0xff,0x7b,0xfe,0x7c,
0xfe,0x7d,0xfe,0x7e,0x02,0x9e,0x02,0x7c,0x01,0x7d,
0x01,0x7b,0x00,0x7c,0xff,0x7b,0xff,0x7d,0xfe,0x7c,
0x09,0x85,0x08,0x95,0x00,0x74,0xfb,0x89,0x0a,0x7a,
0x00,0x86,0xf6,0x7a,0x0d,0xf4,0x0d,0x92,0x00,0x6e,
0xf7,0x89,0x12,0x00,0x04,0xf7,0x06,0x81,0xff,0x7f,
0xff,0x01,0x01,0x01,0x01,0x7f,0x00,0x7e,0xff,0x7e,
0xff,0x7f,0x06,0x84,0x04,0x89,0x12,0x00,0x04,0xf7,
0x05,0x82,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01,
0x05,0xfe,0x00,0xfd,0x0e,0x18,0x00,0xeb,0x09,0x95,
0xfd,0x7f,0xfe,0x7d,0xff,0x7b,0x00,0x7d,0x01,0x7b,
0x02,0x7d,0x03,0x7f,0x02,0x00,0x03,0x01,0x02,0x03,
0x01,0x05,0x00,0x03,0xff,0x05,0xfe,0x03,0xfd,0x01,
0xfe,0x00,0x0b,0xeb,0x06,0x91,0x02,0x01,0x03,0x03,
0x00,0x6b,0x09,0x80,0x04,0x90,0x00,0x01,0x01,0x02,
0x01,0x01,0x02,0x01,0x04,0x00,0x02,0x7f,0x01,0x7f,
0x01,0x7e,0x00,0x7e,0xff,0x7e,0xfe,0x7d,0xf6,0x76,
0x0e,0x00,0x03,0x80,0x05,0x95,0x0b,0x00,0xfa,0x78,
0x03,0x00,0x02,0x7f,0x01,0x7f,0x01,0x7d,0x00,0x7e,
0xff,0x7d,0xfe,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,
0xff,0x01,0xff,0x02,0x11,0xfc,0x0d,0x95,0xf6,0x72,
0x0f,0x00,0xfb,0x8e,0x00,0x6b,0x07,0x80,0x0f,0x95,
0xf6,0x00,0xff,0x77,0x01,0x01,0x03,0x01,0x03,0x00,
0x03,0x7f,0x02,0x7e,0x01,0x7d,0x00,0x7e,0xff,0x7d,
0xfe,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x01,
0xff,0x02,0x11,0xfc,0x10,0x92,0xff,0x02,0xfd,0x01,
0xfe,0x00,0xfd,0x7f,0xfe,0x7d,0xff,0x7b,0x00,0x7b,
0x01,0x7c,0x02,0x7e,0x03,0x7f,0x01,0x00,0x03,0x01,
0x02,0x02,0x01,0x03,0x00,0x01,0xff,0x03,0xfe,0x02,
0xfd,0x01,0xff,0x00,0xfd,0x7f,0xfe,0x7e,0xff,0x7d,
0x10,0xf9,0x11,0x95,0xf6,0x6b,0xfc,0x95,0x0e,0x00,
0x03,0xeb,0x08,0x95,0xfd,0x7f,0xff,0x7e,0x00,0x7e,
0x01,0x7e,0x02,0x7f,0x04,0x7f,0x03,0x7f,0x02,0x7e,
0x01,0x7e,0x00,0x7d,0xff,0x7e,0xff,0x7f,0xfd,0x7f,
0xfc,0x00,0xfd,0x01,0xff,0x01,0xff,0x02,0x00,0x03,
0x01,0x02,0x02,0x02,0x03,0x01,0x04,0x01,0x02,0x01,
0x01,0x02,0x00,0x02,0xff,0x02,0xfd,0x01,0xfc,0x00,
0x0c,0xeb,0x10,0x8e,0xff,0x7d,0xfe,0x7e,0xfd,0x7f,
0xff,0x00,0xfd,0x01,0xfe,0x02,0xff,0x03,0x00,0x01,
0x01,0x03,0x02,0x02,0x03,0x01,0x01,0x00,0x03,0x7f,
0x02,0x7e,0x01,0x7c,0x00,0x7b,0xff,0x7b,0xfe,0x7d,
0xfd,0x7f,0xfe,0x00,0xfd,0x01,0xff,0x02,0x10,0xfd,
0x05,0x8e,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01,
0x00,0xf4,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01,
0x05,0xfe,0x05,0x8e,0xff,0x7f,0x01,0x7f,0x01,0x01,
0xff,0x01,0x01,0xf3,0xff,0x7f,0xff,0x01,0x01,0x01,
0x01,0x7f,0x00,0x7e,0xff,0x7e,0xff,0x7f,0x06,0x84,
0x14,0x92,0xf0,0x77,0x10,0x77,0x04,0x80,0x04,0x8c,
0x12,0x00,0xee,0xfa,0x12,0x00,0x04,0xfa,0x04,0x92,
0x10,0x77,0xf0,0x77,0x14,0x80,0x03,0x90,0x00,0x01,
0x01,0x02,0x01,0x01,0x02,0x01,0x04,0x00,0x02,0x7f,
0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,
0xfc,0x7e,0x00,0x7d,0x00,0xfb,0xff,0x7f,0x01,0x7f,
0x01,0x01,0xff,0x01,0x09,0xfe,0x12,0x8d,0xff,0x02,
0xfe,0x01,0xfd,0x00,0xfe,0x7f,0xff,0x7f,0xff,0x7d,
0x00,0x7d,0x01,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
0x01,0x02,0xfb,0x88,0xfe,0x7e,0xff,0x7d,0x00,0x7d,
0x01,0x7e,0x01,0x7f,0x07,0x8b,0xff,0x78,0x00,0x7e,
0x02,0x7f,0x02,0x00,0x02,0x02,0x01,0x03,0x00,0x02,
0xff,0x03,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfd,0x01,
0xfd,0x00,0xfd,0x7f,0xfe,0x7f,0xfe,0x7e,0xff,0x7e,
0xff,0x7d,0x00,0x7d,0x01,0x7d,0x01,0x7e,0x02,0x7e,
0x02,0x7f,0x03,0x7f,0x03,0x00,0x03,0x01,0x02,0x01,
0x01,0x01,0xfe,0x8d,0xff,0x78,0x00,0x7e,0x01,0x7f,
0x08,0xfb,0x09,0x95,0xf8,0x6b,0x08,0x95,0x08,0x6b,
0xf3,0x87,0x0a,0x00,0x04,0xf9,0x04,0x95,0x00,0x6b,
0x00,0x95,0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,
0x00,0x7e,0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x80,
0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,0x00,0x7d,
0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x00,0x11,0x80,
0x12,0x90,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfc,0x00,
0xfe,0x7f,0xfe,0x7e,0xff,0x7e,0xff,0x7d,0x00,0x7b,
0x01,0x7d,0x01,0x7e,0x02,0x7e,0x02,0x7f,0x04,0x00,
0x02,0x01,0x02,0x02,0x01,0x02,0x03,0xfb,0x04,0x95,
0x00,0x6b,0x00,0x95,0x07,0x00,0x03,0x7f,0x02,0x7e,
0x01,0x7e,0x01,0x7d,0x00,0x7b,0xff,0x7d,0xff,0x7e,
0xfe,0x7e,0xfd,0x7f,0xf9,0x00,0x11,0x80,0x04,0x95,
0x00,0x6b,0x00,0x95,0x0d,0x00,0xf3,0xf6,0x08,0x00,
0xf8,0xf5,0x0d,0x00,0x02,0x80,0x04,0x95,0x00,0x6b,
0x00,0x95,0x0d,0x00,0xf3,0xf6,0x08,0x00,0x06,0xf5,
0x12,0x90,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfc,0x00,
0xfe,0x7f,0xfe,0x7e,0xff,0x7e,0xff,0x7d,0x00,0x7b,
0x01,0x7d,0x01,0x7e,0x02,0x7e,0x02,0x7f,0x04,0x00,
0x02,0x01,0x02,0x02,0x01,0x02,0x00,0x03,0xfb,0x80,
0x05,0x00,0x03,0xf8,0x04,0x95,0x00,0x6b,0x0e,0x95,
0x00,0x6b,0xf2,0x8b,0x0e,0x00,0x04,0xf5,0x04,0x95,
0x00,0x6b,0x04,0x80,0x0c,0x95,0x00,0x70,0xff,0x7d,
0xff,0x7f,0xfe,0x7f,0xfe,0x00,0xfe,0x01,0xff,0x01,
0xff,0x03,0x00,0x02,0x0e,0xf9,0x04,0x95,0x00,0x6b,
0x0e,0x95,0xf2,0x72,0x05,0x85,0x09,0x74,0x03,0x80,
0x04,0x95,0x00,0x6b,0x00,0x80,0x0c,0x00,0x01,0x80,
0x04,0x95,0x00,0x6b,0x00,0x95,0x08,0x6b,0x08,0x95,
0xf8,0x6b,0x08,0x95,0x00,0x6b,0x04,0x80,0x04,0x95,
0x00,0x6b,0x00,0x95,0x0e,0x6b,0x00,0x95,0x00,0x6b,
0x04,0x80,0x09,0x95,0xfe,0x7f,0xfe,0x7e,0xff,0x7e,
0xff,0x7d,0x00,0x7b,0x01,0x7d,0x01,0x7e,0x02,0x7e,
0x02,0x7f,0x04,0x00,0x02,0x01,0x02,0x02,0x01,0x02,
0x01,0x03,0x00,0x05,0xff,0x03,0xff,0x02,0xfe,0x02,
0xfe,0x01,0xfc,0x00,0x0d,0xeb,0x04,0x95,0x00,0x6b,
0x00,0x95,0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,
0x00,0x7d,0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x00,
0x11,0xf6,0x09,0x95,0xfe,0x7f,0xfe,0x7e,0xff,0x7e,
0xff,0x7d,0x00,0x7b,0x01,0x7d,0x01,0x7e,0x02,0x7e,
0x02,0x7f,0x04,0x00,0x02,0x01,0x02,0x02,0x01,0x02,
0x01,0x03,0x00,0x05,0xff,0x03,0xff,0x02,0xfe,0x02,
0xfe,0x01,0xfc,0x00,0x03,0xef,0x06,0x7a,0x04,0x82,
0x04,0x95,0x00,0x6b,0x00,0x95,0x09,0x00,0x03,0x7f,
0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,
0xfd,0x7f,0xf7,0x00,0x07,0x80,0x07,0x75,0x03,0x80,
0x11,0x92,0xfe,0x02,0xfd,0x01,0xfc,0x00,0xfd,0x7f,
0xfe,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x02,0x7f,
0x06,0x7e,0x02,0x7f,0x01,0x7f,0x01,0x7e,0x00,0x7d,
0xfe,0x7e,0xfd,0x7f,0xfc,0x00,0xfd,0x01,0xfe,0x02,
0x11,0xfd,0x08,0x95,0x00,0x6b,0xf9,0x95,0x0e,0x00,
0x01,0xeb,0x04,0x95,0x00,0x71,0x01,0x7d,0x02,0x7e,
0x03,0x7f,0x02,0x00,0x03,0x01,0x02,0x02,0x01,0x03,
0x00,0x0f,0x04,0xeb,0x01,0x95,0x08,0x6b,0x08,0x95,
0xf8,0x6b,0x09,0x80,0x02,0x95,0x05,0x6b,0x05,0x95,
0xfb,0x6b,0x05,0x95,0x05,0x6b,0x05,0x95,0xfb,0x6b,
0x07,0x80,0x03,0x95,0x0e,0x6b,0x00,0x95,0xf2,0x6b,
0x11,0x80,0x01,0x95,0x08,0x76,0x00,0x75,0x08,0x95,
0xf8,0x76,0x09,0xf5,0x11,0x95,0xf2,0x6b,0x00,0x95,
0x0e,0x00,0xf2,0xeb,0x0e,0x00,0x03,0x80,0x03,0x93,
0x00,0x6c,0x01,0x94,0x00,0x6c,0xff,0x94,0x05,0x00,
0xfb,0xec,0x05,0x00,0x02,0x81,0x00,0x95,0x0e,0x68,
0x00,0x83,0x06,0x93,0x00,0x6c,0x01,0x94,0x00,0x6c,
0xfb,0x94,0x05,0x00,0xfb,0xec,0x05,0x00,0x03,0x81,
0x03,0x87,0x08,0x05,0x08,0x7b,0xf0,0x80,0x08,0x04,
0x08,0x7c,0x03,0xf9,0x01,0x80,0x10,0x00,0x01,0x80,
0x06,0x95,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7f,
0x01,0x01,0xff,0x01,0x05,0xef,0x0f,0x8e,0x00,0x72,
0x00,0x8b,0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,
0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,
0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,
0x04,0x95,0x00,0x6b,0x00,0x8b,0x02,0x02,0x02,0x01,
0x03,0x00,0x02,0x7f,0x02,0x7e,0x01,0x7d,0x00,0x7e,
0xff,0x7d,0xfe,0x7e,0xfe,0x7f,0xfd,0x00,0xfe,0x01,
0xfe,0x02,0x0f,0xfd,0x0f,0x8b,0xfe,0x02,0xfe,0x01,
0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e,
0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
0x02,0x02,0x03,0xfd,0x0f,0x95,0x00,0x6b,0x00,0x8b,
0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,0xfe,0x7e,
0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,0x02,0x7f,
0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,0x03,0x88,
0x0c,0x00,0x00,0x02,0xff,0x02,0xff,0x01,0xfe,0x01,
0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e,
0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
0x02,0x02,0x03,0xfd,0x0a,0x95,0xfe,0x00,0xfe,0x7f,
0xff,0x7d,0x00,0x6f,0xfd,0x8e,0x07,0x00,0x03,0xf2,
0x0f,0x8e,0x00,0x70,0xff,0x7d,0xff,0x7f,0xfe,0x7f,
0xfd,0x00,0xfe,0x01,0x09,0x91,0xfe,0x02,0xfe,0x01,
0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e,
0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01,
0x02,0x02,0x04,0xfd,0x04,0x95,0x00,0x6b,0x00,0x8a,
0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,0x01,0x7d,
0x00,0x76,0x04,0x80,0x03,0x95,0x01,0x7f,0x01,0x01,
0xff,0x01,0xff,0x7f,0x01,0xf9,0x00,0x72,0x04,0x80,
0x05,0x95,0x01,0x7f,0x01,0x01,0xff,0x01,0xff,0x7f,
0x01,0xf9,0x00,0x6f,0xff,0x7d,0xfe,0x7f,0xfe,0x00,
0x09,0x87,0x04,0x95,0x00,0x6b,0x0a,0x8e,0xf6,0x76,
0x04,0x84,0x07,0x78,0x02,0x80,0x04,0x95,0x00,0x6b,
0x04,0x80,0x04,0x8e,0x00,0x72,0x00,0x8a,0x03,0x03,
0x02,0x01,0x03,0x00,0x02,0x7f,0x01,0x7d,0x00,0x76,
0x00,0x8a,0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,
0x01,0x7d,0x00,0x76,0x04,0x80,0x04,0x8e,0x00,0x72,
0x00,0x8a,0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,
0x01,0x7d,0x00,0x76,0x04,0x80,0x08,0x8e,0xfe,0x7f,
0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,
0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x01,0x03,
0x00,0x02,0xff,0x03,0xfe,0x02,0xfe,0x01,0xfd,0x00,
0x0b,0xf2,0x04,0x8e,0x00,0x6b,0x00,0x92,0x02,0x02,
0x02,0x01,0x03,0x00,0x02,0x7f,0x02,0x7e,0x01,0x7d,
0x00,0x7e,0xff,0x7d,0xfe,0x7e,0xfe,0x7f,0xfd,0x00,
0xfe,0x01,0xfe,0x02,0x0f,0xfd,0x0f,0x8e,0x00,0x6b,
0x00,0x92,0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,
0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,
0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,
0x04,0x8e,0x00,0x72,0x00,0x88,0x01,0x03,0x02,0x02,
0x02,0x01,0x03,0x00,0x01,0xf2,0x0e,0x8b,0xff,0x02,
0xfd,0x01,0xfd,0x00,0xfd,0x7f,0xff,0x7e,0x01,0x7e,
0x02,0x7f,0x05,0x7f,0x02,0x7f,0x01,0x7e,0x00,0x7f,
0xff,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x02,
0x0e,0xfd,0x05,0x95,0x00,0x6f,0x01,0x7d,0x02,0x7f,
0x02,0x00,0xf8,0x8e,0x07,0x00,0x03,0xf2,0x04,0x8e,
0x00,0x76,0x01,0x7d,0x02,0x7f,0x03,0x00,0x02,0x01,
0x03,0x03,0x00,0x8a,0x00,0x72,0x04,0x80,0x02,0x8e,
0x06,0x72,0x06,0x8e,0xfa,0x72,0x08,0x80,0x03,0x8e,
0x04,0x72,0x04,0x8e,0xfc,0x72,0x04,0x8e,0x04,0x72,
0x04,0x8e,0xfc,0x72,0x07,0x80,0x03,0x8e,0x0b,0x72,
0x00,0x8e,0xf5,0x72,0x0e,0x80,0x02,0x8e,0x06,0x72,
0x06,0x8e,0xfa,0x72,0xfe,0x7c,0xfe,0x7e,0xfe,0x7f,
0xff,0x00,0x0f,0x87,0x0e,0x8e,0xf5,0x72,0x00,0x8e,
0x0b,0x00,0xf5,0xf2,0x0b,0x00,0x03,0x80,0x09,0x99,
0xfe,0x7f,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,
0x01,0x7f,0x01,0x7e,0x00,0x7e,0xfe,0x7e,0x01,0x8e,
0xff,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x01,0x7e,
0x00,0x7e,0xff,0x7e,0xfc,0x7e,0x04,0x7e,0x01,0x7e,
0x00,0x7e,0xff,0x7e,0xff,0x7f,0xff,0x7e,0x00,0x7e,
0x01,0x7e,0xff,0x8e,0x02,0x7e,0x00,0x7e,0xff,0x7e,
0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,
0x02,0x7f,0x05,0x87,0x04,0x95,0x00,0x77,0x00,0xfd,
0x00,0x77,0x04,0x80,0x05,0x99,0x02,0x7f,0x01,0x7f,
0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,0xff,0x7e,
0x00,0x7e,0x02,0x7e,0xff,0x8e,0x01,0x7e,0x00,0x7e,
0xff,0x7e,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,
0x04,0x7e,0xfc,0x7e,0xff,0x7e,0x00,0x7e,0x01,0x7e,
0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0x01,0x8e,
0xfe,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x01,0x7e,
0x00,0x7e,0xff,0x7e,0xff,0x7f,0xfe,0x7f,0x09,0x87,
0x03,0x86,0x00,0x02,0x01,0x03,0x02,0x01,0x02,0x00,
0x02,0x7f,0x04,0x7d,0x02,0x7f,0x02,0x00,0x02,0x01,
0x01,0x02,0xee,0xfe,0x01,0x02,0x02,0x01,0x02,0x00,
0x02,0x7f,0x04,0x7d,0x02,0x7f,0x02,0x00,0x02,0x01,
0x01,0x03,0x00,0x02,0x03,0xf4,0x10,0x80,0x03,0x80,
0x07,0x15,0x08,0x6b,0xfe,0x85,0xf5,0x00,0x10,0xfb,
0x0d,0x95,0xf6,0x00,0x00,0x6b,0x0a,0x00,0x02,0x02,
0x00,0x08,0xfe,0x02,0xf6,0x00,0x0e,0xf4,0x03,0x80,
0x00,0x15,0x0a,0x00,0x02,0x7e,0x00,0x7e,0x00,0x7d,
0x00,0x7e,0xfe,0x7f,0xf6,0x00,0x0a,0x80,0x02,0x7e,
0x01,0x7e,0x00,0x7d,0xff,0x7d,0xfe,0x7f,0xf6,0x00,
0x10,0x80,0x03,0x80,0x00,0x15,0x0c,0x00,0xff,0x7e,
0x03,0xed,0x03,0xfd,0x00,0x03,0x02,0x00,0x00,0x12,
0x02,0x03,0x0a,0x00,0x00,0x6b,0x02,0x00,0x00,0x7d,
0xfe,0x83,0xf4,0x00,0x11,0x80,0x0f,0x80,0xf4,0x00,
0x00,0x15,0x0c,0x00,0xff,0xf6,0xf5,0x00,0x0f,0xf5,
0x04,0x95,0x07,0x76,0x00,0x0a,0x07,0x80,0xf9,0x76,
0x00,0x75,0xf8,0x80,0x07,0x0c,0x09,0xf4,0xf9,0x0c,
0x09,0xf4,0x03,0x92,0x02,0x03,0x07,0x00,0x03,0x7d,
0x00,0x7b,0xfc,0x7e,0x04,0x7d,0x00,0x7a,0xfd,0x7e,
0xf9,0x00,0xfe,0x02,0x06,0x89,0x02,0x00,0x06,0xf5,
0x03,0x95,0x00,0x6b,0x0c,0x15,0x00,0x6b,0x02,0x80,
0x03,0x95,0x00,0x6b,0x0c,0x15,0x00,0x6b,0xf8,0x96,
0x03,0x00,0x07,0xea,0x03,0x80,0x00,0x15,0x0c,0x80,
0xf7,0x76,0xfd,0x00,0x03,0x80,0x0a,0x75,0x03,0x80,
0x03,0x80,0x07,0x13,0x02,0x02,0x03,0x00,0x00,0x6b,
0x02,0x80,0x03,0x80,0x00,0x15,0x09,0x6b,0x09,0x15,
0x00,0x6b,0x03,0x80,0x03,0x80,0x00,0x15,0x00,0xf6,
0x0d,0x00,0x00,0x8a,0x00,0x6b,0x03,0x80,0x07,0x80,
0xfd,0x00,0xff,0x03,0x00,0x04,0x00,0x07,0x00,0x04,
0x01,0x02,0x03,0x01,0x06,0x00,0x03,0x7f,0x01,0x7e,
0x01,0x7c,0x00,0x79,0xff,0x7c,0xff,0x7d,0xfd,0x00,
0xfa,0x00,0x0e,0x80,0x03,0x80,0x00,0x15,0x0c,0x00,
0x00,0x6b,0x02,0x80,0x03,0x80,0x00,0x15,0x0a,0x00,
0x02,0x7f,0x01,0x7d,0x00,0x7b,0xff,0x7e,0xfe,0x7f,
0xf6,0x00,0x10,0xf7,0x11,0x8f,0xff,0x03,0xff,0x02,
0xfe,0x01,0xfa,0x00,0xfd,0x7f,0xff,0x7e,0x00,0x7c,
0x00,0x79,0x00,0x7b,0x01,0x7e,0x03,0x00,0x06,0x00,
0x02,0x00,0x01,0x03,0x01,0x02,0x03,0xfb,0x03,0x95,
0x0c,0x00,0xfa,0x80,0x00,0x6b,0x09,0x80,0x03,0x95,
0x00,0x77,0x06,0x7a,0x06,0x06,0x00,0x09,0xfa,0xf1,
0xfa,0x7a,0x0e,0x80,0x03,0x87,0x00,0x0b,0x02,0x02,
0x03,0x00,0x02,0x7e,0x01,0x02,0x04,0x00,0x02,0x7e,
0x00,0x75,0xfe,0x7e,0xfc,0x00,0xff,0x01,0xfe,0x7f,
0xfd,0x00,0xfe,0x02,0x07,0x8e,0x00,0x6b,0x09,0x80,
0x03,0x80,0x0e,0x15,0xf2,0x80,0x0e,0x6b,0x03,0x80,
0x03,0x95,0x00,0x6b,0x0e,0x00,0x00,0x7d,0xfe,0x98,
0x00,0x6b,0x05,0x80,0x03,0x95,0x00,0x75,0x02,0x7d,
0x0a,0x00,0x00,0x8e,0x00,0x6b,0x02,0x80,0x03,0x95,
0x00,0x6b,0x10,0x00,0x00,0x15,0xf8,0x80,0x00,0x6b,
0x0a,0x80,0x03,0x95,0x00,0x6b,0x10,0x00,0x00,0x15,
0xf8,0x80,0x00,0x6b,0x0a,0x00,0x00,0x7d,0x02,0x83,
0x10,0x80,0x03,0x95,0x00,0x6b,0x09,0x00,0x03,0x02,
0x00,0x08,0xfd,0x02,0xf7,0x00,0x0e,0x89,0x00,0x6b,
0x03,0x80,0x03,0x95,0x00,0x6b,0x09,0x00,0x03,0x02,
0x00,0x08,0xfd,0x02,0xf7,0x00,0x0e,0xf4,0x03,0x92,
0x02,0x03,0x07,0x00,0x03,0x7d,0x00,0x70,0xfd,0x7e,
0xf9,0x00,0xfe,0x02,0x03,0x89,0x09,0x00,0x02,0xf5,
0x03,0x80,0x00,0x15,0x00,0xf5,0x07,0x00,0x00,0x08,
0x02,0x03,0x06,0x00,0x02,0x7d,0x00,0x70,0xfe,0x7e,
0xfa,0x00,0xfe,0x02,0x00,0x08,0x0c,0xf6,0x0f,0x80,
0x00,0x15,0xf6,0x00,0xfe,0x7d,0x00,0x79,0x02,0x7e,
0x0a,0x00,0xf4,0xf7,0x07,0x09,0x07,0xf7,0x03,0x8c,
0x01,0x02,0x01,0x01,0x05,0x00,0x02,0x7f,0x01,0x7e,
0x00,0x74,0x00,0x86,0xff,0x01,0xfe,0x01,0xfb,0x00,
0xff,0x7f,0xff,0x7f,0x00,0x7c,0x01,0x7e,0x01,0x00,
0x05,0x00,0x02,0x00,0x01,0x02,0x03,0xfe,0x04,0x8e,
0x02,0x01,0x04,0x00,0x02,0x7f,0x01,0x7e,0x00,0x77,
0xff,0x7e,0xfe,0x7f,0xfc,0x00,0xfe,0x01,0xff,0x02,
0x00,0x09,0x01,0x02,0x02,0x02,0x03,0x01,0x02,0x01,
0x01,0x01,0x01,0x02,0x02,0xeb,0x03,0x80,0x00,0x15,
0x03,0x00,0x02,0x7e,0x00,0x7b,0xfe,0x7e,0xfd,0x00,
0x03,0x80,0x04,0x00,0x03,0x7e,0x00,0x78,0xfd,0x7e,
0xf9,0x00,0x0c,0x80,0x03,0x8c,0x02,0x02,0x02,0x01,
0x03,0x00,0x02,0x7f,0x01,0x7d,0xfe,0x7e,0xf9,0x7d,
0xff,0x7e,0x00,0x7d,0x03,0x7f,0x02,0x00,0x03,0x01,
0x02,0x01,0x02,0xfe,0x0d,0x8c,0xff,0x02,0xfe,0x01,
0xfc,0x00,0xfe,0x7f,0xff,0x7e,0x00,0x77,0x01,0x7e,
0x02,0x7f,0x04,0x00,0x02,0x01,0x01,0x02,0x00,0x0f,
0xff,0x02,0xfe,0x01,0xf9,0x00,0x0c,0xeb,0x03,0x88,
0x0a,0x00,0x00,0x02,0x00,0x03,0xfe,0x02,0xfa,0x00,
0xff,0x7e,0xff,0x7d,0x00,0x7b,0x01,0x7c,0x01,0x7f,
0x06,0x00,0x02,0x02,0x03,0xfe,0x03,0x8f,0x06,0x77,
0x06,0x09,0xfa,0x80,0x00,0x71,0xff,0x87,0xfb,0x79,
0x07,0x87,0x05,0x79,0x02,0x80,0x03,0x8d,0x02,0x02,
0x06,0x00,0x02,0x7e,0x00,0x7d,0xfc,0x7d,0x04,0x7e,
0x00,0x7d,0xfe,0x7e,0xfa,0x00,0xfe,0x02,0x04,0x85,
0x02,0x00,0x06,0xf9,0x03,0x8f,0x00,0x73,0x01,0x7e,
0x07,0x00,0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,
0x03,0x80,0x03,0x8f,0x00,0x73,0x01,0x7e,0x07,0x00,
0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0xf8,0x90,
0x03,0x00,0x08,0xf0,0x03,0x80,0x00,0x15,0x00,0xf3,
0x02,0x00,0x06,0x07,0xfa,0xf9,0x07,0x78,0x03,0x80,
0x03,0x80,0x04,0x0c,0x02,0x03,0x04,0x00,0x00,0x71,
0x02,0x80,0x03,0x80,0x00,0x0f,0x06,0x77,0x06,0x09,
0x00,0x71,0x02,0x80,0x03,0x80,0x00,0x0f,0x0a,0xf1,
0x00,0x0f,0xf6,0xf8,0x0a,0x00,0x02,0xf9,0x05,0x80,
0xff,0x01,0xff,0x04,0x00,0x05,0x01,0x03,0x01,0x02,
0x06,0x00,0x02,0x7e,0x00,0x7d,0x00,0x7b,0x00,0x7c,
0xfe,0x7f,0xfa,0x00,0x0b,0x80,0x03,0x80,0x00,0x0f,
0x00,0xfb,0x01,0x03,0x01,0x02,0x05,0x00,0x02,0x7e,
0x01,0x7d,0x00,0x76,0x03,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x10,0x80,0x0a,0x8f,0x02,0x7f,0x01,0x7e,0x00,0x76,
0xff,0x7f,0xfe,0x7f,0xfb,0x00,0xff,0x01,0xff,0x01,
0x00,0x0a,0x01,0x02,0x01,0x01,0x05,0x00,0xf9,0x80,
0x00,0x6b,0x0c,0x86,0x0d,0x8a,0xff,0x03,0xfe,0x02,
0xfb,0x00,0xff,0x7e,0xff,0x7d,0x00,0x7b,0x01,0x7c,
0x01,0x7f,0x05,0x00,0x02,0x01,0x01,0x03,0x03,0xfc,
0x03,0x80,0x00,0x0f,0x00,0xfb,0x01,0x03,0x01,0x02,
0x04,0x00,0x01,0x7e,0x01,0x7d,0x00,0x76,0x00,0x8a,
0x01,0x03,0x02,0x02,0x03,0x00,0x02,0x7e,0x01,0x7d,
0x00,0x76,0x03,0x80,0x03,0x8f,0x00,0x74,0x01,0x7e,
0x02,0x7f,0x04,0x00,0x02,0x01,0x01,0x01,0x00,0x8d,
0x00,0x6e,0xff,0x7e,0xfe,0x7f,0xfb,0x00,0xfe,0x01,
0x0c,0x85,0x03,0x8d,0x01,0x02,0x03,0x00,0x02,0x7e,
0x01,0x02,0x03,0x00,0x02,0x7e,0x00,0x74,0xfe,0x7f,
0xfd,0x00,0xff,0x01,0xfe,0x7f,0xfd,0x00,0xff,0x01,
0x00,0x0c,0x06,0x82,0x00,0x6b,0x08,0x86,0x03,0x80,
0x0a,0x0f,0xf6,0x80,0x0a,0x71,0x03,0x80,0x03,0x8f,
0x00,0x73,0x01,0x7e,0x07,0x00,0x02,0x02,0x00,0x0d,
0x00,0xf3,0x01,0x7e,0x00,0x7e,0x03,0x82,0x03,0x8f,
0x00,0x79,0x02,0x7e,0x08,0x00,0x00,0x89,0x00,0x71,
0x02,0x80,0x03,0x8f,0x00,0x73,0x01,0x7e,0x03,0x00,
0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x00,
0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x80,
0x03,0x8f,0x00,0x73,0x01,0x7e,0x03,0x00,0x02,0x02,
0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x00,0x02,0x02,
0x00,0x0d,0x00,0xf3,0x01,0x7e,0x00,0x7e,0x03,0x82,
0x03,0x8d,0x00,0x02,0x02,0x00,0x00,0x71,0x08,0x00,
0x02,0x02,0x00,0x06,0xfe,0x02,0xf8,0x00,0x0c,0xf6,
0x03,0x8f,0x00,0x71,0x07,0x00,0x02,0x02,0x00,0x06,
0xfe,0x02,0xf9,0x00,0x0c,0x85,0x00,0x71,0x02,0x80,
0x03,0x8f,0x00,0x71,0x07,0x00,0x03,0x02,0x00,0x06,
0xfd,0x02,0xf9,0x00,0x0c,0xf6,0x03,0x8d,0x02,0x02,
0x06,0x00,0x02,0x7e,0x00,0x75,0xfe,0x7e,0xfa,0x00,
0xfe,0x02,0x04,0x85,0x06,0x00,0x02,0xf9,0x03,0x80,
0x00,0x0f,0x00,0xf8,0x04,0x00,0x00,0x06,0x02,0x02,
0x04,0x00,0x02,0x7e,0x00,0x75,0xfe,0x7e,0xfc,0x00,
0xfe,0x02,0x00,0x05,0x0a,0xf9,0x0d,0x80,0x00,0x0f,
0xf7,0x00,0xff,0x7e,0x00,0x7b,0x01,0x7e,0x09,0x00,
0xf6,0xfa,0x04,0x06,0x08,0xfa,
];
#[derive(Clone, Copy, PartialEq)]
enum Status {
Initial,
NextChar,
StartGlyph,
Glyph,
}
#[inline]
fn value_le(data: &[u8], offset: usize) -> u16 {
u16::from_le_bytes([data[offset], data[offset + 1]])
}
pub struct GsvText {
x: f64,
y: f64,
start_x: f64,
width: f64,
height: f64,
space: f64,
line_space: f64,
text: Vec<u8>,
cur_chr: usize,
font: &'static [u8],
loaded_font: Vec<u8>,
status: Status,
flip: bool,
indices: usize,
glyphs: usize,
bglyph: usize,
eglyph: usize,
w: f64,
h: f64,
}
impl GsvText {
pub fn new() -> Self {
Self {
x: 0.0,
y: 0.0,
start_x: 0.0,
width: 10.0,
height: 0.0,
space: 0.0,
line_space: 0.0,
text: Vec::new(),
cur_chr: 0,
font: GSV_DEFAULT_FONT,
loaded_font: Vec::new(),
status: Status::Initial,
flip: false,
indices: 0,
glyphs: 0,
bglyph: 0,
eglyph: 0,
w: 0.0,
h: 0.0,
}
}
pub fn set_font(&mut self, font: Option<&'static [u8]>) {
match font {
Some(f) => self.font = f,
None => {
if !self.loaded_font.is_empty() {
}
}
}
}
pub fn flip(&mut self, flip_y: bool) {
self.flip = flip_y;
}
pub fn size(&mut self, height: f64, width: f64) {
self.height = height;
self.width = width;
}
pub fn space(&mut self, space: f64) {
self.space = space;
}
pub fn line_space(&mut self, line_space: f64) {
self.line_space = line_space;
}
pub fn start_point(&mut self, x: f64, y: f64) {
self.x = x;
self.start_x = x;
self.y = y;
}
pub fn text(&mut self, text: &str) {
self.text = text.as_bytes().to_vec();
}
pub fn load_font_data(&mut self, data: &[u8]) {
self.loaded_font = data.to_vec();
}
fn active_font(&self) -> &[u8] {
if !self.loaded_font.is_empty() {
&self.loaded_font
} else {
self.font
}
}
pub fn text_width(&mut self) -> f64 {
match bounding_rect_single(self, 0) {
Some(r) => r.x2 - r.x1,
None => 0.0,
}
}
}
impl Default for GsvText {
fn default() -> Self {
Self::new()
}
}
impl VertexSource for GsvText {
fn rewind(&mut self, _path_id: u32) {
self.status = Status::Initial;
let font = self.active_font();
if font.is_empty() {
return;
}
let base_height = value_le(font, 4) as f64;
let idx_offset = value_le(font, 0) as usize;
self.indices = idx_offset;
self.glyphs = idx_offset + 257 * 2;
self.h = self.height / base_height;
self.w = if self.width == 0.0 {
self.h
} else {
self.width / base_height
};
if self.flip {
self.h = -self.h;
}
self.cur_chr = 0;
}
fn vertex(&mut self, x: &mut f64, y: &mut f64) -> u32 {
loop {
match self.status {
Status::Initial => {
if self.active_font().is_empty() {
return PATH_CMD_STOP;
}
self.status = Status::NextChar;
continue;
}
Status::NextChar => {
if self.cur_chr >= self.text.len() {
return PATH_CMD_STOP;
}
let idx = self.text[self.cur_chr] as usize;
self.cur_chr += 1;
if idx == b'\n' as usize {
self.x = self.start_x;
self.y -= if self.flip {
-self.height - self.line_space
} else {
self.height + self.line_space
};
continue;
}
let idx2 = idx << 1;
let bg = value_le(self.active_font(), self.indices + idx2) as usize;
let eg = value_le(self.active_font(), self.indices + idx2 + 2) as usize;
self.bglyph = self.glyphs + bg;
self.eglyph = self.glyphs + eg;
self.status = Status::StartGlyph;
continue;
}
Status::StartGlyph => {
*x = self.x;
*y = self.y;
self.status = Status::Glyph;
return PATH_CMD_MOVE_TO;
}
Status::Glyph => {
if self.bglyph >= self.eglyph {
self.status = Status::NextChar;
self.x += self.space;
continue;
}
let (dx_byte, yc_raw) = {
let f = self.active_font();
(f[self.bglyph], f[self.bglyph + 1])
};
self.bglyph += 2;
let dx = dx_byte as i8;
let yf = yc_raw & 0x80;
let yc = ((yc_raw as i8) << 1) >> 1;
let dy = yc as i32;
self.x += dx as f64 * self.w;
self.y += dy as f64 * self.h;
*x = self.x;
*y = self.y;
return if yf != 0 {
PATH_CMD_MOVE_TO
} else {
PATH_CMD_LINE_TO
};
}
}
}
}
}
pub struct GsvTextOutline {
polyline: ConvTransform<ConvStroke<GsvText>>,
}
impl GsvTextOutline {
pub fn new(text: GsvText, trans: TransAffine) -> Self {
let stroke = ConvStroke::new(text);
let ct = ConvTransform::new(stroke, trans);
Self { polyline: ct }
}
pub fn set_width(&mut self, w: f64) {
self.polyline.source_mut().set_width(w);
}
pub fn set_transform(&mut self, trans: TransAffine) {
self.polyline.set_transform(trans);
}
pub fn text_mut(&mut self) -> &mut GsvText {
self.polyline.source_mut().source_mut()
}
}
impl VertexSource for GsvTextOutline {
fn rewind(&mut self, path_id: u32) {
self.polyline.rewind(path_id);
self.polyline.source_mut().set_line_join(LineJoin::Round);
self.polyline.source_mut().set_line_cap(LineCap::Round);
}
fn vertex(&mut self, x: &mut f64, y: &mut f64) -> u32 {
self.polyline.vertex(x, y)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::basics::{is_move_to, is_stop, is_vertex};
#[test]
fn test_new_defaults() {
let t = GsvText::new();
assert_eq!(t.width, 10.0);
assert_eq!(t.height, 0.0);
assert_eq!(t.space, 0.0);
assert!(!t.flip);
}
#[test]
fn test_empty_text_produces_stop() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
let cmd = t.vertex(&mut x, &mut y);
assert!(is_stop(cmd));
}
#[test]
fn test_single_char_produces_vertices() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(0.0, 0.0);
t.text("A");
t.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
let cmd = t.vertex(&mut x, &mut y);
assert!(is_move_to(cmd));
let mut count = 1;
loop {
let cmd = t.vertex(&mut x, &mut y);
if is_stop(cmd) {
break;
}
assert!(is_vertex(cmd) || is_move_to(cmd));
count += 1;
}
assert!(count > 3, "Expected multiple vertices for 'A', got {count}");
}
#[test]
fn test_start_point() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(100.0, 200.0);
t.text("A");
t.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
let cmd = t.vertex(&mut x, &mut y);
assert!(is_move_to(cmd));
assert!(x > 50.0 && x < 200.0);
assert!(y > 100.0 && y < 300.0);
}
#[test]
fn test_multi_char_text() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(0.0, 0.0);
t.text("AB");
t.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
let mut count = 0;
loop {
let cmd = t.vertex(&mut x, &mut y);
if is_stop(cmd) {
break;
}
count += 1;
}
let mut t2 = GsvText::new();
t2.size(24.0, 0.0);
t2.start_point(0.0, 0.0);
t2.text("A");
t2.rewind(0);
let mut count_a = 0;
loop {
let cmd = t2.vertex(&mut x, &mut y);
if is_stop(cmd) {
break;
}
count_a += 1;
}
assert!(count > count_a, "AB should produce more vertices than A");
}
#[test]
fn test_text_width() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(0.0, 0.0);
t.text("Hello");
let w = t.text_width();
assert!(w > 0.0, "text_width should be positive for non-empty text");
}
#[test]
fn test_text_width_longer_is_wider() {
let mut t1 = GsvText::new();
t1.size(24.0, 0.0);
t1.start_point(0.0, 0.0);
t1.text("Hi");
let w1 = t1.text_width();
let mut t2 = GsvText::new();
t2.size(24.0, 0.0);
t2.start_point(0.0, 0.0);
t2.text("Hello World");
let w2 = t2.text_width();
assert!(w2 > w1, "Longer text should be wider: {w2} vs {w1}");
}
#[test]
fn test_size_affects_output() {
let mut t1 = GsvText::new();
t1.size(12.0, 0.0);
t1.start_point(0.0, 0.0);
t1.text("A");
let w1 = t1.text_width();
let mut t2 = GsvText::new();
t2.size(24.0, 0.0);
t2.start_point(0.0, 0.0);
t2.text("A");
let w2 = t2.text_width();
assert!(
(w2 / w1 - 2.0).abs() < 0.1,
"Double height should double width: w2/w1 = {}",
w2 / w1
);
}
#[test]
fn test_flip() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(0.0, 100.0);
t.flip(true);
t.text("A");
t.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
t.vertex(&mut x, &mut y);
let mut has_vertex = true;
let cmd = t.vertex(&mut x, &mut y);
if is_stop(cmd) {
has_vertex = false;
}
assert!(has_vertex);
}
#[test]
fn test_rewind_resets() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(0.0, 0.0);
t.text("A");
t.rewind(0);
let mut x1 = 0.0;
let mut y1 = 0.0;
t.vertex(&mut x1, &mut y1);
t.rewind(0);
let mut x2 = 0.0;
let mut y2 = 0.0;
t.vertex(&mut x2, &mut y2);
assert_eq!(x1, x2);
assert_eq!(y1, y2);
}
#[test]
fn test_newline_resets_x() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(100.0, 200.0);
t.text("A\nB");
t.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
loop {
let cmd = t.vertex(&mut x, &mut y);
if is_stop(cmd) {
break;
}
}
t.rewind(0);
let mut count = 0;
loop {
let cmd = t.vertex(&mut x, &mut y);
if is_stop(cmd) {
break;
}
count += 1;
}
assert!(count > 0);
}
#[test]
fn test_gsv_text_outline_basic() {
let mut text = GsvText::new();
text.size(24.0, 0.0);
text.start_point(0.0, 0.0);
text.text("Hi");
let mut outline = GsvTextOutline::new(text, TransAffine::new());
outline.set_width(1.0);
outline.rewind(0);
let mut x = 0.0;
let mut y = 0.0;
let mut count = 0;
loop {
let cmd = outline.vertex(&mut x, &mut y);
if is_stop(cmd) {
break;
}
count += 1;
}
assert!(
count > 10,
"Stroked text outline should produce many vertices, got {count}"
);
}
#[test]
fn test_font_data_valid() {
let font = GSV_DEFAULT_FONT;
assert!(
font.len() > 520,
"Font should have index table + glyph data"
);
let idx_offset = value_le(font, 0) as usize;
let base_height = value_le(font, 4);
assert!(idx_offset > 0 && idx_offset < font.len());
assert!(base_height > 0);
assert!(idx_offset + 257 * 2 <= font.len());
}
#[test]
fn test_space_character_advances() {
let mut t = GsvText::new();
t.size(24.0, 0.0);
t.start_point(0.0, 0.0);
t.text("A B");
let w_with_space = t.text_width();
let mut t2 = GsvText::new();
t2.size(24.0, 0.0);
t2.start_point(0.0, 0.0);
t2.text("AB");
let w_without_space = t2.text_width();
assert!(
w_with_space > w_without_space,
"Text with space should be wider"
);
}
}