| 124 | DISALLOW_COPY_AND_MOVE(Font); |
| 125 | |
| 126 | Font(ReaderPtr<Reader> && fontReader, FT_Library lib) : m_fontReader(std::move(fontReader)), m_fontFace(nullptr) |
| 127 | { |
| 128 | std::memset(&m_stream, 0, sizeof(m_stream)); |
| 129 | m_stream.size = static_cast<unsigned long>(m_fontReader.Size()); |
| 130 | m_stream.descriptor.pointer = &m_fontReader; |
| 131 | m_stream.read = &Font::Read; |
| 132 | m_stream.close = &Font::Close; |
| 133 | |
| 134 | FT_Open_Args args = {}; |
| 135 | args.flags = FT_OPEN_STREAM; |
| 136 | args.stream = &m_stream; |
| 137 | |
| 138 | FT_Error const err = FT_Open_Face(lib, &args, 0, &m_fontFace); |
| 139 | if (err || !IsValid()) |
| 140 | MYTHROW(InvalidFontException, (g_FT_Errors[err].m_code, g_FT_Errors[err].m_message)); |
| 141 | |
| 142 | // The same font size is used to render all glyphs to textures and to shape them. |
| 143 | FT_Set_Pixel_Sizes(m_fontFace, kBaseFontSizePixels, kBaseFontSizePixels); |
| 144 | FT_Activate_Size(m_fontFace->size); |
| 145 | } |
| 146 | |
| 147 | ~Font() |
| 148 | { |