mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_vulkan.cpp # imgui.h
This commit is contained in:
commit
34debc733f
12 changed files with 320 additions and 39 deletions
|
|
@ -4423,7 +4423,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||
if (atlas->Locked || (font->Flags & ImFontFlags_NoLoadGlyphs))
|
||||
{
|
||||
// Lazily load fallback glyph
|
||||
if (baked->FallbackGlyphIndex == -1 && baked->LockLoadingFallback == 0)
|
||||
if (baked->FallbackGlyphIndex == -1 && baked->LoadNoFallback == 0)
|
||||
ImFontAtlasBuildSetupFontBakedFallback(baked);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -4475,7 +4475,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||
}
|
||||
|
||||
// Lazily load fallback glyph
|
||||
if (baked->LockLoadingFallback)
|
||||
if (baked->LoadNoFallback)
|
||||
return NULL;
|
||||
if (baked->FallbackGlyphIndex == -1)
|
||||
ImFontAtlasBuildSetupFontBakedFallback(baked);
|
||||
|
|
@ -4489,7 +4489,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||
|
||||
static float ImFontBaked_BuildLoadGlyphAdvanceX(ImFontBaked* baked, ImWchar codepoint)
|
||||
{
|
||||
if (baked->Size >= IMGUI_FONT_SIZE_THRESHOLD_FOR_LOADADVANCEXONLYMODE)
|
||||
if (baked->Size >= IMGUI_FONT_SIZE_THRESHOLD_FOR_LOADADVANCEXONLYMODE || baked->LoadNoRenderOnLayout)
|
||||
{
|
||||
// First load AdvanceX value used by CalcTextSize() API then load the rest when loaded by drawing API.
|
||||
float only_advance_x = 0.0f;
|
||||
|
|
@ -4685,15 +4685,12 @@ static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontC
|
|||
builder->TempBuffer.resize(w * h * 1);
|
||||
unsigned char* bitmap_pixels = builder->TempBuffer.Data;
|
||||
memset(bitmap_pixels, 0, w * h * 1);
|
||||
stbtt_MakeGlyphBitmapSubpixel(&bd_font_data->FontInfo, bitmap_pixels, r->w - oversample_h + 1, r->h - oversample_v + 1, w,
|
||||
scale_for_raster_x, scale_for_raster_y, 0, 0, glyph_index);
|
||||
|
||||
// Oversampling
|
||||
// Render with oversampling
|
||||
// (those functions conveniently assert if pixels are not cleared, which is another safety layer)
|
||||
if (oversample_h > 1)
|
||||
stbtt__h_prefilter(bitmap_pixels, r->w, r->h, r->w, oversample_h);
|
||||
if (oversample_v > 1)
|
||||
stbtt__v_prefilter(bitmap_pixels, r->w, r->h, r->w, oversample_v);
|
||||
float sub_x, sub_y;
|
||||
stbtt_MakeGlyphBitmapSubpixelPrefilter(&bd_font_data->FontInfo, bitmap_pixels, w, h, w,
|
||||
scale_for_raster_x, scale_for_raster_y, 0, 0, oversample_h, oversample_v, &sub_x, &sub_y, glyph_index);
|
||||
|
||||
const float ref_size = baked->ContainerFont->Sources[0]->SizePixels;
|
||||
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
||||
|
|
@ -4703,8 +4700,8 @@ static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontC
|
|||
font_off_x = IM_ROUND(font_off_x);
|
||||
if (src->PixelSnapV)
|
||||
font_off_y = IM_ROUND(font_off_y);
|
||||
font_off_x += stbtt__oversample_shift(oversample_h);
|
||||
font_off_y += stbtt__oversample_shift(oversample_v) + IM_ROUND(baked->Ascent);
|
||||
font_off_x += sub_x;
|
||||
font_off_y += sub_y + IM_ROUND(baked->Ascent);
|
||||
float recip_h = 1.0f / (oversample_h * rasterizer_density);
|
||||
float recip_v = 1.0f / (oversample_v * rasterizer_density);
|
||||
|
||||
|
|
@ -5231,9 +5228,9 @@ ImFontGlyph* ImFontBaked::FindGlyphNoFallback(ImWchar c)
|
|||
if (i != IM_FONTGLYPH_INDEX_UNUSED)
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
LockLoadingFallback = true; // This is actually a rare call, not done in hot-loop, so we prioritize not adding extra cruft to ImFontBaked_BuildLoadGlyph() call sites.
|
||||
LoadNoFallback = true; // This is actually a rare call, not done in hot-loop, so we prioritize not adding extra cruft to ImFontBaked_BuildLoadGlyph() call sites.
|
||||
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(this, c, NULL);
|
||||
LockLoadingFallback = false;
|
||||
LoadNoFallback = false;
|
||||
return glyph;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue