| 624 | } |
| 625 | |
| 626 | static int SysFonts_DoRegister(const cc_string* path, int faceIndex, SysFont_RegisterCallback callback) { |
| 627 | struct SysFont font; |
| 628 | FT_Open_Args args; |
| 629 | FT_Error err; |
| 630 | int flags, count; |
| 631 | |
| 632 | if (SysFont_Init(path, &font, &args)) return 0; |
| 633 | err = FT_New_Face(ft_lib, &args, faceIndex, &font.face); |
| 634 | if (err) { SysFont_Done(&font); return 0; } |
| 635 | |
| 636 | flags = font.face->style_flags; |
| 637 | count = font.face->num_faces; |
| 638 | |
| 639 | if (flags == (FT_STYLE_FLAG_BOLD | FT_STYLE_FLAG_ITALIC)) { |
| 640 | SysFonts_Add(path, font.face, faceIndex, 'Z', "Bold Italic"); |
| 641 | } else if (flags == FT_STYLE_FLAG_BOLD) { |
| 642 | SysFonts_Add(path, font.face, faceIndex, 'B', "Bold"); |
| 643 | } else if (flags == FT_STYLE_FLAG_ITALIC) { |
| 644 | SysFonts_Add(path, font.face, faceIndex, 'I', "Italic"); |
| 645 | } else if (flags == 0) { |
| 646 | SysFonts_Add(path, font.face, faceIndex, 'R', "Regular"); |
| 647 | } |
| 648 | |
| 649 | if (callback) callback(path); |
| 650 | FT_Done_Face(font.face); |
| 651 | return count; |
| 652 | } |
| 653 | |
| 654 | cc_result SysFonts_Register(const cc_string* path, SysFont_RegisterCallback callback) { |
| 655 | cc_string entry, name, value; |
no test coverage detected