-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for parsing WOFF2 fonts.
This change uses the font/woff2 package for parsing WOFF2 font files. Update all parts of the documentation, usage, etc., to say that WOFF2 fonts are now supported. Add test .woff2 file to testdata and run smoke test on it. Add benchmarks for parsing WOFF2 font files. Fix minor Go style and documentation issues. Resolves #1.
- Loading branch information
Showing
12 changed files
with
86 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Package sfnt provides support for sfnt based font formats. | ||
// | ||
// This includes OpenType, TrueType, wOFF, WOFF2, and EOT (though EOT is currently unimplemented). | ||
// | ||
// Usually you will want to parse a font, make modifications, and then output the modified | ||
// font. If you're really brave, you can build a new font from scratch. | ||
package sfnt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sfnt | ||
|
||
import ( | ||
"bytes" | ||
|
||
"dmitri.shuralyov.com/font/woff2" | ||
) | ||
|
||
func parseWOFF2(file File) (*Font, error) { | ||
f, err := woff2.Parse(file) | ||
if err != nil { | ||
return nil, err | ||
} | ||
font := &Font{ | ||
file: bytes.NewReader(f.FontData), | ||
scalerType: Tag{f.Header.Flavor}, | ||
tables: make(map[Tag]tableSection, f.Header.NumTables), | ||
} | ||
for _, t := range f.TableDirectory.Tables() { | ||
tag := Tag{t.Tag} | ||
font.tables[tag] = tableSection{ | ||
tag: tag, | ||
offset: uint32(t.Offset), | ||
length: uint32(t.Length), | ||
} | ||
} | ||
return font, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ Raleway - Raleway-v4020-Regular.otf | |
SIL Open Font License, 1.1 | ||
Copyright (c) 2010 - 2013, Matt McInerney ([email protected]), Pablo Impallari ([email protected]), Rodrigo Fuenzalida ([email protected]) with Reserved Font Name "Raleway" | ||
|
||
Roboto - Roboto-BoldItalic.ttf | ||
Roboto - Roboto-BoldItalic.ttf | ||
Apache License, version 2.0 | ||
Copyright 2011 Google Inc. All Rights Reserved. | ||
Copyright 2011 Google Inc. All Rights Reserved. | ||
|
||
Go-Regular.woff2 | ||
BSD 3-Clause License | ||
Copyright (c) 2016 Bigelow & Holmes Inc.. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters