Coverage Report

Created: 2026-08-31 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ttf-parser/src/tables/maxp.rs
Line
Count
Source
1
//! A [Maximum Profile Table](
2
//! https://docs.microsoft.com/en-us/typography/opentype/spec/maxp) implementation.
3
4
use core::num::NonZeroU16;
5
6
use crate::parser::Stream;
7
8
/// A [Maximum Profile Table](https://docs.microsoft.com/en-us/typography/opentype/spec/maxp).
9
#[derive(Clone, Copy, Debug)]
10
pub struct Table {
11
    /// The total number of glyphs in the face.
12
    pub number_of_glyphs: NonZeroU16,
13
}
14
15
impl Table {
16
    /// Parses a table from raw data.
17
42.0k
    pub fn parse(data: &[u8]) -> Option<Self> {
18
42.0k
        let mut s = Stream::new(data);
19
42.0k
        let version = s.read::<u32>()?;
20
41.9k
        if !(version == 0x00005000 || version == 0x00010000) {
21
359
            return None;
22
41.6k
        }
23
24
41.6k
        let n = s.read::<u16>()?;
25
41.6k
        let number_of_glyphs = NonZeroU16::new(n)?;
26
41.6k
        Some(Table { number_of_glyphs })
27
42.0k
    }
28
}