MCPcopy Create free account
hub / github.com/arrayfire/forge / loadAtlasWithGlyphs

Method loadAtlasWithGlyphs

src/backend/opengl/font_impl.cpp:87–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85#endif
86
87void font_impl::loadAtlasWithGlyphs(const size_t pFontSize)
88{
89 FT_Library library;
90 FT_Face face;
91 /* Initialize freetype font library */
92 FT_Error bError = FT_Init_FreeType(&library);
93 if (bError)
94 FT_THROW_ERROR("Freetype Initialization failed", FG_ERR_FREETYPE_ERROR);
95 /* get font face for requested font */
96 bError = FT_New_Face(library, mTTFfile.c_str(), 0, &face);
97 if (bError) {
98 FT_Done_FreeType(library);
99 FT_THROW_ERROR("Freetype face initilization", FG_ERR_FREETYPE_ERROR);
100 }
101 /* Select charmap */
102 bError = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
103 if (bError) {
104 FT_Done_Face(face);
105 FT_Done_FreeType(library);
106 FT_THROW_ERROR("Freetype charmap set failed", FG_ERR_FREETYPE_ERROR);
107 }
108 /* set the pixel size of font */
109 bError = FT_Set_Pixel_Sizes(face, 0, (FT_UInt)pFontSize);
110 if (bError) {
111 FT_Done_Face(face);
112 FT_Done_FreeType(library);
113 FT_THROW_ERROR("Freetype char size set failed", FG_ERR_FREETYPE_ERROR);
114 }
115
116 size_t missed = 0;
117
118 /* retrieve the list of current font size */
119 auto& currList = mGlyphLists[pFontSize-size_t(MIN_FONT_SIZE)];
120
121 for (int i=START_CHAR; i<=END_CHAR; ++i)
122 {
123 FT_UInt glyphIndex = FT_Get_Char_Index(face, (FT_ULong)i);
124
125 FT_Int32 flags = 0;
126
127 /* solid outline */
128 flags |= FT_LOAD_NO_BITMAP;
129 flags |= FT_LOAD_FORCE_AUTOHINT;
130
131 /* load glyph */
132 FT_Error bError = FT_Load_Glyph(face, glyphIndex, flags);
133 if (bError) {
134 FT_Done_Face(face);
135 FT_Done_FreeType(library);
136 FT_THROW_ERROR("FT_Load_Glyph failed", FG_ERR_FREETYPE_ERROR);
137 }
138
139 FT_Glyph currGlyph;;
140
141 bError = FT_Get_Glyph(face->glyph, &currGlyph);
142 if (bError) {
143 FT_Done_Face(face);
144 FT_Done_FreeType(library);

Callers

nothing calls this directly

Calls 4

getRegionMethod · 0.80
setRegionMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected