mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-02 20:47:23 +01:00
imgui_freetype: fixed issue where glyph advances would incorrectly be snapped to pixels.
This commit is contained in:
parent
007735737a
commit
4c64ba16c5
@ -47,6 +47,10 @@ Breaking changes:
|
|||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
- ImDrawList: texture baked storage for thick line reduced from ~64x64 to ~32x32. (#3245)
|
- ImDrawList: texture baked storage for thick line reduced from ~64x64 to ~32x32. (#3245)
|
||||||
|
- imgui_freetype: fixed issue where glyph advances would incorrectly be
|
||||||
|
snapped to pixels. Effectively it would only be noticeable when hinting
|
||||||
|
is disabled with ImGuiFreeTypeBuilderFlags_NoHinting, as hinting itself
|
||||||
|
snaps glyph advances.
|
||||||
- Examples: DirectX12: Reduced number of frame in flight from 3 to 2 in
|
- Examples: DirectX12: Reduced number of frame in flight from 3 to 2 in
|
||||||
provided example, to reduce latency.
|
provided example, to reduce latency.
|
||||||
- Examples: Vulkan: better handle VK_SUBOPTIMAL_KHR being returned by
|
- Examples: Vulkan: better handle VK_SUBOPTIMAL_KHR being returned by
|
||||||
|
@ -104,6 +104,9 @@ static FT_Error ImGuiLunasvgPortPresetSlot(FT_GlyphSlot slot, FT_Bool cache, FT_
|
|||||||
// Code
|
// Code
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define FT_CEIL(X) (((X + 63) & -64) / 64) // From SDL_ttf: Handy routines for converting from fixed point
|
||||||
|
#define FT_SCALEFACTOR 64.0f
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// Glyph metrics:
|
// Glyph metrics:
|
||||||
@ -182,9 +185,6 @@ namespace
|
|||||||
float InvRasterizationDensity;
|
float InvRasterizationDensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
// From SDL_ttf: Handy routines for converting from fixed point
|
|
||||||
#define FT_CEIL(X) (((X + 63) & -64) / 64)
|
|
||||||
|
|
||||||
bool FreeTypeFont::InitFont(FT_Library ft_library, const ImFontConfig& cfg, unsigned int extra_font_builder_flags)
|
bool FreeTypeFont::InitFont(FT_Library ft_library, const ImFontConfig& cfg, unsigned int extra_font_builder_flags)
|
||||||
{
|
{
|
||||||
FT_Error error = FT_New_Memory_Face(ft_library, (uint8_t*)cfg.FontData, (uint32_t)cfg.FontDataSize, (uint32_t)cfg.FontNo, &Face);
|
FT_Error error = FT_New_Memory_Face(ft_library, (uint8_t*)cfg.FontData, (uint32_t)cfg.FontDataSize, (uint32_t)cfg.FontNo, &Face);
|
||||||
@ -316,7 +316,7 @@ namespace
|
|||||||
out_glyph_info->Height = (int)ft_bitmap->rows;
|
out_glyph_info->Height = (int)ft_bitmap->rows;
|
||||||
out_glyph_info->OffsetX = Face->glyph->bitmap_left;
|
out_glyph_info->OffsetX = Face->glyph->bitmap_left;
|
||||||
out_glyph_info->OffsetY = -Face->glyph->bitmap_top;
|
out_glyph_info->OffsetY = -Face->glyph->bitmap_top;
|
||||||
out_glyph_info->AdvanceX = (float)FT_CEIL(slot->advance.x);
|
out_glyph_info->AdvanceX = (float)slot->advance.x / FT_SCALEFACTOR;
|
||||||
out_glyph_info->IsColored = (ft_bitmap->pixel_mode == FT_PIXEL_MODE_BGRA);
|
out_glyph_info->IsColored = (ft_bitmap->pixel_mode == FT_PIXEL_MODE_BGRA);
|
||||||
|
|
||||||
return ft_bitmap;
|
return ft_bitmap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user