1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-19 01:24:20 +00:00

ImStrv: made length() returns an int as it simplify the most common case (of passing %.*s to printf)

This commit is contained in:
ocornut 2024-07-02 18:50:28 +02:00 committed by ocornut
parent 1d18540bf4
commit 23a93afdff
4 changed files with 36 additions and 36 deletions

View file

@ -3203,7 +3203,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(ImStrv filename, float size_pixels, cons
const char* p;
for (p = filename.End; p > filename.Begin && p[-1] != '/' && p[-1] != '\\'; p--) {}
filename.Begin = p;
ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "%.*s", (int)filename.length(), filename.Begin);
ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "%.*s", filename.length(), filename.Begin);
}
return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges);
}
@ -3237,7 +3237,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(ImStrv compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
{
int compressed_ttf_size = (((int)compressed_ttf_data_base85.length() + 4) / 5) * 4;
int compressed_ttf_size = ((compressed_ttf_data_base85.length() + 4) / 5) * 4;
void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size);
Decode85(compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges);