Skip to content

Is there a way to know if a font is Truetype or OpenType? #2619

Answered by justvanrossum
moi15moi asked this question in Q&A
Discussion options

You must be logged in to vote
from fontTools.ttLib import TTFont

f = TTFont("path/to/font")
if "glyf" in f:
    print("font is TTF")
else:
    print("font is OTF")

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@kenmcd
Comment options

@jenskutilek
Comment options

@justvanrossum
Comment options

@justvanrossum
Comment options

@moi15moi
Comment options

Answer selected by moi15moi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants