Skip to content

Add support for InstanceRecord in fvar table #208

@Kumasan00

Description

@Kumasan00

Hi,

I've been working with variable fonts and noticed that while ttf-parser supports variation axes, it doesn't currently expose the Instance Records (named instances) defined in the fvar table.

Accessing these instances is crucial for retrieving named styles (like "Light", "Bold", etc.) and their corresponding coordinates. As discussed in #129, variable font support is a broad topic, but I believe this specific feature is a key missing piece.

Proposal & Implementation I have already implemented the necessary structures and parsing logic to support this. My implementation adds:

  • Instance struct representing an Instance Record.
  • Instances struct and iterator to traverse the records.
  • Parsing logic that handles the optional postScriptNameID based on the record size.

Here is an example of how it works with my changes:

// Example usage
if let Some(fvar) = face.tables().fvar {
    for instance in fvar.instances.iter() {
        println!("Subfamily Name ID: {}", instance.subfamily_name_id);
        
        // Access coordinates
        for coord in instance.coordinates {
             println!("Coord: {:?}", coord);
        }
    }
}

I will open a Pull Request shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions