improve font_stb_get_vmetrics for mingw

This commit is contained in:
lixianjing 2024-10-23 14:54:55 +08:00
parent 7d3c89e73e
commit 90f59cace5
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2024/10/23
* 修复mingw编译下font_stb_get_vmetrics异常问题(感谢颖健提供补丁)
2024/10/21
* 完善AWTK字号转成标准字号的功能(感谢颖健提供补丁)
* 打开对话框失去焦点时Ctrl状态未恢复的问题(感谢颖健提供补丁)

View File

@ -85,12 +85,15 @@ static bool_t font_stb_match(font_t* f, const char* name, font_size_t font_size)
}
static font_vmetrics_t font_stb_get_vmetrics(font_t* f, font_size_t font_size) {
int16_t ascender = 0;
int16_t descender = 0;
font_vmetrics_t vmetrics;
int ascender = 0;
int descender = 0;
float scale = 0.0f;
font_stb_t* font = (font_stb_t*)f;
stbtt_fontinfo* sf = &(font->stb_font);
float scale = stbtt_ScaleForPixelHeight(sf, font_size);
const stbtt_fontinfo* sf = &(font->stb_font);
font_vmetrics_t vmetrics = {font_size, 0, 0, 0, 0, 0};
return_value_if_fail(sf != NULL, vmetrics);
scale = stbtt_ScaleForPixelHeight(sf, font_size);
if (scale == INFINITY) {
scale = stbtt_ScaleForMappingEmToPixels(sf, font_size);
}