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

[ttfcomponentizer] Use get_font_format from fdkutils #1069

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions python/afdko/ttfcomponentizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
from fontTools.ufoLib.errors import UFOLibError
from defcon import Font

from afdko.fdkutils import get_font_format

__version__ = '0.2.2'

__version__ = '0.2.3'


PUBLIC_PSNAMES = "public.postscriptNames"
Expand Down Expand Up @@ -275,14 +277,6 @@ def get_glyph_names_mapping(ufo_path):
return ufo, get_goadb_names_mapping(ufo_path)


def get_font_format(font_file_path):
with open(font_file_path, "rb") as f:
head = f.read(4).decode()
if head in ("\0\1\0\0", "true"):
return "TTF"
return None


def validate_font_path(path):
path = os.path.realpath(path)
if not (os.path.isfile(path) and get_font_format(path) == 'TTF'):
Expand Down