Code to get font names from sfnt container object

This commit is contained in:
Kovid Goyal 2021-05-22 06:47:22 +05:30
parent 23c65a4de9
commit 01666d4fff
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -106,6 +106,13 @@ class Sfnt(object):
ans[tag] = len(self[tag]) ans[tag] = len(self[tag])
return ans return ans
def get_all_font_names(self):
name_table = self.get(b'name')
if name_table is None:
return {}
from calibre.utils.fonts.metadata import get_font_names2
return get_font_names2(name_table.raw, raw_is_table=True)
def __call__(self, stream=None): def __call__(self, stream=None):
stream = BytesIO() if stream is None else stream stream = BytesIO() if stream is None else stream