You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I prefer not to use LOCK_FONTCACHE&UNLOCK_FONTCACHE in the vkvg_fonts. cpp file, because locking will reduce the efficiency of the program, so i think traverse all bitmaps of a font and copy them to texture at one time, for font size, we can use scaling factor for coordinates,just like this:
// Writing horisontal text
auto gi = fi->GetGlyphInfo(font_face, text[0]);
auto trans = glm::vec2{ 0,gi->horisontal_coords.top_left.y };
location -= trans;//change the baseline
ret.aabb.top_left = gi->horisontal_coords.top_left * scale + location; //scale to change the font size
ret.aabb.bottom_right = gi->horisontal_coords.bottom_right * scale + location;
for (auto c : text) {
auto gi = fi->GetGlyphInfo(font_face, c);
AppendBox(location, gi->horisontal_coords, gi->uv_coords, gi->atlas_index);
location.x += (gi->horisontal_advance + kerning) * scale.x;
}
and the function of GetGlyphInfo:
const vk2d::vk2d_internal::GlyphInfo *vk2d::vk2d_internal::FontResourceImpl::GetGlyphInfo(
uint32_t font_face,
uint32_t character
) const
{
auto & face_info = face_infos[ font_face ];
auto & charmap = face_info.charmap;
auto glyph_it = charmap.find( character );
auto glyph_index = uint32_t( 0 );
if( glyph_it != charmap.end() ) {
glyph_index = glyph_it->second;
} else {
glyph_index = face_info.fallback_glyph_index;
}
return &face_info.glyph_infos[ glyph_index ];
}
The ideal solution for the font lock would be a reader/writer lock, I may think also of an alternative font provider (selectable on compile, or maybe a runtime option) that will be static with all preloaded glyph and no locking on consume.
You can maybe propose a PR for such a solution with all preloaded glyph, on my side I have some priorities with client (employer) that makes it hard for me to work on that for now.
I prefer not to use LOCK_FONTCACHE&UNLOCK_FONTCACHE in the vkvg_fonts. cpp file, because locking will reduce the efficiency of the program, so i think traverse all bitmaps of a font and copy them to texture at one time, for font size, we can use scaling factor for coordinates,just like this:
and the function of GetGlyphInfo:
The above code comes from https://github.com/Noxagonal/Vulkan2DRenderer
The text was updated successfully, but these errors were encountered: