| 195 | } |
| 196 | |
| 197 | OutlineFont *LoadFont(string_view name) { |
| 198 | FT_Error err = 0; |
| 199 | if (!library) err = FT_Init_FreeType(&library); |
| 200 | if (!err) { |
| 201 | string fbuf; |
| 202 | if (LoadFile(name, &fbuf) >= 0) { |
| 203 | FT_Face face; |
| 204 | err = FT_New_Memory_Face(library, (const FT_Byte *)fbuf.c_str(), (FT_Long)fbuf.length(), |
| 205 | 0, &face); |
| 206 | if (!err) return new OutlineFont(face, fbuf); |
| 207 | } |
| 208 | } |
| 209 | return nullptr; |
| 210 | } |
| 211 | |
| 212 | OutlineFont::~OutlineFont() { |
| 213 | FT_Done_Face((FT_Face)fthandle); |