Added IM_UNICODE_CODEPOINT_MAX. Changed specs of ImFontAtlas::AddCustomRectRegular() (breaking change).

This commit is contained in:
omar
2019-10-29 22:50:34 +01:00
parent ca63349eb4
commit 51a02b319c
6 changed files with 37 additions and 27 deletions

View File

@ -1725,7 +1725,8 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
{
IM_ASSERT(id >= 0x10000);
// Breaking change on 2019/11/21 (1.74): ImFontAtlas::AddCustomRectRegular() now requires an ID >= 0x110000 (instead of >= 0x10000)
IM_ASSERT(id >= 0x110000);
IM_ASSERT(width > 0 && width <= 0xFFFF);
IM_ASSERT(height > 0 && height <= 0xFFFF);
ImFontAtlasCustomRect r;
@ -1905,7 +1906,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
dst_tmp.GlyphsSet.Resize(dst_tmp.GlyphsHighest + 1);
for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
for (int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
{
if (dst_tmp.GlyphsSet.GetBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true)
continue;
@ -2189,7 +2190,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
for (int i = 0; i < atlas->CustomRects.Size; i++)
{
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
if (r.Font == NULL || r.ID > 0x10000)
if (r.Font == NULL || r.ID >= 0x110000)
continue;
IM_ASSERT(r.Font->ContainerAtlas == atlas);
@ -2453,7 +2454,7 @@ void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end)
text += c_len;
if (c_len == 0)
break;
if (c < 0x10000)
if (c <= IM_UNICODE_CODEPOINT_MAX)
AddChar((ImWchar)c);
}
}
@ -2467,12 +2468,12 @@ void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
{
int max_codepoint = 0x10000;
for (int n = 0; n < max_codepoint; n++)
const int max_codepoint = IM_UNICODE_CODEPOINT_MAX;
for (int n = 0; n <= max_codepoint; n++)
if (GetBit(n))
{
out_ranges->push_back((ImWchar)n);
while (n < max_codepoint - 1 && GetBit(n + 1))
while (n < max_codepoint && GetBit(n + 1))
n++;
out_ranges->push_back((ImWchar)n);
}
@ -2601,7 +2602,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
{
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
int index_size = IndexLookup.Size;
unsigned int index_size = (unsigned int)IndexLookup.Size;
if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists
return;