mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-18 17:11:23 +01:00
Fonts: rename internal fields for consistency.
This commit is contained in:
@@ -824,7 +824,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||
const bool use_texture = (Flags & ImDrawListFlags_AntiAliasedLinesUseTex) && (integer_thickness < IM_DRAWLIST_TEX_LINES_WIDTH_MAX) && (fractional_thickness <= 0.00001f) && (AA_SIZE == 1.0f);
|
||||
|
||||
// We should never hit this, because NewFrame() doesn't set ImDrawListFlags_AntiAliasedLinesUseTex unless ImFontAtlasFlags_NoBakedLines is off
|
||||
IM_ASSERT_PARANOID(!use_texture || !(_Data->Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines));
|
||||
IM_ASSERT_PARANOID(!use_texture || !(_Data->Font->OwnerAtlas->Flags & ImFontAtlasFlags_NoBakedLines));
|
||||
|
||||
const int idx_count = use_texture ? (count * 6) : (thick_line ? count * 18 : count * 12);
|
||||
const int vtx_count = use_texture ? (points_count * 2) : (thick_line ? points_count * 4 : points_count * 3);
|
||||
@@ -3242,7 +3242,7 @@ void ImFontAtlas::RemoveFont(ImFont* font)
|
||||
|
||||
ImFontAtlasBuildUpdatePointers(this);
|
||||
|
||||
font->ContainerAtlas = NULL;
|
||||
font->OwnerAtlas = NULL;
|
||||
IM_DELETE(font);
|
||||
|
||||
// Notify external systems
|
||||
@@ -3620,7 +3620,7 @@ void ImFontAtlasFontSourceAddToFont(ImFontAtlas* atlas, ImFont* font, ImFontConf
|
||||
{
|
||||
font->ClearOutputData();
|
||||
//font->FontSize = src->SizePixels;
|
||||
font->ContainerAtlas = atlas;
|
||||
font->OwnerAtlas = atlas;
|
||||
IM_ASSERT(font->Sources[0] == src);
|
||||
}
|
||||
atlas->TexIsBuilt = false; // For legacy backends
|
||||
@@ -3643,7 +3643,7 @@ void ImFontAtlasFontDestroySourceData(ImFontAtlas* atlas, ImFontConfig* src)
|
||||
// FIXME-NEWATLAS: This borrows too much from FontLoader's FontLoadGlyph() handlers and suggest that we should add further helpers.
|
||||
static ImFontGlyph* ImFontAtlasBuildSetupFontBakedEllipsis(ImFontAtlas* atlas, ImFontBaked* baked)
|
||||
{
|
||||
ImFont* font = baked->ContainerFont;
|
||||
ImFont* font = baked->OwnerFont;
|
||||
IM_ASSERT(font->EllipsisChar != 0);
|
||||
|
||||
const ImFontGlyph* dot_glyph = baked->FindGlyphNoFallback((ImWchar)'.');
|
||||
@@ -3689,7 +3689,7 @@ static void ImFontAtlasBuildSetupFontBakedFallback(ImFontBaked* baked)
|
||||
{
|
||||
IM_ASSERT(baked->FallbackGlyphIndex == -1);
|
||||
IM_ASSERT(baked->FallbackAdvanceX == 0.0f);
|
||||
ImFont* font = baked->ContainerFont;
|
||||
ImFont* font = baked->OwnerFont;
|
||||
ImFontGlyph* fallback_glyph = NULL;
|
||||
if (font->FallbackChar != 0)
|
||||
fallback_glyph = baked->FindGlyphNoFallback(font->FallbackChar);
|
||||
@@ -3699,7 +3699,7 @@ static void ImFontAtlasBuildSetupFontBakedFallback(ImFontBaked* baked)
|
||||
ImFontGlyph glyph;
|
||||
glyph.Codepoint = 0;
|
||||
glyph.AdvanceX = space_glyph ? space_glyph->AdvanceX : IM_ROUND(baked->Size * 0.40f);
|
||||
fallback_glyph = ImFontAtlasBakedAddFontGlyph(font->ContainerAtlas, baked, NULL, &glyph);
|
||||
fallback_glyph = ImFontAtlasBakedAddFontGlyph(font->OwnerAtlas, baked, NULL, &glyph);
|
||||
}
|
||||
baked->FallbackGlyphIndex = baked->Glyphs.index_from_ptr(fallback_glyph); // Storing index avoid need to update pointer on growth and simplify inner loop code
|
||||
baked->FallbackAdvanceX = fallback_glyph->AdvanceX;
|
||||
@@ -3780,7 +3780,7 @@ ImFontBaked* ImFontAtlasBakedAdd(ImFontAtlas* atlas, ImFont* font, float font_si
|
||||
baked->Size = font_size;
|
||||
baked->RasterizerDensity = font_rasterizer_density;
|
||||
baked->BakedId = baked_id;
|
||||
baked->ContainerFont = font;
|
||||
baked->OwnerFont = font;
|
||||
baked->LastUsedFrame = atlas->Builder->FrameCount;
|
||||
|
||||
// Initialize backend data
|
||||
@@ -3815,7 +3815,7 @@ ImFontBaked* ImFontAtlasBakedGetClosestMatch(ImFontAtlas* atlas, ImFont* font, f
|
||||
for (int baked_n = 0; baked_n < builder->BakedPool.Size; baked_n++)
|
||||
{
|
||||
ImFontBaked* baked = &builder->BakedPool[baked_n];
|
||||
if (baked->ContainerFont != font || baked->WantDestroy)
|
||||
if (baked->OwnerFont != font || baked->WantDestroy)
|
||||
continue;
|
||||
if (step_n == 0 && baked->RasterizerDensity != font_rasterizer_density) // First try with same density
|
||||
continue;
|
||||
@@ -3871,7 +3871,7 @@ void ImFontAtlasFontDiscardBakes(ImFontAtlas* atlas, ImFont* font, int unused_fr
|
||||
ImFontBaked* baked = &builder->BakedPool[baked_n];
|
||||
if (baked->LastUsedFrame + unused_frames > atlas->Builder->FrameCount)
|
||||
continue;
|
||||
if (baked->ContainerFont != font || baked->WantDestroy)
|
||||
if (baked->OwnerFont != font || baked->WantDestroy)
|
||||
continue;
|
||||
ImFontAtlasBakedDiscard(atlas, font, baked);
|
||||
}
|
||||
@@ -3886,9 +3886,9 @@ void ImFontAtlasBuildDiscardBakes(ImFontAtlas* atlas, int unused_frames)
|
||||
ImFontBaked* baked = &builder->BakedPool[baked_n];
|
||||
if (baked->LastUsedFrame + unused_frames > atlas->Builder->FrameCount)
|
||||
continue;
|
||||
if (baked->WantDestroy || (baked->ContainerFont->Flags & ImFontFlags_LockBakedSizes))
|
||||
if (baked->WantDestroy || (baked->OwnerFont->Flags & ImFontFlags_LockBakedSizes))
|
||||
continue;
|
||||
ImFontAtlasBakedDiscard(atlas, baked->ContainerFont, baked);
|
||||
ImFontAtlasBakedDiscard(atlas, baked->OwnerFont, baked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4421,8 +4421,8 @@ static void ImFontAtlas_FontHookRemapCodepoint(ImFontAtlas* atlas, ImFont* font,
|
||||
|
||||
static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codepoint, float* only_load_advance_x)
|
||||
{
|
||||
ImFont* font = baked->ContainerFont;
|
||||
ImFontAtlas* atlas = font->ContainerAtlas;
|
||||
ImFont* font = baked->OwnerFont;
|
||||
ImFontAtlas* atlas = font->OwnerAtlas;
|
||||
if (atlas->Locked || (font->Flags & ImFontFlags_NoLoadGlyphs))
|
||||
{
|
||||
// Lazily load fallback glyph
|
||||
@@ -4696,7 +4696,7 @@ static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontC
|
||||
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 ref_size = baked->OwnerFont->Sources[0]->SizePixels;
|
||||
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
||||
float font_off_x = (src->GlyphOffset.x * offsets_scale);
|
||||
float font_off_y = (src->GlyphOffset.y * offsets_scale);
|
||||
@@ -5093,7 +5093,7 @@ ImFont::~ImFont()
|
||||
|
||||
void ImFont::ClearOutputData()
|
||||
{
|
||||
if (ImFontAtlas* atlas = ContainerAtlas)
|
||||
if (ImFontAtlas* atlas = OwnerAtlas)
|
||||
ImFontAtlasFontDiscardBakes(atlas, this, 0);
|
||||
FallbackChar = EllipsisChar = 0;
|
||||
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
|
||||
@@ -5138,7 +5138,7 @@ ImFontGlyph* ImFontAtlasBakedAddFontGlyph(ImFontAtlas* atlas, ImFontBaked* baked
|
||||
if (src != NULL)
|
||||
{
|
||||
// Clamp & recenter if needed
|
||||
const float ref_size = baked->ContainerFont->Sources[0]->SizePixels;
|
||||
const float ref_size = baked->OwnerFont->Sources[0]->SizePixels;
|
||||
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
||||
float advance_x = ImClamp(glyph->AdvanceX, src->GlyphMinAdvanceX * offsets_scale, src->GlyphMaxAdvanceX * offsets_scale);
|
||||
if (advance_x != glyph->AdvanceX)
|
||||
@@ -5164,7 +5164,7 @@ ImFontGlyph* ImFontAtlasBakedAddFontGlyph(ImFontAtlas* atlas, ImFontBaked* baked
|
||||
baked->IndexAdvanceX[codepoint] = glyph->AdvanceX;
|
||||
baked->IndexLookup[codepoint] = (ImU16)glyph_idx;
|
||||
const int page_n = codepoint / 8192;
|
||||
baked->ContainerFont->Used8kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
|
||||
baked->OwnerFont->Used8kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
|
||||
|
||||
return glyph;
|
||||
}
|
||||
@@ -5176,7 +5176,7 @@ void ImFontAtlasBakedAddFontGlyphAdvancedX(ImFontAtlas* atlas, ImFontBaked* bake
|
||||
if (src != NULL)
|
||||
{
|
||||
// Clamp & recenter if needed
|
||||
const float ref_size = baked->ContainerFont->Sources[0]->SizePixels;
|
||||
const float ref_size = baked->OwnerFont->Sources[0]->SizePixels;
|
||||
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
||||
advance_x = ImClamp(advance_x, src->GlyphMinAdvanceX * offsets_scale, src->GlyphMaxAdvanceX * offsets_scale);
|
||||
|
||||
@@ -5198,7 +5198,7 @@ void ImFontAtlasBakedSetFontGlyphBitmap(ImFontAtlas* atlas, ImFontBaked* baked,
|
||||
ImTextureData* tex = atlas->TexData;
|
||||
IM_ASSERT(r->x + r->w <= tex->Width && r->y + r->h <= tex->Height);
|
||||
ImFontAtlasTextureBlockConvert(src_pixels, src_fmt, src_pitch, (unsigned char*)tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h);
|
||||
ImFontAtlasPostProcessData pp_data = { atlas, baked->ContainerFont, src, baked, glyph, tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h };
|
||||
ImFontAtlasPostProcessData pp_data = { atlas, baked->OwnerFont, src, baked, glyph, tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h };
|
||||
ImFontAtlasTextureBlockPostProcess(&pp_data);
|
||||
ImFontAtlasTextureBlockQueueUpload(atlas, tex, r->x, r->y, r->w, r->h);
|
||||
}
|
||||
@@ -5256,7 +5256,7 @@ bool ImFontBaked::IsGlyphLoaded(ImWchar c)
|
||||
// This is not fast query
|
||||
bool ImFont::IsGlyphInFont(ImWchar c)
|
||||
{
|
||||
ImFontAtlas* atlas = ContainerAtlas;
|
||||
ImFontAtlas* atlas = OwnerAtlas;
|
||||
ImFontAtlas_FontHookRemapCodepoint(atlas, this, &c);
|
||||
for (ImFontConfig* src : Sources)
|
||||
{
|
||||
@@ -5305,7 +5305,7 @@ ImFontBaked* ImFont::GetFontBaked(float size, float density)
|
||||
if (baked && baked->Size == size && baked->RasterizerDensity == density)
|
||||
return baked;
|
||||
|
||||
ImFontAtlas* atlas = ContainerAtlas;
|
||||
ImFontAtlas* atlas = OwnerAtlas;
|
||||
ImFontAtlasBuilder* builder = atlas->Builder;
|
||||
baked = ImFontAtlasBakedGetOrAdd(atlas, this, size, density);
|
||||
if (baked == NULL)
|
||||
@@ -5326,7 +5326,7 @@ ImFontBaked* ImFontAtlasBakedGetOrAdd(ImFontAtlas* atlas, ImFont* font, float fo
|
||||
ImFontBaked* baked = *p_baked_in_map;
|
||||
if (baked != NULL)
|
||||
{
|
||||
IM_ASSERT(baked->Size == font_size && baked->ContainerFont == font && baked->BakedId == baked_id);
|
||||
IM_ASSERT(baked->Size == font_size && baked->OwnerFont == font && baked->BakedId == baked_id);
|
||||
return baked;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user