MCPcopy Create free account
hub / github.com/comaps/comaps / GetGlyphImage

Method GetGlyphImage

libs/drape/glyph_manager.cpp:160–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 bool HasGlyph(strings::UniChar unicodePoint) const { return FT_Get_Char_Index(m_fontFace, unicodePoint) != 0; }
159
160 GlyphImage GetGlyphImage(uint16_t glyphId, int pixelHeight, bool sdf) const
161 {
162 FREETYPE_CHECK(FT_Set_Pixel_Sizes(m_fontFace, 0, pixelHeight));
163 // FT_LOAD_RENDER with FT_RENDER_MODE_SDF uses bsdf driver that is around 3x times faster
164 // than sdf driver, activated by FT_LOAD_DEFAULT + FT_RENDER_MODE_SDF
165 FREETYPE_CHECK(FT_Load_Glyph(m_fontFace, glyphId, FT_LOAD_RENDER));
166 if (sdf)
167 FREETYPE_CHECK(FT_Render_Glyph(m_fontFace->glyph, FT_RENDER_MODE_SDF));
168
169 FT_Bitmap const & bitmap = m_fontFace->glyph->bitmap;
170
171 SharedBufferManager::shared_buffer_ptr_t data;
172 if (bitmap.buffer != nullptr)
173 {
174 // Bitmap is stored without a padding.
175 data = SharedBufferManager::instance().reserveSharedBuffer(bitmap.width * bitmap.rows);
176 auto ptr = data->data();
177
178 for (unsigned int row = 0; row < bitmap.rows; ++row)
179 {
180 unsigned int const dstBaseIndex = row * bitmap.width;
181 int const srcBaseIndex = static_cast<int>(row) * bitmap.pitch;
182 for (unsigned int column = 0; column < bitmap.width; ++column)
183 ptr[dstBaseIndex + column] = bitmap.buffer[srcBaseIndex + column];
184 }
185 }
186 return {bitmap.width, bitmap.rows, data};
187 }
188
189 void GetCharcodes(std::vector<FT_ULong> & charcodes) const
190 {

Callers

nothing calls this directly

Calls 2

reserveSharedBufferMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected