1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:07:35 +00:00

LibTTF: Parse TTF "name" table

This commit is contained in:
Stephan Unverwerth 2021-01-01 00:16:18 +01:00 committed by Andreas Kling
parent f12754ee10
commit 2c4e13f14a
3 changed files with 91 additions and 2 deletions

View file

@ -146,4 +146,40 @@ private:
u32 m_number_of_h_metrics { 0 };
};
class Name {
public:
static Optional<Name> from_slice(const ReadonlyBytes&);
String family_name() const { return string_for_id(NameId::FamilyName); }
String subfamily_name() const { return string_for_id(NameId::SubfamilyName); }
String typographic_family_name() const { return string_for_id(NameId::TypographicFamilyName); }
String typographic_subfamily_name() const { return string_for_id(NameId::TypographicSubfamilyName); }
private:
enum class NameId {
Copyright = 0,
FamilyName = 1,
SubfamilyName = 2,
UniqueIdentifier = 3,
FullName = 4,
VersionString = 5,
PostscriptName = 6,
Trademark = 7,
Manufacturer = 8,
Designer = 9,
Description = 10,
TypographicFamilyName = 16,
TypographicSubfamilyName = 17,
};
Name(const ReadonlyBytes& slice)
: m_slice(slice)
{
}
String string_for_id(NameId id) const;
ReadonlyBytes m_slice;
};
}