// THIS FILE IS AUTOGENERATED.
// Any changes to this file will be overwritten.
// Use ../../scripts/gen_tables.py to regenerate.

/// Holds some data for each possible table in a font.
#[derive(Clone, Default, Debug)]
struct PerTableData<T> {
    /// Anchor point table.
    ankr: T,
    /// Axis variation table.
    avar: T,
    /// Baseline table.
    base: T,
    /// Compact font format table.
    cff: T,
    /// Compact font format 2.0 table.
    cff2: T,
    /// Color bitmap data table.
    cbdt: T,
    /// Color bitmap location table.
    cblc: T,
    /// Color table.
    colr: T,
    /// Color palette table.
    cpal: T,
    /// Character to glyph mapping table.
    cmap: T,
    /// CVT variations table.
    cvar: T,
    /// Control value table.
    cvt: T,
    /// Digital signature table.
    dsig: T,
    /// Embedded bitmap data table.
    ebdt: T,
    /// Embedded bitmap location data table.
    eblc: T,
    /// Font feature table.
    feat: T,
    /// Font program table.
    fpgm: T,
    /// Font variations table.
    fvar: T,
    /// Grid-fitting and scan-conversion procedure table.
    gasp: T,
    /// Glyph definition table.
    gdef: T,
    /// TrueType glyph data table.
    glyf: T,
    /// Glyph positioning table.
    gpos: T,
    /// Glyph substitution table.
    gsub: T,
    /// Glyph variation table.
    gvar: T,
    /// Horizontal device metrics.
    hdmx: T,
    /// Font header table.
    head: T,
    /// Horizontal header table.
    hhea: T,
    /// Horizontal metrics table.
    hmtx: T,
    /// Horizontal metrics variation table.
    hvar: T,
    /// Incremental font transfer table.
    ift: T,
    /// Incremental font transfer table.
    iftx: T,
    /// Justification table.
    jstf: T,
    /// Kerning table.
    kern: T,
    /// Extended kerning table.
    kerx: T,
    /// Index to location table.
    loca: T,
    /// Language tag table.
    ltag: T,
    /// Mathematical typesetting table.
    math: T,
    /// Maximum profile table.
    maxp: T,
    /// Metadata table.
    meta: T,
    /// Extended metamorphosis table.
    morx: T,
    /// Metrics variation table.
    mvar: T,
    /// Naming table.
    name: T,
    /// OS/2 and Windows-specific metrics table.
    os2: T,
    /// PostScript information table.
    post: T,
    /// Control value program table.
    prep: T,
    /// Standard bitmap graphics table.
    sbix: T,
    /// Style attributes table.
    stat: T,
    /// Scalable vector graphics table.
    svg: T,
    /// Tracking table.
    trak: T,
    /// Variable composite/component table.
    varc: T,
    /// Vertical header table.
    vhea: T,
    /// Vertical metrics table.
    vmtx: T,
    /// Vertical origin table.
    vorg: T,
    /// Vertical metrics variation table.
    vvar: T,
}

impl<T> PerTableData<T> {
    /// Calls `f` with the tag and associated data for each table.
    fn init_all(&mut self, f: impl Fn(Tag, &mut T)) {
        f(Tag::new(b"ankr"), &mut self.ankr);
        f(Tag::new(b"avar"), &mut self.avar);
        f(Tag::new(b"BASE"), &mut self.base);
        f(Tag::new(b"CFF "), &mut self.cff);
        f(Tag::new(b"CFF2"), &mut self.cff2);
        f(Tag::new(b"CBDT"), &mut self.cbdt);
        f(Tag::new(b"CBLC"), &mut self.cblc);
        f(Tag::new(b"COLR"), &mut self.colr);
        f(Tag::new(b"CPAL"), &mut self.cpal);
        f(Tag::new(b"cmap"), &mut self.cmap);
        f(Tag::new(b"cvar"), &mut self.cvar);
        f(Tag::new(b"cvt "), &mut self.cvt);
        f(Tag::new(b"DSIG"), &mut self.dsig);
        f(Tag::new(b"EBDT"), &mut self.ebdt);
        f(Tag::new(b"EBLC"), &mut self.eblc);
        f(Tag::new(b"feat"), &mut self.feat);
        f(Tag::new(b"fpgm"), &mut self.fpgm);
        f(Tag::new(b"fvar"), &mut self.fvar);
        f(Tag::new(b"gasp"), &mut self.gasp);
        f(Tag::new(b"GDEF"), &mut self.gdef);
        f(Tag::new(b"glyf"), &mut self.glyf);
        f(Tag::new(b"GPOS"), &mut self.gpos);
        f(Tag::new(b"GSUB"), &mut self.gsub);
        f(Tag::new(b"gvar"), &mut self.gvar);
        f(Tag::new(b"hdmx"), &mut self.hdmx);
        f(Tag::new(b"head"), &mut self.head);
        f(Tag::new(b"hhea"), &mut self.hhea);
        f(Tag::new(b"hmtx"), &mut self.hmtx);
        f(Tag::new(b"HVAR"), &mut self.hvar);
        f(Tag::new(b"IFT "), &mut self.ift);
        f(Tag::new(b"IFTX"), &mut self.iftx);
        f(Tag::new(b"JSTF"), &mut self.jstf);
        f(Tag::new(b"kern"), &mut self.kern);
        f(Tag::new(b"kerx"), &mut self.kerx);
        f(Tag::new(b"loca"), &mut self.loca);
        f(Tag::new(b"ltag"), &mut self.ltag);
        f(Tag::new(b"MATH"), &mut self.math);
        f(Tag::new(b"maxp"), &mut self.maxp);
        f(Tag::new(b"meta"), &mut self.meta);
        f(Tag::new(b"morx"), &mut self.morx);
        f(Tag::new(b"MVAR"), &mut self.mvar);
        f(Tag::new(b"name"), &mut self.name);
        f(Tag::new(b"OS/2"), &mut self.os2);
        f(Tag::new(b"post"), &mut self.post);
        f(Tag::new(b"prep"), &mut self.prep);
        f(Tag::new(b"sbix"), &mut self.sbix);
        f(Tag::new(b"STAT"), &mut self.stat);
        f(Tag::new(b"SVG "), &mut self.svg);
        f(Tag::new(b"trak"), &mut self.trak);
        f(Tag::new(b"VARC"), &mut self.varc);
        f(Tag::new(b"vhea"), &mut self.vhea);
        f(Tag::new(b"vmtx"), &mut self.vmtx);
        f(Tag::new(b"VORG"), &mut self.vorg);
        f(Tag::new(b"VVAR"), &mut self.vvar);
    }
}

trait TableDataProvider<'a> where Self: 'a {
    type Entry;

    fn tables(&self) -> &'a PerTableData<Self::Entry>;
    fn table_state(&self, tag: Tag, entry: &'a Self::Entry) -> Option<TableState<'a>>;

    fn ankr(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"ankr"), &self.tables().ankr)
    }

    fn avar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"avar"), &self.tables().avar)
    }

    fn base(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"BASE"), &self.tables().base)
    }

    fn cff(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"CFF "), &self.tables().cff)
    }

    fn cff2(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"CFF2"), &self.tables().cff2)
    }

    fn cbdt(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"CBDT"), &self.tables().cbdt)
    }

    fn cblc(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"CBLC"), &self.tables().cblc)
    }

    fn colr(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"COLR"), &self.tables().colr)
    }

    fn cpal(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"CPAL"), &self.tables().cpal)
    }

    fn cmap(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"cmap"), &self.tables().cmap)
    }

    fn cvar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"cvar"), &self.tables().cvar)
    }

    fn cvt(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"cvt "), &self.tables().cvt)
    }

    fn dsig(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"DSIG"), &self.tables().dsig)
    }

    fn ebdt(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"EBDT"), &self.tables().ebdt)
    }

    fn eblc(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"EBLC"), &self.tables().eblc)
    }

    fn feat(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"feat"), &self.tables().feat)
    }

    fn fpgm(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"fpgm"), &self.tables().fpgm)
    }

    fn fvar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"fvar"), &self.tables().fvar)
    }

    fn gasp(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"gasp"), &self.tables().gasp)
    }

    fn gdef(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"GDEF"), &self.tables().gdef)
    }

    fn glyf(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"glyf"), &self.tables().glyf)
    }

    fn gpos(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"GPOS"), &self.tables().gpos)
    }

    fn gsub(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"GSUB"), &self.tables().gsub)
    }

    fn gvar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"gvar"), &self.tables().gvar)
    }

    fn hdmx(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"hdmx"), &self.tables().hdmx)
    }

    fn head(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"head"), &self.tables().head)
    }

    fn hhea(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"hhea"), &self.tables().hhea)
    }

    fn hmtx(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"hmtx"), &self.tables().hmtx)
    }

    fn hvar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"HVAR"), &self.tables().hvar)
    }

    fn ift(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"IFT "), &self.tables().ift)
    }

    fn iftx(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"IFTX"), &self.tables().iftx)
    }

    fn jstf(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"JSTF"), &self.tables().jstf)
    }

    fn kern(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"kern"), &self.tables().kern)
    }

    fn kerx(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"kerx"), &self.tables().kerx)
    }

    fn loca(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"loca"), &self.tables().loca)
    }

    fn ltag(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"ltag"), &self.tables().ltag)
    }

    fn math(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"MATH"), &self.tables().math)
    }

    fn maxp(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"maxp"), &self.tables().maxp)
    }

    fn meta(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"meta"), &self.tables().meta)
    }

    fn morx(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"morx"), &self.tables().morx)
    }

    fn mvar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"MVAR"), &self.tables().mvar)
    }

    fn name(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"name"), &self.tables().name)
    }

    fn os2(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"OS/2"), &self.tables().os2)
    }

    fn post(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"post"), &self.tables().post)
    }

    fn prep(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"prep"), &self.tables().prep)
    }

    fn sbix(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"sbix"), &self.tables().sbix)
    }

    fn stat(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"STAT"), &self.tables().stat)
    }

    fn svg(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"SVG "), &self.tables().svg)
    }

    fn trak(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"trak"), &self.tables().trak)
    }

    fn varc(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"VARC"), &self.tables().varc)
    }

    fn vhea(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"vhea"), &self.tables().vhea)
    }

    fn vmtx(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"vmtx"), &self.tables().vmtx)
    }

    fn vorg(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"VORG"), &self.tables().vorg)
    }

    fn vvar(&self) -> Option<TableState<'a>> {
        self.table_state(Tag::new(b"VVAR"), &self.tables().vvar)
    }

}

impl FontTables {
    /// Anchor point table data.
    ///
    /// See the [ankr](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html) specification.
    pub fn ankr_data(&self) -> Option<&'_ [u8]> {
        self.ankr_state().map(|state| state.data)
    }

    fn ankr_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.ankr(),
            TableSource::Function(func) => func.ankr(),
        }
    }

    /// Axis variation table data.
    ///
    /// See the [avar](https://learn.microsoft.com/en-us/typography/opentype/spec/avar) specification.
    pub fn avar_data(&self) -> Option<&'_ [u8]> {
        self.avar_state().map(|state| state.data)
    }

    fn avar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.avar(),
            TableSource::Function(func) => func.avar(),
        }
    }

    /// Baseline table data.
    ///
    /// See the [BASE](https://learn.microsoft.com/en-us/typography/opentype/spec/base) specification.
    pub fn base_data(&self) -> Option<&'_ [u8]> {
        self.base_state().map(|state| state.data)
    }

    fn base_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.base(),
            TableSource::Function(func) => func.base(),
        }
    }

    /// Compact font format table data.
    ///
    /// See the [CFF](https://learn.microsoft.com/en-us/typography/opentype/spec/cff) specification.
    pub fn cff_data(&self) -> Option<&'_ [u8]> {
        self.cff_state().map(|state| state.data)
    }

    fn cff_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cff(),
            TableSource::Function(func) => func.cff(),
        }
    }

    /// Compact font format 2.0 table data.
    ///
    /// See the [CFF2](https://learn.microsoft.com/en-us/typography/opentype/spec/cff2) specification.
    pub fn cff2_data(&self) -> Option<&'_ [u8]> {
        self.cff2_state().map(|state| state.data)
    }

    fn cff2_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cff2(),
            TableSource::Function(func) => func.cff2(),
        }
    }

    /// Color bitmap data table data.
    ///
    /// See the [CBDT](https://learn.microsoft.com/en-us/typography/opentype/spec/cbdt) specification.
    pub fn cbdt_data(&self) -> Option<&'_ [u8]> {
        self.cbdt_state().map(|state| state.data)
    }

    fn cbdt_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cbdt(),
            TableSource::Function(func) => func.cbdt(),
        }
    }

    /// Color bitmap location table data.
    ///
    /// See the [CBLC](https://learn.microsoft.com/en-us/typography/opentype/spec/cblc) specification.
    pub fn cblc_data(&self) -> Option<&'_ [u8]> {
        self.cblc_state().map(|state| state.data)
    }

    fn cblc_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cblc(),
            TableSource::Function(func) => func.cblc(),
        }
    }

    /// Color table data.
    ///
    /// See the [COLR](https://learn.microsoft.com/en-us/typography/opentype/spec/colr) specification.
    pub fn colr_data(&self) -> Option<&'_ [u8]> {
        self.colr_state().map(|state| state.data)
    }

    fn colr_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.colr(),
            TableSource::Function(func) => func.colr(),
        }
    }

    /// Color palette table data.
    ///
    /// See the [CPAL](https://learn.microsoft.com/en-us/typography/opentype/spec/cpal) specification.
    pub fn cpal_data(&self) -> Option<&'_ [u8]> {
        self.cpal_state().map(|state| state.data)
    }

    fn cpal_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cpal(),
            TableSource::Function(func) => func.cpal(),
        }
    }

    /// Character to glyph mapping table data.
    ///
    /// See the [cmap](https://learn.microsoft.com/en-us/typography/opentype/spec/cmap) specification.
    pub fn cmap_data(&self) -> Option<&'_ [u8]> {
        self.cmap_state().map(|state| state.data)
    }

    fn cmap_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cmap(),
            TableSource::Function(func) => func.cmap(),
        }
    }

    /// CVT variations table data.
    ///
    /// See the [cvar](https://learn.microsoft.com/en-us/typography/opentype/spec/cvar) specification.
    pub fn cvar_data(&self) -> Option<&'_ [u8]> {
        self.cvar_state().map(|state| state.data)
    }

    fn cvar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cvar(),
            TableSource::Function(func) => func.cvar(),
        }
    }

    /// Control value table data.
    ///
    /// See the [cvt](https://learn.microsoft.com/en-us/typography/opentype/spec/cvt) specification.
    pub fn cvt_data(&self) -> Option<&'_ [u8]> {
        self.cvt_state().map(|state| state.data)
    }

    fn cvt_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.cvt(),
            TableSource::Function(func) => func.cvt(),
        }
    }

    /// Digital signature table data.
    ///
    /// See the [DSIG](https://learn.microsoft.com/en-us/typography/opentype/spec/dsig) specification.
    pub fn dsig_data(&self) -> Option<&'_ [u8]> {
        self.dsig_state().map(|state| state.data)
    }

    fn dsig_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.dsig(),
            TableSource::Function(func) => func.dsig(),
        }
    }

    /// Embedded bitmap data table data.
    ///
    /// See the [EBDT](https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt) specification.
    pub fn ebdt_data(&self) -> Option<&'_ [u8]> {
        self.ebdt_state().map(|state| state.data)
    }

    fn ebdt_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.ebdt(),
            TableSource::Function(func) => func.ebdt(),
        }
    }

    /// Embedded bitmap location data table data.
    ///
    /// See the [EBLC](https://learn.microsoft.com/en-us/typography/opentype/spec/eblc) specification.
    pub fn eblc_data(&self) -> Option<&'_ [u8]> {
        self.eblc_state().map(|state| state.data)
    }

    fn eblc_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.eblc(),
            TableSource::Function(func) => func.eblc(),
        }
    }

    /// Font feature table data.
    ///
    /// See the [feat](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html) specification.
    pub fn feat_data(&self) -> Option<&'_ [u8]> {
        self.feat_state().map(|state| state.data)
    }

    fn feat_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.feat(),
            TableSource::Function(func) => func.feat(),
        }
    }

    /// Font program table data.
    ///
    /// See the [fpgm](https://learn.microsoft.com/en-us/typography/opentype/spec/fpgm) specification.
    pub fn fpgm_data(&self) -> Option<&'_ [u8]> {
        self.fpgm_state().map(|state| state.data)
    }

    fn fpgm_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.fpgm(),
            TableSource::Function(func) => func.fpgm(),
        }
    }

    /// Font variations table data.
    ///
    /// See the [fvar](https://learn.microsoft.com/en-us/typography/opentype/spec/fvar) specification.
    pub fn fvar_data(&self) -> Option<&'_ [u8]> {
        self.fvar_state().map(|state| state.data)
    }

    fn fvar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.fvar(),
            TableSource::Function(func) => func.fvar(),
        }
    }

    /// Grid-fitting and scan-conversion procedure table data.
    ///
    /// See the [gasp](https://learn.microsoft.com/en-us/typography/opentype/spec/gasp) specification.
    pub fn gasp_data(&self) -> Option<&'_ [u8]> {
        self.gasp_state().map(|state| state.data)
    }

    fn gasp_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.gasp(),
            TableSource::Function(func) => func.gasp(),
        }
    }

    /// Glyph definition table data.
    ///
    /// See the [GDEF](https://learn.microsoft.com/en-us/typography/opentype/spec/gdef) specification.
    pub fn gdef_data(&self) -> Option<&'_ [u8]> {
        self.gdef_state().map(|state| state.data)
    }

    fn gdef_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.gdef(),
            TableSource::Function(func) => func.gdef(),
        }
    }

    /// TrueType glyph data table data.
    ///
    /// See the [glyf](https://learn.microsoft.com/en-us/typography/opentype/spec/glyf) specification.
    pub fn glyf_data(&self) -> Option<&'_ [u8]> {
        self.glyf_state().map(|state| state.data)
    }

    fn glyf_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.glyf(),
            TableSource::Function(func) => func.glyf(),
        }
    }

    /// Glyph positioning table data.
    ///
    /// See the [GPOS](https://learn.microsoft.com/en-us/typography/opentype/spec/gpos) specification.
    pub fn gpos_data(&self) -> Option<&'_ [u8]> {
        self.gpos_state().map(|state| state.data)
    }

    fn gpos_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.gpos(),
            TableSource::Function(func) => func.gpos(),
        }
    }

    /// Glyph substitution table data.
    ///
    /// See the [GSUB](https://learn.microsoft.com/en-us/typography/opentype/spec/gsub) specification.
    pub fn gsub_data(&self) -> Option<&'_ [u8]> {
        self.gsub_state().map(|state| state.data)
    }

    fn gsub_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.gsub(),
            TableSource::Function(func) => func.gsub(),
        }
    }

    /// Glyph variation table data.
    ///
    /// See the [gvar](https://learn.microsoft.com/en-us/typography/opentype/spec/gvar) specification.
    pub fn gvar_data(&self) -> Option<&'_ [u8]> {
        self.gvar_state().map(|state| state.data)
    }

    fn gvar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.gvar(),
            TableSource::Function(func) => func.gvar(),
        }
    }

    /// Horizontal device metrics data.
    ///
    /// See the [hdmx](https://learn.microsoft.com/en-us/typography/opentype/spec/hdmx) specification.
    pub fn hdmx_data(&self) -> Option<&'_ [u8]> {
        self.hdmx_state().map(|state| state.data)
    }

    fn hdmx_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.hdmx(),
            TableSource::Function(func) => func.hdmx(),
        }
    }

    /// Font header table data.
    ///
    /// See the [head](https://learn.microsoft.com/en-us/typography/opentype/spec/head) specification.
    pub fn head_data(&self) -> Option<&'_ [u8]> {
        self.head_state().map(|state| state.data)
    }

    fn head_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.head(),
            TableSource::Function(func) => func.head(),
        }
    }

    /// Horizontal header table data.
    ///
    /// See the [hhea](https://learn.microsoft.com/en-us/typography/opentype/spec/hhea) specification.
    pub fn hhea_data(&self) -> Option<&'_ [u8]> {
        self.hhea_state().map(|state| state.data)
    }

    fn hhea_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.hhea(),
            TableSource::Function(func) => func.hhea(),
        }
    }

    /// Horizontal metrics table data.
    ///
    /// See the [hmtx](https://learn.microsoft.com/en-us/typography/opentype/spec/hmtx) specification.
    pub fn hmtx_data(&self) -> Option<&'_ [u8]> {
        self.hmtx_state().map(|state| state.data)
    }

    fn hmtx_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.hmtx(),
            TableSource::Function(func) => func.hmtx(),
        }
    }

    /// Horizontal metrics variation table data.
    ///
    /// See the [HVAR](https://learn.microsoft.com/en-us/typography/opentype/spec/hvar) specification.
    pub fn hvar_data(&self) -> Option<&'_ [u8]> {
        self.hvar_state().map(|state| state.data)
    }

    fn hvar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.hvar(),
            TableSource::Function(func) => func.hvar(),
        }
    }

    /// Incremental font transfer table data.
    ///
    /// See the [IFT](https://www.w3.org/TR/IFT/#font-format-extensions) specification.
    pub fn ift_data(&self) -> Option<&'_ [u8]> {
        self.ift_state().map(|state| state.data)
    }

    fn ift_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.ift(),
            TableSource::Function(func) => func.ift(),
        }
    }

    /// Incremental font transfer table data.
    ///
    /// See the [IFTX](https://www.w3.org/TR/IFT/#font-format-extensions) specification.
    pub fn iftx_data(&self) -> Option<&'_ [u8]> {
        self.iftx_state().map(|state| state.data)
    }

    fn iftx_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.iftx(),
            TableSource::Function(func) => func.iftx(),
        }
    }

    /// Justification table data.
    ///
    /// See the [JSTF](https://learn.microsoft.com/en-us/typography/opentype/spec/jstf) specification.
    pub fn jstf_data(&self) -> Option<&'_ [u8]> {
        self.jstf_state().map(|state| state.data)
    }

    fn jstf_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.jstf(),
            TableSource::Function(func) => func.jstf(),
        }
    }

    /// Kerning table data.
    ///
    /// See the [kern](https://learn.microsoft.com/en-us/typography/opentype/spec/kern) specification.
    pub fn kern_data(&self) -> Option<&'_ [u8]> {
        self.kern_state().map(|state| state.data)
    }

    fn kern_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.kern(),
            TableSource::Function(func) => func.kern(),
        }
    }

    /// Extended kerning table data.
    ///
    /// See the [kerx](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html) specification.
    pub fn kerx_data(&self) -> Option<&'_ [u8]> {
        self.kerx_state().map(|state| state.data)
    }

    fn kerx_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.kerx(),
            TableSource::Function(func) => func.kerx(),
        }
    }

    /// Index to location table data.
    ///
    /// See the [loca](https://learn.microsoft.com/en-us/typography/opentype/spec/loca) specification.
    pub fn loca_data(&self) -> Option<&'_ [u8]> {
        self.loca_state().map(|state| state.data)
    }

    fn loca_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.loca(),
            TableSource::Function(func) => func.loca(),
        }
    }

    /// Language tag table data.
    ///
    /// See the [ltag](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ltag.html) specification.
    pub fn ltag_data(&self) -> Option<&'_ [u8]> {
        self.ltag_state().map(|state| state.data)
    }

    fn ltag_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.ltag(),
            TableSource::Function(func) => func.ltag(),
        }
    }

    /// Mathematical typesetting table data.
    ///
    /// See the [MATH](https://learn.microsoft.com/en-us/typography/opentype/spec/math) specification.
    pub fn math_data(&self) -> Option<&'_ [u8]> {
        self.math_state().map(|state| state.data)
    }

    fn math_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.math(),
            TableSource::Function(func) => func.math(),
        }
    }

    /// Maximum profile table data.
    ///
    /// See the [maxp](https://learn.microsoft.com/en-us/typography/opentype/spec/maxp) specification.
    pub fn maxp_data(&self) -> Option<&'_ [u8]> {
        self.maxp_state().map(|state| state.data)
    }

    fn maxp_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.maxp(),
            TableSource::Function(func) => func.maxp(),
        }
    }

    /// Metadata table data.
    ///
    /// See the [meta](https://learn.microsoft.com/en-us/typography/opentype/spec/meta) specification.
    pub fn meta_data(&self) -> Option<&'_ [u8]> {
        self.meta_state().map(|state| state.data)
    }

    fn meta_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.meta(),
            TableSource::Function(func) => func.meta(),
        }
    }

    /// Extended metamorphosis table data.
    ///
    /// See the [morx](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html) specification.
    pub fn morx_data(&self) -> Option<&'_ [u8]> {
        self.morx_state().map(|state| state.data)
    }

    fn morx_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.morx(),
            TableSource::Function(func) => func.morx(),
        }
    }

    /// Metrics variation table data.
    ///
    /// See the [MVAR](https://learn.microsoft.com/en-us/typography/opentype/spec/mvar) specification.
    pub fn mvar_data(&self) -> Option<&'_ [u8]> {
        self.mvar_state().map(|state| state.data)
    }

    fn mvar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.mvar(),
            TableSource::Function(func) => func.mvar(),
        }
    }

    /// Naming table data.
    ///
    /// See the [name](https://learn.microsoft.com/en-us/typography/opentype/spec/name) specification.
    pub fn name_data(&self) -> Option<&'_ [u8]> {
        self.name_state().map(|state| state.data)
    }

    fn name_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.name(),
            TableSource::Function(func) => func.name(),
        }
    }

    /// OS/2 and Windows-specific metrics table data.
    ///
    /// See the [OS/2](https://learn.microsoft.com/en-us/typography/opentype/spec/os2) specification.
    pub fn os2_data(&self) -> Option<&'_ [u8]> {
        self.os2_state().map(|state| state.data)
    }

    fn os2_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.os2(),
            TableSource::Function(func) => func.os2(),
        }
    }

    /// PostScript information table data.
    ///
    /// See the [post](https://learn.microsoft.com/en-us/typography/opentype/spec/post) specification.
    pub fn post_data(&self) -> Option<&'_ [u8]> {
        self.post_state().map(|state| state.data)
    }

    fn post_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.post(),
            TableSource::Function(func) => func.post(),
        }
    }

    /// Control value program table data.
    ///
    /// See the [prep](https://learn.microsoft.com/en-us/typography/opentype/spec/prep) specification.
    pub fn prep_data(&self) -> Option<&'_ [u8]> {
        self.prep_state().map(|state| state.data)
    }

    fn prep_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.prep(),
            TableSource::Function(func) => func.prep(),
        }
    }

    /// Standard bitmap graphics table data.
    ///
    /// See the [sbix](https://learn.microsoft.com/en-us/typography/opentype/spec/sbix) specification.
    pub fn sbix_data(&self) -> Option<&'_ [u8]> {
        self.sbix_state().map(|state| state.data)
    }

    fn sbix_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.sbix(),
            TableSource::Function(func) => func.sbix(),
        }
    }

    /// Style attributes table data.
    ///
    /// See the [STAT](https://learn.microsoft.com/en-us/typography/opentype/spec/stat) specification.
    pub fn stat_data(&self) -> Option<&'_ [u8]> {
        self.stat_state().map(|state| state.data)
    }

    fn stat_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.stat(),
            TableSource::Function(func) => func.stat(),
        }
    }

    /// Scalable vector graphics table data.
    ///
    /// See the [SVG](https://learn.microsoft.com/en-us/typography/opentype/spec/svg) specification.
    pub fn svg_data(&self) -> Option<&'_ [u8]> {
        self.svg_state().map(|state| state.data)
    }

    fn svg_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.svg(),
            TableSource::Function(func) => func.svg(),
        }
    }

    /// Tracking table data.
    ///
    /// See the [trak](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6trak.html) specification.
    pub fn trak_data(&self) -> Option<&'_ [u8]> {
        self.trak_state().map(|state| state.data)
    }

    fn trak_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.trak(),
            TableSource::Function(func) => func.trak(),
        }
    }

    /// Variable composite/component table data.
    ///
    /// See the [VARC](https://github.com/harfbuzz/boring-expansion-spec/blob/main/VARC.md) specification.
    pub fn varc_data(&self) -> Option<&'_ [u8]> {
        self.varc_state().map(|state| state.data)
    }

    fn varc_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.varc(),
            TableSource::Function(func) => func.varc(),
        }
    }

    /// Vertical header table data.
    ///
    /// See the [vhea](https://learn.microsoft.com/en-us/typography/opentype/spec/vhea) specification.
    pub fn vhea_data(&self) -> Option<&'_ [u8]> {
        self.vhea_state().map(|state| state.data)
    }

    fn vhea_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.vhea(),
            TableSource::Function(func) => func.vhea(),
        }
    }

    /// Vertical metrics table data.
    ///
    /// See the [vmtx](https://learn.microsoft.com/en-us/typography/opentype/spec/vmtx) specification.
    pub fn vmtx_data(&self) -> Option<&'_ [u8]> {
        self.vmtx_state().map(|state| state.data)
    }

    fn vmtx_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.vmtx(),
            TableSource::Function(func) => func.vmtx(),
        }
    }

    /// Vertical origin table data.
    ///
    /// See the [VORG](https://learn.microsoft.com/en-us/typography/opentype/spec/vorg) specification.
    pub fn vorg_data(&self) -> Option<&'_ [u8]> {
        self.vorg_state().map(|state| state.data)
    }

    fn vorg_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.vorg(),
            TableSource::Function(func) => func.vorg(),
        }
    }

    /// Vertical metrics variation table data.
    ///
    /// See the [VVAR](https://learn.microsoft.com/en-us/typography/opentype/spec/vvar) specification.
    pub fn vvar_data(&self) -> Option<&'_ [u8]> {
        self.vvar_state().map(|state| state.data)
    }

    fn vvar_state(&self) -> Option<TableState<'_>> {
        match &self.0 {
            TableSource::None => None,
            TableSource::Blob(blob) => blob.vvar(),
            TableSource::Function(func) => func.vvar(),
        }
    }

}
