From 35f5e28ce5f5f6e523c940af415f19269cd12327 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 23 Feb 2022 15:47:08 +0100 Subject: [PATCH] implement changes without freetype --- src/vkvg_fonts.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/vkvg_fonts.c b/src/vkvg_fonts.c index edbcfe5..1847d99 100644 --- a/src/vkvg_fonts.c +++ b/src/vkvg_fonts.c @@ -404,13 +404,7 @@ void _font_cache_add_font_identity (VkvgContext ctx, const char* fontFilePath, c //select current font for context _vkvg_font_t* _find_or_create_font_size (VkvgContext ctx) { _vkvg_font_identity_t* font = ctx->currentFont; -#ifndef VKVG_USE_FREETYPE - if (!font->stbInfo.data) { - if (!stbtt_InitFont(&font->stbInfo, font->fontBuffer, 0)) - printf("failed\n"); - stbtt_GetFontVMetrics(&font->stbInfo, &font->ascent, &font->descent, &font->lineGap); - } -#endif + for (uint32_t i = 0; i < font->sizeCount; ++i) { if (font->sizes[i].charSize == ctx->selectedCharSize) return &font->sizes[i]; @@ -435,6 +429,8 @@ _vkvg_font_t* _find_or_create_font_size (VkvgContext ctx) { else newSize.curLine.height = newSize.face->height >> 6; #else + assert(stbtt_InitFont(&font->stbInfo, font->fontBuffer, 0) && "stbtt_initFont failed"); + stbtt_GetFontVMetrics(&font->stbInfo, &font->ascent, &font->descent, &font->lineGap); newSize.charLookup = (_char_ref**)calloc (font->stbInfo.numGlyphs, sizeof(_char_ref*)); //newSize.scale = stbtt_ScaleForPixelHeight(&font->stbInfo, newSize.charSize); newSize.scale = stbtt_ScaleForMappingEmToPixels(&font->stbInfo, newSize.charSize); -- 2.47.3