diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2022-09-24 03:36:49 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2022-09-24 03:36:49 +0300 |
commit | cd1631b17dd0e25a8a398fb00a982ca5f0633558 (patch) | |
tree | ee8d9cdb560c815ea86d952ef2f053c6435865c1 /source/blender/blenfont/intern/blf_font.c | |
parent | 88a602bc64fc2a86411d67881439a04486f95030 (diff) |
BLF: Refactor of DPI
Correction of U.dpi to hold actual monitor DPI. Simplify font sizing by
omitting DPI as API argument, always using 72 internally.
See D15961 for more details.
Differential Revision: https://developer.blender.org/D15961
Reviewed by Campbell Barton
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index fcded5a13cd..3d7e83bc22f 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1300,7 +1300,6 @@ static void blf_font_fill(FontBLF *font) font->clip_rec.ymin = 0; font->clip_rec.ymax = 0; font->flags = 0; - font->dpi = 0; font->size = 0; BLI_listbase_clear(&font->cache); font->kerning_cache = NULL; @@ -1613,8 +1612,8 @@ void blf_ensure_size(FontBLF *font) scaler.width = 0; scaler.height = round_fl_to_uint(font->size * 64.0f); scaler.pixel = 0; - scaler.x_res = font->dpi; - scaler.y_res = font->dpi; + scaler.x_res = BLF_DPI; + scaler.y_res = BLF_DPI; if (FTC_Manager_LookupSize(ftc_manager, &scaler, &font->ft_size) == FT_Err_Ok) { font->ft_size->generic.data = (void *)font; font->ft_size->generic.finalizer = blf_size_finalizer; @@ -1624,7 +1623,7 @@ void blf_ensure_size(FontBLF *font) BLI_assert_unreachable(); } -bool blf_font_size(FontBLF *font, float size, uint dpi) +bool blf_font_size(FontBLF *font, float size) { if (!blf_ensure_face(font)) { return false; @@ -1635,15 +1634,15 @@ bool blf_font_size(FontBLF *font, float size, uint dpi) /* Adjust our new size to be on even 64ths. */ size = (float)ft_size / 64.0f; - if (font->size != size || font->dpi != dpi) { + if (font->size != size) { if (font->flags & BLF_CACHED) { FTC_ScalerRec scaler = {0}; scaler.face_id = font; scaler.width = 0; scaler.height = ft_size; scaler.pixel = 0; - scaler.x_res = dpi; - scaler.y_res = dpi; + scaler.x_res = BLF_DPI; + scaler.y_res = BLF_DPI; if (FTC_Manager_LookupSize(ftc_manager, &scaler, &font->ft_size) != FT_Err_Ok) { return false; } @@ -1651,7 +1650,7 @@ bool blf_font_size(FontBLF *font, float size, uint dpi) font->ft_size->generic.finalizer = blf_size_finalizer; } else { - if (FT_Set_Char_Size(font->face, 0, ft_size, dpi, dpi) != FT_Err_Ok) { + if (FT_Set_Char_Size(font->face, 0, ft_size, BLF_DPI, BLF_DPI) != FT_Err_Ok) { return false; } font->ft_size = font->face->size; @@ -1659,7 +1658,6 @@ bool blf_font_size(FontBLF *font, float size, uint dpi) } font->size = size; - font->dpi = dpi; return true; } |