Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opentype font writer #102

Merged
merged 4 commits into from
Nov 1, 2023
Merged

Opentype font writer #102

merged 4 commits into from
Nov 1, 2023

Conversation

benoitkugler
Copy link
Contributor

This PR adds support to write an Opentype font file from a list of tables.

This is a simple implementation, since neither font collections nor compressed format (WOFF) are supported.

This paves the way for features such as subsetter or variable font instantiater.

Conceptually, the Write function performs the reverse operation of NewLoader, so that I think it should belong to this package.

Note that the GUI toolkits are probably NOT interested by such features, but since the Go linker is able to remove dead code, it should come with no cost for end users anyway.

Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool addition - not quite sure about the naming though - will this support other font types like collections? if so the generic Write name may need clarity.

// Write creates a single font file from the given [tables] slice,
// which must be sorted by Tag
func Write(tables []Table) []byte {
buffer := writeTTF(tables)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has a single purpose - to call writeTTF, which is strange - if it is generic we don't need the extra function, but if it is because this writer is for TTF perhaps the generic name isn't right?

Copy link
Contributor Author

@benoitkugler benoitkugler Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. In the future, we may want to support other formats, like web font (WOFF). In such case, the Write function would become Write(tables []Table, woff bool) []byte, and internally call writeTTF or writeWOFF.
But, for now, it seems indeed cleaner to drop the internal function and rename Write to, say, WriteTTF.

Copy link
Member

@whereswaldon whereswaldon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Feature looks good! Thank you.

@benoitkugler benoitkugler merged commit a36c1d9 into main Nov 1, 2023
20 checks passed
@benoitkugler benoitkugler deleted the opentype-writer branch November 1, 2023 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants