diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2018-10-12 00:22:53 -0500 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2019-09-26 16:48:42 +0300 |
commit | 6d98071cf6c5dbd48660ff8799b1000837600b0e (patch) | |
tree | 4e33fdc5eab5915a3ad99ac1523664fa78f97ed0 /libass/ass_font.c | |
parent | e52fd88b3b52e3da2dba167f3fbadb8342c6da56 (diff) | |
download | libass-6d98071cf6c5dbd48660ff8799b1000837600b0e.tar.bz2 libass-6d98071cf6c5dbd48660ff8799b1000837600b0e.tar.xz |
font: add function to get the actual weight of a font face
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r-- | libass/ass_font.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index 480d5f9..d2fd76d 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -303,6 +303,23 @@ void ass_font_set_size(ASS_Font *font, double size) } /** + * \brief Get face weight + **/ +int ass_face_get_weight(FT_Face face) +{ +#if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 6) + TT_OS2 *os2 = FT_Get_Sfnt_Table(face, FT_SFNT_OS2); +#else + // This old name is still included (as a macro), but deprecated as of 2.6, so avoid using it if we can + TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2); +#endif + if (os2 && os2->version != 0xffff && os2->usWeightClass) + return os2->usWeightClass; + else + return 300 * !!(face->style_flags & FT_STYLE_FLAG_BOLD) + 400; +} + +/** * \brief Get maximal font ascender and descender. **/ void ass_font_get_asc_desc(ASS_Font *font, int face_index, |