55 lines
1.3 KiB
Rust
55 lines
1.3 KiB
Rust
|
use std::{fs::File, io::{BufReader, Read, Seek, SeekFrom}};
|
||
|
|
||
|
use bincode::{de::read, Result};
|
||
|
use log::debug;
|
||
|
use serde::Deserialize;
|
||
|
|
||
|
use super::{deserialize, table_directory::{FontTable, TableDirectoryRecord}};
|
||
|
|
||
|
#[derive(Debug, Deserialize)]
|
||
|
pub struct MaximumProfileV05 {
|
||
|
num_glyphs: u16
|
||
|
}
|
||
|
|
||
|
#[derive(Debug, Deserialize)]
|
||
|
pub struct MaximumProfileV10 {
|
||
|
num_glyphs: u16,
|
||
|
max_points: u16,
|
||
|
max_countours: u16,
|
||
|
max_composite_points: u16,
|
||
|
max_composite_countours: u16,
|
||
|
max_zones: u16,
|
||
|
max_twilight_points: u16,
|
||
|
max_storage: u16,
|
||
|
max_function_defs: u16,
|
||
|
max_instruction_defs: u16,
|
||
|
max_stack_elements: u16,
|
||
|
max_size_of_instructions: u16,
|
||
|
max_component_elements: u16,
|
||
|
max_component_depth: u16
|
||
|
}
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
pub enum MaximumProfile {
|
||
|
V0_5(MaximumProfileV05),
|
||
|
V1_0(MaximumProfileV10)
|
||
|
}
|
||
|
|
||
|
impl FontTable for MaximumProfile {
|
||
|
const TAG: &'static str = "maxp";
|
||
|
|
||
|
fn decode(mut reader: BufReader<File>, _: &TableDirectoryRecord) -> Result<Self>
|
||
|
where Self: Sized
|
||
|
{
|
||
|
let version: u32 = deserialize(reader.by_ref())?;
|
||
|
debug!("maxp table version: {:#08x}", version);
|
||
|
|
||
|
match version {
|
||
|
0x00005000 => todo!(),
|
||
|
0x00010000 => Ok(MaximumProfile::V1_0(deserialize(reader.by_ref())?)),
|
||
|
_ => { return Err(bincode::ErrorKind::Custom("Invalid maxp table version".into()).into()); }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|