diff --git a/build/ImGui.linemap.json b/build/ImGui.linemap.json index bdc1109..4fb7453 100644 --- a/build/ImGui.linemap.json +++ b/build/ImGui.linemap.json @@ -1 +1 @@ -[[46, "imgui.lua"], [21466, "imgui_demo.lua"], [33318, "imgui_draw.lua"], [41121, "imgui_h.lua"], [44027, "imgui_impl_roblox.lua"], [45675, "imgui_impl_roblox_fonts.lua"], [52078, "imgui_internal.lua"], [55800, "imgui_tables.lua"], [60859, "imgui_widgets.lua"], [72835, "imstb_rectpack.lua"], [73499, "imstb_textedit.lua"], [75041, "imstb_truetype.lua"], [77829, "imstd_minstdio.lua"]] \ No newline at end of file +[[46, "imgui.lua"], [21466, "imgui_demo.lua"], [33318, "imgui_draw.lua"], [41521, "imgui_h.lua"], [44455, "imgui_impl_roblox.lua"], [46103, "imgui_impl_roblox_fonts.lua"], [52506, "imgui_internal.lua"], [56228, "imgui_tables.lua"], [61287, "imgui_widgets.lua"], [73263, "imstb_rectpack.lua"], [73927, "imstb_textedit.lua"], [75469, "imstb_truetype.lua"], [78257, "imstd_minstdio.lua"]] \ No newline at end of file diff --git a/build/ImGui.luau b/build/ImGui.luau index 6ed1f5a..f3b2abd 100644 --- a/build/ImGui.luau +++ b/build/ImGui.luau @@ -1,7 +1,7 @@ --!optimize 2 -- GENERATED by tools/bundle.py from *.lua, backends/, fonts/ - do not edit -local ImGui, ImVec2, ImVec4, ImRect, HelpMarker, ImVec2_Copy, IMGUI_DEMO_MARKER, ImGuiTableFlags, ImStd, ImVector, ImDrawFlags, ImGuiInputFlags, ImRect_Copy, ImGuiDataType, ImStb, IM_TRUNC, ImGuiKey, ImVec2_CopyV, ImGuiStyleVarInfo, IM_ASSERT_USER_ERROR, ImGuiHoveredFlags, ImFormatString, IM_ASSERT_USER_ERROR_RET, ImHashStr, ImS32, ImGuiColorEditFlags, ImIsPowerOfTwo, ImAbs, ImVec4_Copy, ExampleAppConsoleMT, IM_ROUND, ImGuiTableColumnFlags, ImGuiTreeNodeFlags, PopStyleCompact, PushStyleCompact, IM_ASSERT_PARANOID, ImU16, ExampleNames, ImGuiWindowFlags, ImGuiItemFlags, ImGui_ImplRoblox_GetBackendData, stbte, ImColor, ImCos, ImGuiButtonFlags, ImGuiDebugLogFlags, ImGuiLocKey, ImU32, ExampleTreeFuncs, ImGuiListClipper, ImS16, _PathArcToFastExXY, ImGuiMultiSelectFlags, ImSin, ImGuiTabBarFlags, ImUpperPowerOfTwo, IM_F32_TO_INT8_SAT, ImFontAtlasPackGetRect, DockSettingsRenameNodeReferences, ExampleDualListBoxMT, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImCeil, ImFabs, ImGuiCol, ImGuiSelectionBasicStorage, ImLengthSqr, ImS8, ImU8, ExampleAppPropertyEditorMT, ImGuiChildFlags, ImGuiLastItemData_Copy, ImGuiScrollFlags, ImLog, ImMemchr, ImStrByte, ExampleSelectionWithDeletionMT, IMGUI_DEBUG_LOG_VIEWPORT, ImGuiInputEvent, ImGuiTextBuffer, ImPow, ImTrunc64, CustomConstraints, ExampleAppLogMT, IMGUI_DEBUG_LOG_FONT, IMGUI_DEBUG_LOG_SELECTION, ImAddClampOverflow, ImFontAtlasBuildInit, ImFontCalcWordWrapPositionEx, ImGuiComboFlags, ImGuiLastItemData, ImGuiPayload_IsDataType, ImGuiPopupFlags, ImGuiSliderFlags, ImGuiTextFilter, ImRotate, ImSqrt, ImSubClampOverflow, ImTextClassifierSetCharClass, MyDocument, ShowExampleMenuFile, CalcCornerArcStepAndCount, CalcNextScrollFromScrollTargetAndClamp, IMGUI_PAYLOAD_TYPE_WINDOW, IMGUI_VERSION, ImCharIsBlankW, ImCharIsSeparatorW, ImFmod, ImFontAtlasBakedAddFontGlyph, ImFontAtlasPackAddRect, ImFontBaked_BuildLoadGlyph, ImGuiInputTextFlags, ImGuiNavMoveFlags, ImGuiStyle_Copy, ImHashData, ImVec1_Copy, ExampleAsset_s_current_sort_specs, ExampleMemberInfo, ExampleTree_CreateNode, IMGUI_PAYLOAD_TYPE_COLOR_4F, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC, IM_F32_TO_INT8_UNBOUND, IM_PI, ImCharIsBlankA, ImFontAtlasBuildRenderBitmapFromString, ImFontAtlasFontDestroyOutput, ImFontAtlasFontDiscardBakes, ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit, ImFontAtlasRectId_GetIndex, ImFontAtlasTextureAdd, ImFontAtlasTextureBlockQueueUpload, ImFontAtlasTextureGrow, ImFontBaked_BuildGrowIndex, ImFontConfig, ImFontGlyph, ImGuiTableColumn, ImGuiWindowClass, ImGui_ImplRoblox_RenderDrawData, ImParseFormatFindStart, ImRect_CopyFromV4, ImTextureRect, ImTextureRef, MyItem_s_current_sort_specs, stb_textedit_key, stbtt_GetGlyphBitmapBoxSubpixel, DockSettingsHandler_ClearAll, EditTableSizingFlags, ExampleSelectionWithDeletion, IMGUI_DEBUG_LOG_TABLE, IMGUI_PAYLOAD_TYPE_COLOR_3F, IM_FREE, ImDrawListSplitter, ImFontAtlasBakedDiscard, ImFontAtlasBuildDestroy, ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildSetTexture, ImFontAtlasBuildSetupFontBakedFallback, ImFontAtlasFontDestroySourceData, ImFontAtlasPackInit, ImFontAtlasRect +local ImGui, ImVec2, ImVec4, ImRect, HelpMarker, ImVec2_Copy, IMGUI_DEMO_MARKER, ImGuiTableFlags, ImStd, ImVector, ImDrawFlags, ImGuiInputFlags, ImRect_Copy, ImGuiDataType, ImStb, IM_TRUNC, ImGuiKey, ImVec2_CopyV, ImGuiStyleVarInfo, IM_ASSERT_USER_ERROR, ImGuiHoveredFlags, ImFormatString, IM_ASSERT_USER_ERROR_RET, ImHashStr, ImS32, ImGuiColorEditFlags, ImIsPowerOfTwo, ImAbs, ImVec4_Copy, ExampleAppConsoleMT, IM_ROUND, ImGuiTableColumnFlags, ImGuiTreeNodeFlags, PopStyleCompact, PushStyleCompact, IM_ASSERT_PARANOID, ImU16, ExampleNames, ImGuiWindowFlags, ImGuiItemFlags, ImGui_ImplRoblox_GetBackendData, stbte, ImColor, ImCos, ImGuiButtonFlags, ImGuiDebugLogFlags, ImGuiLocKey, ImU32, ExampleTreeFuncs, ImGuiListClipper, ImS16, _PathArcToFastExXY, ImGuiMultiSelectFlags, ImSin, ImGuiTabBarFlags, ImUpperPowerOfTwo, IM_F32_TO_INT8_SAT, ImFontAtlasPackGetRect, DockSettingsRenameNodeReferences, ExampleDualListBoxMT, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImCeil, ImFabs, ImGuiCol, ImGuiSelectionBasicStorage, ImLengthSqr, ImS8, ImU8, ExampleAppPropertyEditorMT, ImGuiChildFlags, ImGuiLastItemData_Copy, ImGuiScrollFlags, ImLog, ImMemchr, ImStrByte, ExampleSelectionWithDeletionMT, IMGUI_DEBUG_LOG_VIEWPORT, ImFontCalcWordWrapPositionEx, ImGuiInputEvent, ImGuiTextBuffer, ImPow, ImTrunc64, CustomConstraints, ExampleAppLogMT, IMGUI_DEBUG_LOG_FONT, IMGUI_DEBUG_LOG_SELECTION, ImAddClampOverflow, ImFontAtlasBuildInit, ImFontAtlasFontDestroyOutput, ImGuiComboFlags, ImGuiLastItemData, ImGuiPayload_IsDataType, ImGuiPopupFlags, ImGuiSliderFlags, ImGuiTextFilter, ImRotate, ImSqrt, ImSubClampOverflow, ImTextClassifierSetCharClass, MyDocument, ShowExampleMenuFile, CalcCornerArcStepAndCount, CalcNextScrollFromScrollTargetAndClamp, IMGUI_PAYLOAD_TYPE_WINDOW, IMGUI_VERSION, ImCharIsBlankW, ImCharIsSeparatorW, ImFmod, ImFontAtlasBakedAddFontGlyph, ImFontAtlasPackAddRect, ImFontBaked_BuildLoadGlyph, ImFontConfig, ImGuiInputTextFlags, ImGuiNavMoveFlags, ImGuiStyle_Copy, ImHashData, ImVec1_Copy, ExampleAsset_s_current_sort_specs, ExampleMemberInfo, ExampleTree_CreateNode, IMGUI_PAYLOAD_TYPE_COLOR_4F, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC, IM_F32_TO_INT8_UNBOUND, IM_PI, ImCharIsBlankA, ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildRenderBitmapFromString, ImFontAtlasFontDestroySourceData, ImFontAtlasFontDiscardBakes, ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit, ImFontAtlasRectId_GetIndex, ImFontAtlasTextureAdd, ImFontAtlasTextureBlockQueueUpload, ImFontAtlasTextureGrow, ImFontBaked_BuildGrowIndex, ImFontGlyph, ImGuiTableColumn, ImGuiWindowClass, ImGui_ImplRoblox_RenderDrawData, ImParseFormatFindStart, ImRect_CopyFromV4, ImTextureRect, ImTextureRef, MyItem_s_current_sort_specs, stb_textedit_key, stbtt_GetGlyphBitmapBoxSubpixel, DockSettingsHandler_ClearAll, EditTableSizingFlags, ExampleSelectionWithDeletion, IMGUI_DEBUG_LOG_TABLE, IMGUI_PAYLOAD_TYPE_COLOR_3F, IM_FREE, ImDrawListSplitter, ImFontAtlasBakedDiscard, ImFontAtlasBuildDestroy, ImFontAtlasBuildSetTexture, ImFontAtlasBuildSetupFontBakedFallback, ImFontAtlasPackDiscardRect, ImFontAtlasPackGetRectSafe local type, mathMin, mathMax, mathFloor, mathCeil, bitOr, bitLShift = type, math.min, math.max, math.floor, math.ceil, bit32.bor, bit32.lshift local function IM_COL32(R, G, B, A) return (bitOr(bitLShift(A, 24 --[[IM_COL32_A_SHIFT]]), bitLShift(B, 16 --[[IM_COL32_B_SHIFT]]), bitLShift(G, 8 --[[IM_COL32_G_SHIFT]]), bitLShift(R, 0 --[[IM_COL32_R_SHIFT]]))) end @native @@ -34205,6 +34205,28 @@ function ImFontAtlasTextureBlockCopy(src_tex, src_x, src_y, dst_tex, dst_x, dst_ end end +--- @param dst_tex ImTextureData +--- @param col ImU32 +function ImFontAtlasTextureBlockFill(dst_tex, dst_x, dst_y, w, h, col) + if dst_tex.Format == 1 --[[ImTextureFormat.Alpha8]] then + local col_a = bit32.band(bit32.rshift(col, 24 --[[IM_COL32_A_SHIFT]]), 0xFF) + for y = 0, h - 1 do + local p, base = dst_tex:GetPixelsAt(dst_x, dst_y + y) + for i = base, base + w - 1 do p[i] = col_a end + end + else + -- [Luau] Pixels is a byte table: write the 4 bytes of the little-endian ImU32 + local c0, c1, c2, c3 = bit32.band(col, 0xFF), bit32.band(bit32.rshift(col, 8), 0xFF), bit32.band(bit32.rshift(col, 16), 0xFF), bit32.band(bit32.rshift(col, 24), 0xFF) + for y = 0, h - 1 do + local p, i = dst_tex:GetPixelsAt(dst_x, dst_y + y) + for _ = w, 1, -1 do + p[i] = c0; p[i + 1] = c1; p[i + 2] = c2; p[i + 3] = c3 + i = i + 4 + end + end + end +end + -- Queue texture block update for renderer backend --- @param tex ImTextureData --- @param x int @@ -34859,6 +34881,18 @@ function ImFontAtlasBuildSetupFontBakedBlanks(atlas, baked) end end +--- @param glyph ImFontGlyph +function ImFontAtlasBakedDiscardFontGlyph(atlas, font, baked, glyph) + if glyph.PackId ~= (-1) --[[ImFontAtlasRectId_Invalid]] then + ImFontAtlasPackDiscardRect(atlas, glyph.PackId) + glyph.PackId = (-1) --[[ImFontAtlasRectId_Invalid]] + end + local c = glyph.Codepoint + assert(font.FallbackChar ~= c and font.EllipsisChar ~= c) -- Unsupported for simplicity + baked.IndexLookup.Data[c + 1] = IM_FONTGLYPH_INDEX_UNUSED + baked.IndexAdvanceX.Data[c + 1] = baked.FallbackAdvanceX +end + --- @param atlas ImFontAtlas --- @param font ImFont --- @param font_size float @@ -35017,6 +35051,11 @@ function ImFontAtlasFontDestroyOutput(atlas, font) end end +function ImFontAtlasFontRebuildOutput(atlas, font) + ImFontAtlasFontDestroyOutput(atlas, font) + ImFontAtlasFontInitOutput(atlas, font) +end + --- @param atlas ImFontAtlas --- @param src ImFontConfig --- @return boolean @@ -35903,6 +35942,32 @@ function ImFontAtlasBuildMain(atlas) atlas.TexIsBuilt = true end +-- [Luau] Ported but its call above stays disabled: the Roblox/LÖVE backends support RendererHasTextures. +function ImFontAtlasBuildLegacyPreloadAllGlyphRanges(atlas) + atlas.Builder.PreloadedAllGlyphsRanges = true + for _, font in atlas.Fonts:iter() do + local baked = font:GetFontBaked(font.LegacySize) + if font.FallbackChar ~= 0 then + baked:FindGlyph(font.FallbackChar) + end + if font.EllipsisChar ~= 0 then + baked:FindGlyph(font.EllipsisChar) + end + for _, src in font.Sources:iter() do + local ranges = src.GlyphRanges and src.GlyphRanges or atlas:GetGlyphRangesDefault() + local i = 1 + while ranges[i] ~= 0 do + local c = ranges[i] + while c <= ranges[i + 1] and c <= 65535 --[[IM_UNICODE_CODEPOINT_MAX]] do + baked:FindGlyph(c) + c = c + 1 + end + i = i + 2 + end + end + end +end + ------------------------------------------------------------------------------- -- [SECTION] ImTextureData ------------------------------------------------------------------------------- @@ -35910,6 +35975,25 @@ end -- - ImTextureData:DestroyPixels() ------------------------------------------------------------------------------- +--- @param status ImTextureStatus +function ImTextureDataGetStatusName(status) + if status == 0 --[[ImTextureStatus.OK]] then return "OK" + elseif status == 1 --[[ImTextureStatus.Destroyed]] then return "Destroyed" + elseif status == 2 --[[ImTextureStatus.WantCreate]] then return "WantCreate" + elseif status == 3 --[[ImTextureStatus.WantUpdates]] then return "WantUpdates" + elseif status == 4 --[[ImTextureStatus.WantDestroy]] then return "WantDestroy" + end + return "N/A" +end + +--- @param format ImTextureFormat +function ImTextureDataGetFormatName(format) + if format == 1 --[[ImTextureFormat.Alpha8]] then return "Alpha8" + elseif format == 0 --[[ImTextureFormat.RGBA32]] then return "RGBA32" + end + return "N/A" +end + function MT.ImTextureData:DestroyPixels() self.Pixels = nil self.UseColors = false @@ -35946,6 +36030,74 @@ function MT.ImTextureData:Create(format, w, h) self.UpdateRect.h = 0 end +------------------------------------------------------------------------------- +-- [SECTION] ImFontAtlas: glyph ranges helpers +------------------------------------------------------------------------------- +-- - GetGlyphRangesDefault() +-- [Luau] The obsolete GetGlyphRangesXXX() (IMGUI_DISABLE_OBSOLETE_FUNCTIONS) are not ported. +------------------------------------------------------------------------------- + +-- Retrieve list of range (2 int per range, values are inclusive) +local GlyphRangesDefault = +{ + 0x0020, 0x00FF, -- Basic Latin + Latin Supplement + 0, +} +function MT.ImFontAtlas:GetGlyphRangesDefault() + return GlyphRangesDefault +end + +------------------------------------------------------------------------------- +-- [SECTION] ImFontGlyphRangesBuilder +------------------------------------------------------------------------------- + +--- @param text ImString +--- @param text_end? int # exclusive, 1-based +function MT.ImFontGlyphRangesBuilder:AddText(text, text_end) + if text_end == nil then + text_end = #text + 1 + end + local s = 1 + while s < text_end do + local c_len, c = ImStd.ImTextCharFromUtf8(text, s, text_end) + s = s + c_len + if c_len == 0 then + break + end + self:AddChar(c) + end +end + +--- @param ranges ImWchar[] # 1-based, zero-terminated +function MT.ImFontGlyphRangesBuilder:AddRanges(ranges) + local i = 1 + while ranges[i] ~= 0 do + local c = ranges[i] + while c <= ranges[i + 1] and c <= 65535 --[[IM_UNICODE_CODEPOINT_MAX]] do + self:AddChar(c) + c = c + 1 + end + i = i + 2 + end +end + +--- @param out_ranges ImVector +function MT.ImFontGlyphRangesBuilder:BuildRanges(out_ranges) + local max_codepoint = 65535 --[[IM_UNICODE_CODEPOINT_MAX]] + local n = 0 + while n <= max_codepoint do + if self:GetBit(n) then + out_ranges:push_back(n) + while n < max_codepoint and self:GetBit(n + 1) do + n = n + 1 + end + out_ranges:push_back(n) + end + n = n + 1 + end + out_ranges:push_back(0) +end + ------------------------------------------------------------------------------- -- [SECTION] ImFontBaked, ImFont ------------------------------------------------------------------------------- @@ -36015,6 +36167,21 @@ function MT.ImFont:ClearOutputData() self.LastBaked = nil end +-- API is designed this way to avoid exposing the 8K page size +-- e.g. use with IsGlyphRangeUnused(0, 255) +function MT.ImFont:IsGlyphRangeUnused(c_begin, c_last) + local page_begin = math.floor(c_begin / 8192) + local page_last = math.floor(c_last / 8192) + for page_n = page_begin, page_last do + if bit32.rshift(page_n, 3) < (65535 --[[IM_UNICODE_CODEPOINT_MAX]] + 1) / 8192 / 8 then -- sizeof(Used8kPagesMap) + if bit32.band(self.Used8kPagesMap[bit32.rshift(page_n, 3) + 1] or 0, bit32.lshift(1, bit32.band(page_n, 7))) ~= 0 then + return false + end + end + end + return true +end + --- @param font_id ImGuiID --- @param baked_size float --- @param rasterizer_density float @@ -36182,6 +36349,14 @@ function MT.ImFont:GetFontBaked(size, density) return baked end +-- Makes 'from_codepoint' character points to 'to_codepoint' glyph. +-- [Luau] AddRemapCodepointToGlyphIndex() not ported: needs the 1.93 loader split (FontSrcGetGlyphIndexFromCodepoint). +function MT.ImFont:AddRemapCodepoint(from_codepoint, to_codepoint) + local data = to_codepoint + assert(bit32.band(data, bit32.lshift(1, 31)) == 0) + self.RemapPairs[from_codepoint] = data +end + --- @param atlas ImFontAtlas --- @param font ImFont --- @param c ImWchar @@ -36189,7 +36364,7 @@ end --- @nodiscard local function ImFontAtlas_FontHookRemapCodepoint(atlas, font, c) -- IM_UNUSED(atlas) - if #font.RemapPairs > 0 then + if next(font.RemapPairs) ~= nil then -- [Luau] font->RemapPairs.Data.Size != 0 (RemapPairs is a hash table) local ret = font.RemapPairs[c] return (ret ~= nil) and ret or c end @@ -36584,6 +36759,16 @@ function ImFontCalcWordWrapPositionEx_Uncached(baked, size, text, pos, text_end, return s end +--- @param size float +--- @param text ImString +--- @param pos int # [Luau] 1-based start position (C++ 'text' pointer) +--- @param text_end int # exclusive +--- @param wrap_width float +--- @return int +function MT.ImFont:CalcWordWrapPosition(size, text, pos, text_end, wrap_width) + return ImFontCalcWordWrapPositionEx(self, size, text, pos, text_end, wrap_width, 0 --[[ImDrawTextFlags.None]]) +end + --- @param font ImFont --- @param size float --- @param max_width float @@ -36911,6 +37096,25 @@ function MT.ImFontAtlas:AddFont(font_cfg_in) return font end +-- Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder) +local stb_decompress_length +local stb_decompress +local function Decode85Byte(c) return (c >= 92) and (c - 36) or (c - 35) end -- c >= '\\' +--- @param src string +--- @param dst buffer +local function Decode85(src, dst) + local d = 0 + local src_len = #src + local s = 1 + while s + 4 <= src_len do -- [Luau] while (*src): stop at the last complete 5-char group + local b0, b1, b2, b3, b4 = string.byte(src, s, s + 4) + local tmp = (Decode85Byte(b0) + 85 * (Decode85Byte(b1) + 85 * (Decode85Byte(b2) + 85 * (Decode85Byte(b3) + 85 * Decode85Byte(b4))))) % 4294967296 + buffer.writeu8(dst, d + 0, tmp % 256); buffer.writeu8(dst, d + 1, math.floor(tmp / 256) % 256); buffer.writeu8(dst, d + 2, math.floor(tmp / 65536) % 256); buffer.writeu8(dst, d + 3, math.floor(tmp / 16777216) % 256) -- We can't assume little-endianness. + s = s + 5 + d = d + 4 + end +end + -- This duplicates some of the logic in UpdateFontsNewFrame() which is a bit chicken-and-eggy/tricky to extract due to variety of codepaths and possible initialization ordering. --- @param ctx ImGuiContext --- @return float @@ -36944,9 +37148,68 @@ function MT.ImFontAtlas:AddFontFromMemoryTTF(font_data, font_data_size, size_pix return self:AddFont(font_cfg) end --- TODO: GetDefaultCompressedFontDataProggyClean, GetDefaultCompressedFontDataProggyForever -function MT.ImFontAtlas:AddFontFromMemoryCompressedTTF() - -- TODO: +--- @param compressed_ttf_data buffer|string|ImU8[] # [Luau] stb_compress() output: buffer, string or 1-based byte table +--- @param compressed_ttf_size int +function MT.ImFontAtlas:AddFontFromMemoryCompressedTTF(compressed_ttf_data, compressed_ttf_size, size_pixels, font_cfg_template, glyph_ranges) + -- [Luau] normalize input to a buffer + if type(compressed_ttf_data) == "string" then + compressed_ttf_data = buffer.fromstring(compressed_ttf_data) + elseif type(compressed_ttf_data) == "table" then + local b = buffer.create(compressed_ttf_size) + for n = 1, compressed_ttf_size do buffer.writeu8(b, n - 1, compressed_ttf_data[n]) end + compressed_ttf_data = b + end + local buf_decompressed_size = stb_decompress_length(compressed_ttf_data) + local buf_decompressed_data = buffer.create(buf_decompressed_size) + stb_decompress(buf_decompressed_data, compressed_ttf_data, compressed_ttf_size) + + -- [Luau] FontData is a 1-based byte table (see stbtt / ImFileLoadToMemory) + local ttf_data = table.create and table.create(buf_decompressed_size) or {} + for n = 1, buf_decompressed_size do ttf_data[n] = buffer.readu8(buf_decompressed_data, n - 1) end + + local font_cfg = font_cfg_template and font_cfg_template or ImFontConfig() + assert(font_cfg.FontData == nil) + font_cfg.FontDataOwnedByAtlas = true + return self:AddFontFromMemoryTTF(ttf_data, buf_decompressed_size, size_pixels or 0.0, font_cfg, glyph_ranges) +end + +--- @param compressed_ttf_data_base85 string +function MT.ImFontAtlas:AddFontFromMemoryCompressedBase85TTF(compressed_ttf_data_base85, size_pixels, font_cfg, glyph_ranges) + local compressed_ttf_size = math.floor((#compressed_ttf_data_base85 + 4) / 5) * 4 + local compressed_ttf = buffer.create(compressed_ttf_size) + Decode85(compressed_ttf_data_base85, compressed_ttf) + local font = self:AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges) + return font +end + +--- @param font ImFont +function MT.ImFontAtlas:RemoveFont(font) + assert(not self.Locked, "Cannot modify a locked ImFontAtlas!") + + ImFontAtlasFontDestroyOutput(self, font) + for _, src in font.Sources:iter() do + ImFontAtlasFontDestroySourceData(self, src) + end + local src_n = 1 + while src_n <= self.Sources.Size do + if self.Sources.Data[src_n].DstFont == font then + self.Sources:erase(src_n) + else + src_n = src_n + 1 + end + end + + local removed = self.Fonts:find_erase(font) + assert(removed) + + ImFontAtlasBuildUpdatePointers(self) + + font.OwnerAtlas = nil + + -- Notify external systems + local new_current_font = nil + if self.Fonts.Size > 0 then new_current_font = self.Fonts.Data[1] end + ImFontAtlasBuildNotifySetFont(self, font, new_current_font) end function MT.ImFontAtlas:AddFontFromFileTTF(filename, size_pixels, font_cfg_template, glyph_ranges) @@ -37102,6 +37365,13 @@ function MT.ImFontAtlas:AddCustomRect(width, height, out_r) return r_id end +function MT.ImFontAtlas:RemoveCustomRect(id) + if ImFontAtlasPackGetRectSafe(self, id) == nil then + return + end + ImFontAtlasPackDiscardRect(self, id) +end + local function IM_NORMALIZE2F_OVER_ZERO(VX, VY) local d2 = VX * VX + VY * VY if d2 > 0.0 then @@ -41114,6 +41384,136 @@ function MT.ImDrawList:PathFillConcave(col) self._Path.Size = 0 end +------------------------------------------------------------------------------- +-- [SECTION] Decompression code +------------------------------------------------------------------------------- +-- Compressed with stb_compress() then converted to a C array and encoded as base85. +-- Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file. +-- The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. +-- Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h +-- [Luau] Input and output are buffers, pointers are 0-based byte offsets into them. +------------------------------------------------------------------------------- + +do +local readu8 = buffer.readu8 +local writeu8 = buffer.writeu8 + +--- @param input buffer +function stb_decompress_length(input) + return readu8(input, 8) * 16777216 + readu8(input, 9) * 65536 + readu8(input, 10) * 256 + readu8(input, 11) +end + +local stb__barrier_out_e, stb__barrier_out_b +local stb__barrier_in_b +local stb__dout +local stb__out, stb__in -- [Luau] buffers the offsets above point into +local function stb__match(data, length) + -- INVERSE of memmove... write each byte before copying the next... + assert(stb__dout + length <= stb__barrier_out_e) + if stb__dout + length > stb__barrier_out_e then stb__dout = stb__dout + length; return end + if data < stb__barrier_out_b then stb__dout = stb__barrier_out_e + 1; return end + if stb__dout - data >= length then -- [Luau] no overlap: block copy + buffer.copy(stb__out, stb__dout, stb__out, data, length) + stb__dout = stb__dout + length + return + end + local out = stb__out + local dout = stb__dout + for n = 0, length - 1 do writeu8(out, dout + n, readu8(out, data + n)) end + stb__dout = dout + length +end + +local function stb__lit(data, length) + assert(stb__dout + length <= stb__barrier_out_e) + if stb__dout + length > stb__barrier_out_e then stb__dout = stb__dout + length; return end + if data < stb__barrier_in_b then stb__dout = stb__barrier_out_e + 1; return end + buffer.copy(stb__out, stb__dout, stb__in, data, length) + stb__dout = stb__dout + length +end + +local function stb__in2(i, x) return readu8(stb__in, i + x) * 256 + readu8(stb__in, i + x + 1) end +local function stb__in3(i, x) return readu8(stb__in, i + x) * 65536 + stb__in2(i, x + 1) end +local function stb__in4(i, x) return readu8(stb__in, i + x) * 16777216 + stb__in3(i, x + 1) end + +local function stb_decompress_token(i) + local i0 = readu8(stb__in, i) + if i0 >= 0x20 then -- use fewer if's for cases that expand small + if i0 >= 0x80 then stb__match(stb__dout - readu8(stb__in, i + 1) - 1, i0 - 0x80 + 1); i = i + 2 + elseif i0 >= 0x40 then stb__match(stb__dout - (stb__in2(i, 0) - 0x4000 + 1), readu8(stb__in, i + 2) + 1); i = i + 3 + else --[[ *i >= 0x20 ]] stb__lit(i + 1, i0 - 0x20 + 1); i = i + 1 + (i0 - 0x20 + 1) + end + else -- more ifs for cases that expand large, since overhead is amortized + if i0 >= 0x18 then stb__match(stb__dout - (stb__in3(i, 0) - 0x180000 + 1), readu8(stb__in, i + 3) + 1); i = i + 4 + elseif i0 >= 0x10 then stb__match(stb__dout - (stb__in3(i, 0) - 0x100000 + 1), stb__in2(i, 3) + 1); i = i + 5 + elseif i0 >= 0x08 then stb__lit(i + 2, stb__in2(i, 0) - 0x0800 + 1); i = i + 2 + (stb__in2(i, 0) - 0x0800 + 1) + elseif i0 == 0x07 then stb__lit(i + 3, stb__in2(i, 1) + 1); i = i + 3 + (stb__in2(i, 1) + 1) + elseif i0 == 0x06 then stb__match(stb__dout - (stb__in3(i, 1) + 1), readu8(stb__in, i + 4) + 1); i = i + 5 + elseif i0 == 0x04 then stb__match(stb__dout - (stb__in3(i, 1) + 1), stb__in2(i, 4) + 1); i = i + 6 + end + end + return i +end + +--- @param buf buffer +--- @param buflen int +local function stb_adler32(adler32, buf, buflen) + local ADLER_MOD = 65521 + local s1 = adler32 % 65536 + local s2 = math.floor(adler32 / 65536) + local blocklen = buflen % 5552 + + local p = 0 + while buflen > 0 do + for _ = 1, blocklen do + s1 = s1 + readu8(buf, p); s2 = s2 + s1 + p = p + 1 + end + + s1 = s1 % ADLER_MOD; s2 = s2 % ADLER_MOD + buflen = buflen - blocklen + blocklen = 5552 + end + return s2 * 65536 + s1 +end + +--- @param output buffer +--- @param i buffer +function stb_decompress(output, i, length) + stb__in = i + if stb__in4(0, 0) ~= 0x57bC0000 then return 0 end + if stb__in4(0, 4) ~= 0 then return 0 end -- error! stream is > 4GB + local olen = stb_decompress_length(i) + stb__barrier_in_b = 0 + stb__barrier_out_e = olen + stb__barrier_out_b = 0 + stb__out = output + local p = 16 + + stb__dout = 0 + while true do + local old_p = p + p = stb_decompress_token(p) + if p == old_p then + if readu8(i, p) == 0x05 and readu8(i, p + 1) == 0xfa then + assert(stb__dout == olen) + if stb__dout ~= olen then return 0 end + if stb_adler32(1, output, olen) ~= stb__in4(p, 2) then + return 0 + end + return olen + else + assert(false) -- NOTREACHED + return 0 + end + end + assert(stb__dout <= olen) + if stb__dout > olen then + return 0 + end + end +end +end + return true -- [Roblox] ModuleScripts must return exactly one value end @@ -42258,6 +42658,34 @@ function ImFontGlyph() } end +-- Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges(). +-- This is essentially a tightly packed of vector of 64k booleans = 8KB storage. +--- @class ImFontGlyphRangesBuilder +--- @field UsedChars ImVector # Store 1-bit per Unicode code point (0=unused, 1=used) +MT.ImFontGlyphRangesBuilder = {} +MT.ImFontGlyphRangesBuilder.__index = MT.ImFontGlyphRangesBuilder + +--- @return ImFontGlyphRangesBuilder +--- @nodiscard +function ImFontGlyphRangesBuilder() + local this = setmetatable({ UsedChars = ImVector() }, MT.ImFontGlyphRangesBuilder) + this:Clear() + return this +end + +function MT.ImFontGlyphRangesBuilder:Clear() + local size_in_bytes = (65535 --[[IM_UNICODE_CODEPOINT_MAX]] + 1) / 8 + self.UsedChars:resize(size_in_bytes / 4) + local data = self.UsedChars.Data + for i = 1, self.UsedChars.Size do data[i] = 0 end +end +-- Get bit n in the array +function MT.ImFontGlyphRangesBuilder:GetBit(n) local off = bit32.rshift(n, 5); local mask = bit32.lshift(1, bit32.band(n, 31)); return bit32.band(self.UsedChars.Data[off + 1], mask) ~= 0 end +-- Set bit n in the array +function MT.ImFontGlyphRangesBuilder:SetBit(n) local off = bit32.rshift(n, 5); local mask = bit32.lshift(1, bit32.band(n, 31)); self.UsedChars.Data[off + 1] = bit32.bor(self.UsedChars.Data[off + 1], mask) end +-- Add character +function MT.ImFontGlyphRangesBuilder:AddChar(c) self:SetBit(c) end + ------------------------------------------------------------------------------- -- [SECTION] ImGuiIO ------------------------------------------------------------------------------- @@ -78253,6 +78681,7 @@ return { ImFontAtlasBakedAddFontGlyph = ImFontAtlasBakedAddFontGlyph, ImFontAtlasBakedAddFontGlyphAdvancedX = ImFontAtlasBakedAddFontGlyphAdvancedX, ImFontAtlasBakedDiscard = ImFontAtlasBakedDiscard, + ImFontAtlasBakedDiscardFontGlyph = ImFontAtlasBakedDiscardFontGlyph, ImFontAtlasBakedGetClosestMatch = ImFontAtlasBakedGetClosestMatch, ImFontAtlasBakedGetId = ImFontAtlasBakedGetId, ImFontAtlasBakedGetOrAdd = ImFontAtlasBakedGetOrAdd, @@ -78260,6 +78689,7 @@ return { ImFontAtlasBuildClear = ImFontAtlasBuildClear, ImFontAtlasBuildDestroy = ImFontAtlasBuildDestroy, ImFontAtlasBuildInit = ImFontAtlasBuildInit, + ImFontAtlasBuildLegacyPreloadAllGlyphRanges = ImFontAtlasBuildLegacyPreloadAllGlyphRanges, ImFontAtlasBuildMain = ImFontAtlasBuildMain, ImFontAtlasBuildNotifySetFont = ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildRenderBitmapFromString = ImFontAtlasBuildRenderBitmapFromString, @@ -78279,6 +78709,7 @@ return { ImFontAtlasFontDestroySourceData = ImFontAtlasFontDestroySourceData, ImFontAtlasFontDiscardBakes = ImFontAtlasFontDiscardBakes, ImFontAtlasFontInitOutput = ImFontAtlasFontInitOutput, + ImFontAtlasFontRebuildOutput = ImFontAtlasFontRebuildOutput, ImFontAtlasFontSourceAddToFont = ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit = ImFontAtlasFontSourceInit, ImFontAtlasGetMouseCursorTexData = ImFontAtlasGetMouseCursorTexData, @@ -78298,6 +78729,7 @@ return { ImFontAtlasTextureAdd = ImFontAtlasTextureAdd, ImFontAtlasTextureBlockConvert = ImFontAtlasTextureBlockConvert, ImFontAtlasTextureBlockCopy = ImFontAtlasTextureBlockCopy, + ImFontAtlasTextureBlockFill = ImFontAtlasTextureBlockFill, ImFontAtlasTextureBlockPostProcess = ImFontAtlasTextureBlockPostProcess, ImFontAtlasTextureBlockPostProcessMultiply = ImFontAtlasTextureBlockPostProcessMultiply, ImFontAtlasTextureBlockQueueUpload = ImFontAtlasTextureBlockQueueUpload, @@ -78316,6 +78748,7 @@ return { ImFontConfig = ImFontConfig, ImFontFlags = ImFontFlags, ImFontGlyph = ImFontGlyph, + ImFontGlyphRangesBuilder = ImFontGlyphRangesBuilder, ImFontLoader = ImFontLoader, ImFontStackData = ImFontStackData, ImFormatString = ImFormatString, @@ -78536,6 +78969,8 @@ return { ImTextInitClassifiers = ImTextInitClassifiers, ImTextureData = ImTextureData, ImTextureDataGetFormatBytesPerPixel = ImTextureDataGetFormatBytesPerPixel, + ImTextureDataGetFormatName = ImTextureDataGetFormatName, + ImTextureDataGetStatusName = ImTextureDataGetStatusName, ImTextureDataUpdateNewFrame = ImTextureDataUpdateNewFrame, ImTextureFormat = ImTextureFormat, ImTextureID_Invalid = ImTextureID_Invalid, @@ -78621,6 +79056,8 @@ return { UINT_MAX = UINT_MAX, VTX_STRIDE = VTX_STRIDE, _PathArcToFastExXY = _PathArcToFastExXY, + stb_decompress = stb_decompress, + stb_decompress_length = stb_decompress_length, stb_text_locate_coord = stb_text_locate_coord, stb_text_makeundo_delete = stb_text_makeundo_delete, stb_text_makeundo_insert = stb_text_makeundo_insert, diff --git a/build/imgui_love.linemap.json b/build/imgui_love.linemap.json index bc6b4db..9a8dea0 100644 --- a/build/imgui_love.linemap.json +++ b/build/imgui_love.linemap.json @@ -1 +1 @@ -[[183, "imgui.lua"], [21603, "imgui_demo.lua"], [33455, "imgui_draw.lua"], [41258, "imgui_h.lua"], [44164, "imgui_impl_love.lua"], [44704, "imgui_internal.lua"], [48426, "imgui_tables.lua"], [53485, "imgui_widgets.lua"], [65461, "imstb_rectpack.lua"], [66125, "imstb_textedit.lua"], [67667, "imstb_truetype.lua"], [70455, "imstd_minstdio.lua"]] \ No newline at end of file +[[183, "imgui.lua"], [21603, "imgui_demo.lua"], [33455, "imgui_draw.lua"], [41658, "imgui_h.lua"], [44592, "imgui_impl_love.lua"], [45132, "imgui_internal.lua"], [48854, "imgui_tables.lua"], [53913, "imgui_widgets.lua"], [65889, "imstb_rectpack.lua"], [66553, "imstb_textedit.lua"], [68095, "imstb_truetype.lua"], [70883, "imstd_minstdio.lua"]] \ No newline at end of file diff --git a/build/imgui_love.lua b/build/imgui_love.lua index b600a38..ae48a2d 100644 --- a/build/imgui_love.lua +++ b/build/imgui_love.lua @@ -138,7 +138,7 @@ if not utf8 then end -local ImGui, ImVec2, ImVec4, ImRect, HelpMarker, ImVec2_Copy, IMGUI_DEMO_MARKER, ImGuiTableFlags, ImStd, ImVector, ImGuiKey, ImDrawFlags, ImGuiInputFlags, ImRect_Copy, ImGuiDataType, ImStb, IM_TRUNC, ImVec2_CopyV, ImGuiStyleVarInfo, IM_ASSERT_USER_ERROR, ImGuiHoveredFlags, ImFormatString, IM_ASSERT_USER_ERROR_RET, ImHashStr, ImS32, ImGuiColorEditFlags, ImIsPowerOfTwo, ImAbs, ImVec4_Copy, ExampleAppConsoleMT, IM_ROUND, ImGuiTableColumnFlags, ImGuiTreeNodeFlags, PopStyleCompact, PushStyleCompact, IM_ASSERT_PARANOID, ImU16, ExampleNames, ImGuiWindowFlags, ImGuiItemFlags, stbte, ImColor, ImCos, ImGuiButtonFlags, ImGuiDebugLogFlags, ImGuiLocKey, ImU32, ExampleTreeFuncs, ImGuiListClipper, ImS16, _PathArcToFastExXY, ImGuiMultiSelectFlags, ImSin, ImGuiTabBarFlags, ImUpperPowerOfTwo, IM_F32_TO_INT8_SAT, ImFontAtlasPackGetRect, ImGuiMouseCursor, DockSettingsRenameNodeReferences, ExampleDualListBoxMT, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImCeil, ImFabs, ImGuiCol, ImGuiSelectionBasicStorage, ImLengthSqr, ImS8, ImU8, ExampleAppPropertyEditorMT, ImGuiScrollFlags, ImGui_ImplLOVE_GetBackendData, ImLog, ExampleSelectionWithDeletionMT, CustomConstraints, ExampleAppLogMT, ImFontAtlasBuildInit, ImGuiComboFlags, ImGuiPopupFlags, ImGuiSliderFlags, ImTextClassifierSetCharClass, MyDocument, ShowExampleMenuFile, CalcCornerArcStepAndCount, ImFontAtlasBakedAddFontGlyph, ImFontAtlasPackAddRect, ImFontBaked_BuildLoadGlyph, ImGuiInputTextFlags, ImGuiStyle_Copy, ExampleAsset_s_current_sort_specs, ExampleMemberInfo, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC, ImFontAtlasBuildRenderBitmapFromString, ImFontAtlasFontDestroyOutput, ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit, ImFontAtlasTextureAdd, ImFontAtlasTextureBlockQueueUpload, ImFontBaked_BuildGrowIndex, ImGuiTableColumn, stb_textedit_key, stbtt_GetGlyphBitmapBoxSubpixel, IM_FREE, ImDrawListSplitter, ImGuiDragDropFlags, ImGuiFocusedFlags, stb_text_locate_coord, stb_text_makeundo_insert, stb_text_makeundo_replace, stb_textedit_find_charpos, stbtt_GetGlyphShape, IM_ALLOC, ImGuiTableColumnSortSpecs, ImGuiTableInstanceData, ImGuiTableSettings, stb_text_makeundo_delete, stb_text_redo, stb_text_undo, stb_textedit_click, stb_textedit_drag, stbtt_FindGlyphIndex, stbtt_GetFontOffsetForIndex, stbtt_GetFontVMetrics, stbtt_GetGlyphBitmapBox, stbtt_GetGlyphHMetrics, stbtt_InitFont, stbtt_MakeGlyphBitmapSubpixelPrefilter, stbtt_ScaleForPixelHeight, stbtt__GetGlyphInfoT2, stbtt__GetGlyphShapeT2, stbtt_fontinfo, ImGuiOldColumnData, ImGuiOldColumnFlags, ImGuiOldColumns, ImGuiTable, ImGuiTableColumnSettings, ImGuiTableSortSpecs, ImGuiTableTempData, ImGui_ImplLOVE_CreateTexture, ImGui_ImplLOVE_DestroyTexture, ImGui_ImplLOVE_Init, ImGui_ImplLOVE_NewFrame, ImGui_ImplLOVE_RenderDrawData, ImGui_ImplLOVE_Shutdown, ImGui_ImplLOVE_UpdateTexture, stbrp_init_target, IMGUI_TABLE_MAX_COLUMNS, IMSTB_TEXTEDIT_UNDOSTATECOUNT, IM_COL32_DISABLE, ImGui_ImplLove, STB_TEXTEDIT_K_BACKSPACE, STB_TEXTEDIT_K_DELETE, STB_TEXTEDIT_K_DOWN, STB_TEXTEDIT_K_LEFT, STB_TEXTEDIT_K_LINEEND, STB_TEXTEDIT_K_LINESTART, STB_TEXTEDIT_K_PGDOWN, STB_TEXTEDIT_K_PGUP, STB_TEXTEDIT_K_REDO, STB_TEXTEDIT_K_RIGHT, STB_TEXTEDIT_K_SHIFT +local ImGui, ImVec2, ImVec4, ImRect, HelpMarker, ImVec2_Copy, IMGUI_DEMO_MARKER, ImGuiTableFlags, ImStd, ImVector, ImGuiKey, ImDrawFlags, ImGuiInputFlags, ImRect_Copy, ImGuiDataType, ImStb, IM_TRUNC, ImVec2_CopyV, ImGuiStyleVarInfo, IM_ASSERT_USER_ERROR, ImGuiHoveredFlags, ImFormatString, IM_ASSERT_USER_ERROR_RET, ImHashStr, ImS32, ImGuiColorEditFlags, ImIsPowerOfTwo, ImAbs, ImVec4_Copy, ExampleAppConsoleMT, IM_ROUND, ImGuiTableColumnFlags, ImGuiTreeNodeFlags, PopStyleCompact, PushStyleCompact, IM_ASSERT_PARANOID, ImU16, ExampleNames, ImGuiWindowFlags, ImGuiItemFlags, stbte, ImColor, ImCos, ImGuiButtonFlags, ImGuiDebugLogFlags, ImGuiLocKey, ImU32, ExampleTreeFuncs, ImGuiListClipper, ImS16, _PathArcToFastExXY, ImGuiMultiSelectFlags, ImSin, ImGuiTabBarFlags, ImUpperPowerOfTwo, IM_F32_TO_INT8_SAT, ImFontAtlasPackGetRect, ImGuiMouseCursor, DockSettingsRenameNodeReferences, ExampleDualListBoxMT, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImCeil, ImFabs, ImGuiCol, ImGuiSelectionBasicStorage, ImLengthSqr, ImS8, ImU8, ExampleAppPropertyEditorMT, ImGuiScrollFlags, ImGui_ImplLOVE_GetBackendData, ImLog, ExampleSelectionWithDeletionMT, CustomConstraints, ExampleAppLogMT, ImFontAtlasBuildInit, ImFontAtlasFontDestroyOutput, ImGuiComboFlags, ImGuiPopupFlags, ImGuiSliderFlags, ImTextClassifierSetCharClass, MyDocument, ShowExampleMenuFile, CalcCornerArcStepAndCount, ImFontAtlasBakedAddFontGlyph, ImFontAtlasPackAddRect, ImFontBaked_BuildLoadGlyph, ImFontConfig, ImGuiInputTextFlags, ImGuiStyle_Copy, ExampleAsset_s_current_sort_specs, ExampleMemberInfo, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC, ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildRenderBitmapFromString, ImFontAtlasFontDestroySourceData, ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit, ImGuiTableColumn, stb_textedit_key, stbtt_GetGlyphBitmapBoxSubpixel, IM_FREE, ImDrawListSplitter, ImGuiDragDropFlags, ImGuiFocusedFlags, stb_text_locate_coord, stb_text_makeundo_insert, stb_text_makeundo_replace, stb_textedit_find_charpos, stbtt_GetGlyphShape, ImGuiTableColumnSortSpecs, ImGuiTableInstanceData, ImGuiTableSettings, stb_text_makeundo_delete, stb_text_redo, stb_text_undo, stb_textedit_click, stb_textedit_drag, stbtt_FindGlyphIndex, stbtt_GetFontOffsetForIndex, stbtt_GetFontVMetrics, stbtt_GetGlyphBitmapBox, stbtt_GetGlyphHMetrics, stbtt_InitFont, stbtt_MakeGlyphBitmapSubpixelPrefilter, stbtt_ScaleForPixelHeight, stbtt__GetGlyphInfoT2, stbtt__GetGlyphShapeT2, stbtt_fontinfo, ImGuiOldColumnData, ImGuiOldColumnFlags, ImGuiOldColumns, ImGuiTable, ImGuiTableColumnSettings, ImGuiTableSortSpecs, ImGuiTableTempData, ImGui_ImplLOVE_CreateTexture, ImGui_ImplLOVE_DestroyTexture, ImGui_ImplLOVE_Init, ImGui_ImplLOVE_NewFrame, ImGui_ImplLOVE_RenderDrawData, ImGui_ImplLOVE_Shutdown, ImGui_ImplLOVE_UpdateTexture, stbrp_init_target, IMGUI_TABLE_MAX_COLUMNS, IMSTB_TEXTEDIT_UNDOSTATECOUNT, IM_COL32_DISABLE, ImGui_ImplLove, STB_TEXTEDIT_K_BACKSPACE, STB_TEXTEDIT_K_DELETE, STB_TEXTEDIT_K_DOWN, STB_TEXTEDIT_K_LEFT, STB_TEXTEDIT_K_LINEEND, STB_TEXTEDIT_K_LINESTART, STB_TEXTEDIT_K_PGDOWN, STB_TEXTEDIT_K_PGUP, STB_TEXTEDIT_K_REDO, STB_TEXTEDIT_K_RIGHT, STB_TEXTEDIT_K_SHIFT, STB_TEXTEDIT_K_TEXTEND local type, mathMin, mathMax, mathFloor, mathCeil, bitOr, bitLShift = type, math.min, math.max, math.floor, math.ceil, bit32.bor, bit32.lshift local function IM_COL32(R, G, B, A) return (bitOr(bitLShift(A, 24 --[[IM_COL32_A_SHIFT]]), bitLShift(B, 16 --[[IM_COL32_B_SHIFT]]), bitLShift(G, 8 --[[IM_COL32_G_SHIFT]]), bitLShift(R, 0 --[[IM_COL32_R_SHIFT]]))) end @@ -34342,6 +34342,28 @@ function ImFontAtlasTextureBlockCopy(src_tex, src_x, src_y, dst_tex, dst_x, dst_ end end +--- @param dst_tex ImTextureData +--- @param col ImU32 +function ImFontAtlasTextureBlockFill(dst_tex, dst_x, dst_y, w, h, col) + if dst_tex.Format == 1 --[[ImTextureFormat.Alpha8]] then + local col_a = bit32.band(bit32.rshift(col, 24 --[[IM_COL32_A_SHIFT]]), 0xFF) + for y = 0, h - 1 do + local p, base = dst_tex:GetPixelsAt(dst_x, dst_y + y) + for i = base, base + w - 1 do p[i] = col_a end + end + else + -- [Luau] Pixels is a byte table: write the 4 bytes of the little-endian ImU32 + local c0, c1, c2, c3 = bit32.band(col, 0xFF), bit32.band(bit32.rshift(col, 8), 0xFF), bit32.band(bit32.rshift(col, 16), 0xFF), bit32.band(bit32.rshift(col, 24), 0xFF) + for y = 0, h - 1 do + local p, i = dst_tex:GetPixelsAt(dst_x, dst_y + y) + for _ = w, 1, -1 do + p[i] = c0; p[i + 1] = c1; p[i + 2] = c2; p[i + 3] = c3 + i = i + 4 + end + end + end +end + -- Queue texture block update for renderer backend --- @param tex ImTextureData --- @param x int @@ -34996,6 +35018,18 @@ function ImFontAtlasBuildSetupFontBakedBlanks(atlas, baked) end end +--- @param glyph ImFontGlyph +function ImFontAtlasBakedDiscardFontGlyph(atlas, font, baked, glyph) + if glyph.PackId ~= (-1) --[[ImFontAtlasRectId_Invalid]] then + ImFontAtlasPackDiscardRect(atlas, glyph.PackId) + glyph.PackId = (-1) --[[ImFontAtlasRectId_Invalid]] + end + local c = glyph.Codepoint + assert(font.FallbackChar ~= c and font.EllipsisChar ~= c) -- Unsupported for simplicity + baked.IndexLookup.Data[c + 1] = IM_FONTGLYPH_INDEX_UNUSED + baked.IndexAdvanceX.Data[c + 1] = baked.FallbackAdvanceX +end + --- @param atlas ImFontAtlas --- @param font ImFont --- @param font_size float @@ -35154,6 +35188,11 @@ function ImFontAtlasFontDestroyOutput(atlas, font) end end +function ImFontAtlasFontRebuildOutput(atlas, font) + ImFontAtlasFontDestroyOutput(atlas, font) + ImFontAtlasFontInitOutput(atlas, font) +end + --- @param atlas ImFontAtlas --- @param src ImFontConfig --- @return boolean @@ -36040,6 +36079,32 @@ function ImFontAtlasBuildMain(atlas) atlas.TexIsBuilt = true end +-- [Luau] Ported but its call above stays disabled: the Roblox/LÖVE backends support RendererHasTextures. +function ImFontAtlasBuildLegacyPreloadAllGlyphRanges(atlas) + atlas.Builder.PreloadedAllGlyphsRanges = true + for _, font in atlas.Fonts:iter() do + local baked = font:GetFontBaked(font.LegacySize) + if font.FallbackChar ~= 0 then + baked:FindGlyph(font.FallbackChar) + end + if font.EllipsisChar ~= 0 then + baked:FindGlyph(font.EllipsisChar) + end + for _, src in font.Sources:iter() do + local ranges = src.GlyphRanges and src.GlyphRanges or atlas:GetGlyphRangesDefault() + local i = 1 + while ranges[i] ~= 0 do + local c = ranges[i] + while c <= ranges[i + 1] and c <= 65535 --[[IM_UNICODE_CODEPOINT_MAX]] do + baked:FindGlyph(c) + c = c + 1 + end + i = i + 2 + end + end + end +end + ------------------------------------------------------------------------------- -- [SECTION] ImTextureData ------------------------------------------------------------------------------- @@ -36047,6 +36112,25 @@ end -- - ImTextureData:DestroyPixels() ------------------------------------------------------------------------------- +--- @param status ImTextureStatus +function ImTextureDataGetStatusName(status) + if status == 0 --[[ImTextureStatus.OK]] then return "OK" + elseif status == 1 --[[ImTextureStatus.Destroyed]] then return "Destroyed" + elseif status == 2 --[[ImTextureStatus.WantCreate]] then return "WantCreate" + elseif status == 3 --[[ImTextureStatus.WantUpdates]] then return "WantUpdates" + elseif status == 4 --[[ImTextureStatus.WantDestroy]] then return "WantDestroy" + end + return "N/A" +end + +--- @param format ImTextureFormat +function ImTextureDataGetFormatName(format) + if format == 1 --[[ImTextureFormat.Alpha8]] then return "Alpha8" + elseif format == 0 --[[ImTextureFormat.RGBA32]] then return "RGBA32" + end + return "N/A" +end + function MT.ImTextureData:DestroyPixels() self.Pixels = nil self.UseColors = false @@ -36083,6 +36167,74 @@ function MT.ImTextureData:Create(format, w, h) self.UpdateRect.h = 0 end +------------------------------------------------------------------------------- +-- [SECTION] ImFontAtlas: glyph ranges helpers +------------------------------------------------------------------------------- +-- - GetGlyphRangesDefault() +-- [Luau] The obsolete GetGlyphRangesXXX() (IMGUI_DISABLE_OBSOLETE_FUNCTIONS) are not ported. +------------------------------------------------------------------------------- + +-- Retrieve list of range (2 int per range, values are inclusive) +local GlyphRangesDefault = +{ + 0x0020, 0x00FF, -- Basic Latin + Latin Supplement + 0, +} +function MT.ImFontAtlas:GetGlyphRangesDefault() + return GlyphRangesDefault +end + +------------------------------------------------------------------------------- +-- [SECTION] ImFontGlyphRangesBuilder +------------------------------------------------------------------------------- + +--- @param text ImString +--- @param text_end? int # exclusive, 1-based +function MT.ImFontGlyphRangesBuilder:AddText(text, text_end) + if text_end == nil then + text_end = #text + 1 + end + local s = 1 + while s < text_end do + local c_len, c = ImStd.ImTextCharFromUtf8(text, s, text_end) + s = s + c_len + if c_len == 0 then + break + end + self:AddChar(c) + end +end + +--- @param ranges ImWchar[] # 1-based, zero-terminated +function MT.ImFontGlyphRangesBuilder:AddRanges(ranges) + local i = 1 + while ranges[i] ~= 0 do + local c = ranges[i] + while c <= ranges[i + 1] and c <= 65535 --[[IM_UNICODE_CODEPOINT_MAX]] do + self:AddChar(c) + c = c + 1 + end + i = i + 2 + end +end + +--- @param out_ranges ImVector +function MT.ImFontGlyphRangesBuilder:BuildRanges(out_ranges) + local max_codepoint = 65535 --[[IM_UNICODE_CODEPOINT_MAX]] + local n = 0 + while n <= max_codepoint do + if self:GetBit(n) then + out_ranges:push_back(n) + while n < max_codepoint and self:GetBit(n + 1) do + n = n + 1 + end + out_ranges:push_back(n) + end + n = n + 1 + end + out_ranges:push_back(0) +end + ------------------------------------------------------------------------------- -- [SECTION] ImFontBaked, ImFont ------------------------------------------------------------------------------- @@ -36152,6 +36304,21 @@ function MT.ImFont:ClearOutputData() self.LastBaked = nil end +-- API is designed this way to avoid exposing the 8K page size +-- e.g. use with IsGlyphRangeUnused(0, 255) +function MT.ImFont:IsGlyphRangeUnused(c_begin, c_last) + local page_begin = math.floor(c_begin / 8192) + local page_last = math.floor(c_last / 8192) + for page_n = page_begin, page_last do + if bit32.rshift(page_n, 3) < (65535 --[[IM_UNICODE_CODEPOINT_MAX]] + 1) / 8192 / 8 then -- sizeof(Used8kPagesMap) + if bit32.band(self.Used8kPagesMap[bit32.rshift(page_n, 3) + 1] or 0, bit32.lshift(1, bit32.band(page_n, 7))) ~= 0 then + return false + end + end + end + return true +end + --- @param font_id ImGuiID --- @param baked_size float --- @param rasterizer_density float @@ -36319,6 +36486,14 @@ function MT.ImFont:GetFontBaked(size, density) return baked end +-- Makes 'from_codepoint' character points to 'to_codepoint' glyph. +-- [Luau] AddRemapCodepointToGlyphIndex() not ported: needs the 1.93 loader split (FontSrcGetGlyphIndexFromCodepoint). +function MT.ImFont:AddRemapCodepoint(from_codepoint, to_codepoint) + local data = to_codepoint + assert(bit32.band(data, bit32.lshift(1, 31)) == 0) + self.RemapPairs[from_codepoint] = data +end + --- @param atlas ImFontAtlas --- @param font ImFont --- @param c ImWchar @@ -36326,7 +36501,7 @@ end --- @nodiscard local function ImFontAtlas_FontHookRemapCodepoint(atlas, font, c) -- IM_UNUSED(atlas) - if #font.RemapPairs > 0 then + if next(font.RemapPairs) ~= nil then -- [Luau] font->RemapPairs.Data.Size != 0 (RemapPairs is a hash table) local ret = font.RemapPairs[c] return (ret ~= nil) and ret or c end @@ -36721,6 +36896,16 @@ function ImFontCalcWordWrapPositionEx_Uncached(baked, size, text, pos, text_end, return s end +--- @param size float +--- @param text ImString +--- @param pos int # [Luau] 1-based start position (C++ 'text' pointer) +--- @param text_end int # exclusive +--- @param wrap_width float +--- @return int +function MT.ImFont:CalcWordWrapPosition(size, text, pos, text_end, wrap_width) + return ImFontCalcWordWrapPositionEx(self, size, text, pos, text_end, wrap_width, 0 --[[ImDrawTextFlags.None]]) +end + --- @param font ImFont --- @param size float --- @param max_width float @@ -37048,6 +37233,25 @@ function MT.ImFontAtlas:AddFont(font_cfg_in) return font end +-- Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder) +local stb_decompress_length +local stb_decompress +local function Decode85Byte(c) return (c >= 92) and (c - 36) or (c - 35) end -- c >= '\\' +--- @param src string +--- @param dst buffer +local function Decode85(src, dst) + local d = 0 + local src_len = #src + local s = 1 + while s + 4 <= src_len do -- [Luau] while (*src): stop at the last complete 5-char group + local b0, b1, b2, b3, b4 = string.byte(src, s, s + 4) + local tmp = (Decode85Byte(b0) + 85 * (Decode85Byte(b1) + 85 * (Decode85Byte(b2) + 85 * (Decode85Byte(b3) + 85 * Decode85Byte(b4))))) % 4294967296 + buffer.writeu8(dst, d + 0, tmp % 256); buffer.writeu8(dst, d + 1, math.floor(tmp / 256) % 256); buffer.writeu8(dst, d + 2, math.floor(tmp / 65536) % 256); buffer.writeu8(dst, d + 3, math.floor(tmp / 16777216) % 256) -- We can't assume little-endianness. + s = s + 5 + d = d + 4 + end +end + -- This duplicates some of the logic in UpdateFontsNewFrame() which is a bit chicken-and-eggy/tricky to extract due to variety of codepaths and possible initialization ordering. --- @param ctx ImGuiContext --- @return float @@ -37081,9 +37285,68 @@ function MT.ImFontAtlas:AddFontFromMemoryTTF(font_data, font_data_size, size_pix return self:AddFont(font_cfg) end --- TODO: GetDefaultCompressedFontDataProggyClean, GetDefaultCompressedFontDataProggyForever -function MT.ImFontAtlas:AddFontFromMemoryCompressedTTF() - -- TODO: +--- @param compressed_ttf_data buffer|string|ImU8[] # [Luau] stb_compress() output: buffer, string or 1-based byte table +--- @param compressed_ttf_size int +function MT.ImFontAtlas:AddFontFromMemoryCompressedTTF(compressed_ttf_data, compressed_ttf_size, size_pixels, font_cfg_template, glyph_ranges) + -- [Luau] normalize input to a buffer + if type(compressed_ttf_data) == "string" then + compressed_ttf_data = buffer.fromstring(compressed_ttf_data) + elseif type(compressed_ttf_data) == "table" then + local b = buffer.create(compressed_ttf_size) + for n = 1, compressed_ttf_size do buffer.writeu8(b, n - 1, compressed_ttf_data[n]) end + compressed_ttf_data = b + end + local buf_decompressed_size = stb_decompress_length(compressed_ttf_data) + local buf_decompressed_data = buffer.create(buf_decompressed_size) + stb_decompress(buf_decompressed_data, compressed_ttf_data, compressed_ttf_size) + + -- [Luau] FontData is a 1-based byte table (see stbtt / ImFileLoadToMemory) + local ttf_data = table.create and table.create(buf_decompressed_size) or {} + for n = 1, buf_decompressed_size do ttf_data[n] = buffer.readu8(buf_decompressed_data, n - 1) end + + local font_cfg = font_cfg_template and font_cfg_template or ImFontConfig() + assert(font_cfg.FontData == nil) + font_cfg.FontDataOwnedByAtlas = true + return self:AddFontFromMemoryTTF(ttf_data, buf_decompressed_size, size_pixels or 0.0, font_cfg, glyph_ranges) +end + +--- @param compressed_ttf_data_base85 string +function MT.ImFontAtlas:AddFontFromMemoryCompressedBase85TTF(compressed_ttf_data_base85, size_pixels, font_cfg, glyph_ranges) + local compressed_ttf_size = math.floor((#compressed_ttf_data_base85 + 4) / 5) * 4 + local compressed_ttf = buffer.create(compressed_ttf_size) + Decode85(compressed_ttf_data_base85, compressed_ttf) + local font = self:AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges) + return font +end + +--- @param font ImFont +function MT.ImFontAtlas:RemoveFont(font) + assert(not self.Locked, "Cannot modify a locked ImFontAtlas!") + + ImFontAtlasFontDestroyOutput(self, font) + for _, src in font.Sources:iter() do + ImFontAtlasFontDestroySourceData(self, src) + end + local src_n = 1 + while src_n <= self.Sources.Size do + if self.Sources.Data[src_n].DstFont == font then + self.Sources:erase(src_n) + else + src_n = src_n + 1 + end + end + + local removed = self.Fonts:find_erase(font) + assert(removed) + + ImFontAtlasBuildUpdatePointers(self) + + font.OwnerAtlas = nil + + -- Notify external systems + local new_current_font = nil + if self.Fonts.Size > 0 then new_current_font = self.Fonts.Data[1] end + ImFontAtlasBuildNotifySetFont(self, font, new_current_font) end function MT.ImFontAtlas:AddFontFromFileTTF(filename, size_pixels, font_cfg_template, glyph_ranges) @@ -37239,6 +37502,13 @@ function MT.ImFontAtlas:AddCustomRect(width, height, out_r) return r_id end +function MT.ImFontAtlas:RemoveCustomRect(id) + if ImFontAtlasPackGetRectSafe(self, id) == nil then + return + end + ImFontAtlasPackDiscardRect(self, id) +end + local function IM_NORMALIZE2F_OVER_ZERO(VX, VY) local d2 = VX * VX + VY * VY if d2 > 0.0 then @@ -41251,6 +41521,136 @@ function MT.ImDrawList:PathFillConcave(col) self._Path.Size = 0 end +------------------------------------------------------------------------------- +-- [SECTION] Decompression code +------------------------------------------------------------------------------- +-- Compressed with stb_compress() then converted to a C array and encoded as base85. +-- Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file. +-- The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. +-- Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h +-- [Luau] Input and output are buffers, pointers are 0-based byte offsets into them. +------------------------------------------------------------------------------- + +do +local readu8 = buffer.readu8 +local writeu8 = buffer.writeu8 + +--- @param input buffer +function stb_decompress_length(input) + return readu8(input, 8) * 16777216 + readu8(input, 9) * 65536 + readu8(input, 10) * 256 + readu8(input, 11) +end + +local stb__barrier_out_e, stb__barrier_out_b +local stb__barrier_in_b +local stb__dout +local stb__out, stb__in -- [Luau] buffers the offsets above point into +local function stb__match(data, length) + -- INVERSE of memmove... write each byte before copying the next... + assert(stb__dout + length <= stb__barrier_out_e) + if stb__dout + length > stb__barrier_out_e then stb__dout = stb__dout + length; return end + if data < stb__barrier_out_b then stb__dout = stb__barrier_out_e + 1; return end + if stb__dout - data >= length then -- [Luau] no overlap: block copy + buffer.copy(stb__out, stb__dout, stb__out, data, length) + stb__dout = stb__dout + length + return + end + local out = stb__out + local dout = stb__dout + for n = 0, length - 1 do writeu8(out, dout + n, readu8(out, data + n)) end + stb__dout = dout + length +end + +local function stb__lit(data, length) + assert(stb__dout + length <= stb__barrier_out_e) + if stb__dout + length > stb__barrier_out_e then stb__dout = stb__dout + length; return end + if data < stb__barrier_in_b then stb__dout = stb__barrier_out_e + 1; return end + buffer.copy(stb__out, stb__dout, stb__in, data, length) + stb__dout = stb__dout + length +end + +local function stb__in2(i, x) return readu8(stb__in, i + x) * 256 + readu8(stb__in, i + x + 1) end +local function stb__in3(i, x) return readu8(stb__in, i + x) * 65536 + stb__in2(i, x + 1) end +local function stb__in4(i, x) return readu8(stb__in, i + x) * 16777216 + stb__in3(i, x + 1) end + +local function stb_decompress_token(i) + local i0 = readu8(stb__in, i) + if i0 >= 0x20 then -- use fewer if's for cases that expand small + if i0 >= 0x80 then stb__match(stb__dout - readu8(stb__in, i + 1) - 1, i0 - 0x80 + 1); i = i + 2 + elseif i0 >= 0x40 then stb__match(stb__dout - (stb__in2(i, 0) - 0x4000 + 1), readu8(stb__in, i + 2) + 1); i = i + 3 + else --[[ *i >= 0x20 ]] stb__lit(i + 1, i0 - 0x20 + 1); i = i + 1 + (i0 - 0x20 + 1) + end + else -- more ifs for cases that expand large, since overhead is amortized + if i0 >= 0x18 then stb__match(stb__dout - (stb__in3(i, 0) - 0x180000 + 1), readu8(stb__in, i + 3) + 1); i = i + 4 + elseif i0 >= 0x10 then stb__match(stb__dout - (stb__in3(i, 0) - 0x100000 + 1), stb__in2(i, 3) + 1); i = i + 5 + elseif i0 >= 0x08 then stb__lit(i + 2, stb__in2(i, 0) - 0x0800 + 1); i = i + 2 + (stb__in2(i, 0) - 0x0800 + 1) + elseif i0 == 0x07 then stb__lit(i + 3, stb__in2(i, 1) + 1); i = i + 3 + (stb__in2(i, 1) + 1) + elseif i0 == 0x06 then stb__match(stb__dout - (stb__in3(i, 1) + 1), readu8(stb__in, i + 4) + 1); i = i + 5 + elseif i0 == 0x04 then stb__match(stb__dout - (stb__in3(i, 1) + 1), stb__in2(i, 4) + 1); i = i + 6 + end + end + return i +end + +--- @param buf buffer +--- @param buflen int +local function stb_adler32(adler32, buf, buflen) + local ADLER_MOD = 65521 + local s1 = adler32 % 65536 + local s2 = math.floor(adler32 / 65536) + local blocklen = buflen % 5552 + + local p = 0 + while buflen > 0 do + for _ = 1, blocklen do + s1 = s1 + readu8(buf, p); s2 = s2 + s1 + p = p + 1 + end + + s1 = s1 % ADLER_MOD; s2 = s2 % ADLER_MOD + buflen = buflen - blocklen + blocklen = 5552 + end + return s2 * 65536 + s1 +end + +--- @param output buffer +--- @param i buffer +function stb_decompress(output, i, length) + stb__in = i + if stb__in4(0, 0) ~= 0x57bC0000 then return 0 end + if stb__in4(0, 4) ~= 0 then return 0 end -- error! stream is > 4GB + local olen = stb_decompress_length(i) + stb__barrier_in_b = 0 + stb__barrier_out_e = olen + stb__barrier_out_b = 0 + stb__out = output + local p = 16 + + stb__dout = 0 + while true do + local old_p = p + p = stb_decompress_token(p) + if p == old_p then + if readu8(i, p) == 0x05 and readu8(i, p + 1) == 0xfa then + assert(stb__dout == olen) + if stb__dout ~= olen then return 0 end + if stb_adler32(1, output, olen) ~= stb__in4(p, 2) then + return 0 + end + return olen + else + assert(false) -- NOTREACHED + return 0 + end + end + assert(stb__dout <= olen) + if stb__dout > olen then + return 0 + end + end +end +end + return true -- [Roblox] ModuleScripts must return exactly one value end @@ -42395,6 +42795,34 @@ function ImFontGlyph() } end +-- Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges(). +-- This is essentially a tightly packed of vector of 64k booleans = 8KB storage. +--- @class ImFontGlyphRangesBuilder +--- @field UsedChars ImVector # Store 1-bit per Unicode code point (0=unused, 1=used) +MT.ImFontGlyphRangesBuilder = {} +MT.ImFontGlyphRangesBuilder.__index = MT.ImFontGlyphRangesBuilder + +--- @return ImFontGlyphRangesBuilder +--- @nodiscard +function ImFontGlyphRangesBuilder() + local this = setmetatable({ UsedChars = ImVector() }, MT.ImFontGlyphRangesBuilder) + this:Clear() + return this +end + +function MT.ImFontGlyphRangesBuilder:Clear() + local size_in_bytes = (65535 --[[IM_UNICODE_CODEPOINT_MAX]] + 1) / 8 + self.UsedChars:resize(size_in_bytes / 4) + local data = self.UsedChars.Data + for i = 1, self.UsedChars.Size do data[i] = 0 end +end +-- Get bit n in the array +function MT.ImFontGlyphRangesBuilder:GetBit(n) local off = bit32.rshift(n, 5); local mask = bit32.lshift(1, bit32.band(n, 31)); return bit32.band(self.UsedChars.Data[off + 1], mask) ~= 0 end +-- Set bit n in the array +function MT.ImFontGlyphRangesBuilder:SetBit(n) local off = bit32.rshift(n, 5); local mask = bit32.lshift(1, bit32.band(n, 31)); self.UsedChars.Data[off + 1] = bit32.bor(self.UsedChars.Data[off + 1], mask) end +-- Add character +function MT.ImFontGlyphRangesBuilder:AddChar(c) self:SetBit(c) end + ------------------------------------------------------------------------------- -- [SECTION] ImGuiIO ------------------------------------------------------------------------------- @@ -70879,6 +71307,7 @@ return { ImFontAtlasBakedAddFontGlyph = ImFontAtlasBakedAddFontGlyph, ImFontAtlasBakedAddFontGlyphAdvancedX = ImFontAtlasBakedAddFontGlyphAdvancedX, ImFontAtlasBakedDiscard = ImFontAtlasBakedDiscard, + ImFontAtlasBakedDiscardFontGlyph = ImFontAtlasBakedDiscardFontGlyph, ImFontAtlasBakedGetClosestMatch = ImFontAtlasBakedGetClosestMatch, ImFontAtlasBakedGetId = ImFontAtlasBakedGetId, ImFontAtlasBakedGetOrAdd = ImFontAtlasBakedGetOrAdd, @@ -70886,6 +71315,7 @@ return { ImFontAtlasBuildClear = ImFontAtlasBuildClear, ImFontAtlasBuildDestroy = ImFontAtlasBuildDestroy, ImFontAtlasBuildInit = ImFontAtlasBuildInit, + ImFontAtlasBuildLegacyPreloadAllGlyphRanges = ImFontAtlasBuildLegacyPreloadAllGlyphRanges, ImFontAtlasBuildMain = ImFontAtlasBuildMain, ImFontAtlasBuildNotifySetFont = ImFontAtlasBuildNotifySetFont, ImFontAtlasBuildRenderBitmapFromString = ImFontAtlasBuildRenderBitmapFromString, @@ -70905,6 +71335,7 @@ return { ImFontAtlasFontDestroySourceData = ImFontAtlasFontDestroySourceData, ImFontAtlasFontDiscardBakes = ImFontAtlasFontDiscardBakes, ImFontAtlasFontInitOutput = ImFontAtlasFontInitOutput, + ImFontAtlasFontRebuildOutput = ImFontAtlasFontRebuildOutput, ImFontAtlasFontSourceAddToFont = ImFontAtlasFontSourceAddToFont, ImFontAtlasFontSourceInit = ImFontAtlasFontSourceInit, ImFontAtlasGetMouseCursorTexData = ImFontAtlasGetMouseCursorTexData, @@ -70924,6 +71355,7 @@ return { ImFontAtlasTextureAdd = ImFontAtlasTextureAdd, ImFontAtlasTextureBlockConvert = ImFontAtlasTextureBlockConvert, ImFontAtlasTextureBlockCopy = ImFontAtlasTextureBlockCopy, + ImFontAtlasTextureBlockFill = ImFontAtlasTextureBlockFill, ImFontAtlasTextureBlockPostProcess = ImFontAtlasTextureBlockPostProcess, ImFontAtlasTextureBlockPostProcessMultiply = ImFontAtlasTextureBlockPostProcessMultiply, ImFontAtlasTextureBlockQueueUpload = ImFontAtlasTextureBlockQueueUpload, @@ -70942,6 +71374,7 @@ return { ImFontConfig = ImFontConfig, ImFontFlags = ImFontFlags, ImFontGlyph = ImFontGlyph, + ImFontGlyphRangesBuilder = ImFontGlyphRangesBuilder, ImFontLoader = ImFontLoader, ImFontStackData = ImFontStackData, ImFormatString = ImFormatString, @@ -71155,6 +71588,8 @@ return { ImTextInitClassifiers = ImTextInitClassifiers, ImTextureData = ImTextureData, ImTextureDataGetFormatBytesPerPixel = ImTextureDataGetFormatBytesPerPixel, + ImTextureDataGetFormatName = ImTextureDataGetFormatName, + ImTextureDataGetStatusName = ImTextureDataGetStatusName, ImTextureDataUpdateNewFrame = ImTextureDataUpdateNewFrame, ImTextureFormat = ImTextureFormat, ImTextureID_Invalid = ImTextureID_Invalid, @@ -71239,6 +71674,8 @@ return { UINT_MAX = UINT_MAX, VTX_STRIDE = VTX_STRIDE, _PathArcToFastExXY = _PathArcToFastExXY, + stb_decompress = stb_decompress, + stb_decompress_length = stb_decompress_length, stb_text_locate_coord = stb_text_locate_coord, stb_text_makeundo_delete = stb_text_makeundo_delete, stb_text_makeundo_insert = stb_text_makeundo_insert, diff --git a/docs/PORT_STATUS.txt b/docs/PORT_STATUS.txt index 694781a..a76f8ea 100644 --- a/docs/PORT_STATUS.txt +++ b/docs/PORT_STATUS.txt @@ -14,18 +14,18 @@ polyline stroker (AddPolyline), Lua-native replacements (ImGuiStorage, ImStr*, I upstream file funcs ported by size similarity stubs imgui.cpp 786 87.4% 93.5% 75.1% 2 imgui_widgets.cpp 308 93.8% 98.7% 78.4% 1 -imgui_draw.cpp 258 86.8% 94.4% 61.2% 2 +imgui_draw.cpp 258 96.1% 98.2% 61.1% 1 imgui_tables.cpp 113 96.5% 99.0% 74.0% 0 imgui_demo.cpp 56 100.0% 100.0% 55.8% 0 -imgui.h 110 53.6% 37.4% 60.0% 0 +imgui.h 110 58.2% 41.7% 60.2% 0 imgui_internal.h 269 63.2% 67.5% 68.5% 1 -TOTAL 1900 83.9% 95.6% 70.4% 6 +TOTAL 1900 85.4% 96.1% 70.3% 5 -upstream code reproduced (similarity x ported size / all upstream size): 67.2% +upstream code reproduced (similarity x ported size / all upstream size): 67.5% Public API (imgui.h, namespace ImGui) 368 / 376 97.9% Internal API (imgui_internal.h, namespace ImGui) 417 / 443 94.1% Enum values (imgui.h + imgui_internal.h) 1037 / 1078 96.2% -Struct fields (imgui.h + imgui_internal.h) 1839 / 1926 95.5% +Struct fields (imgui.h + imgui_internal.h) 1840 / 1926 95.5% Legend: [x] ported (sim %) [~] stub [ ] not ported [-] excluded (c++-only / obsolete / os-specific / #if 0 / test-engine) @@ -43,7 +43,7 @@ imgui.cpp -- USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO) [x] 33% ImGuiStyle::ImGuiStyle imgui_internal.lua:1530 [x] 83% ImGuiStyle::ScaleAllSizes imgui.lua:4779 - [x] 12% ImGuiIO::ImGuiIO imgui_h.lua:1187 + [x] 12% ImGuiIO::ImGuiIO imgui_h.lua:1215 [x] 83% ImGuiIO::AddInputCharacter imgui.lua:7983 [x] 83% ImGuiIO::AddInputCharacterUTF16 imgui.lua:8004 [ ] ImGuiIO::AddInputCharactersUTF8 @@ -61,7 +61,7 @@ imgui.cpp [x] 96% ImGuiIO::AddMouseSourceEvent imgui.lua:8173 [x] 87% ImGuiIO::AddMouseViewportEvent imgui.lua:8180 [x] 84% ImGuiIO::AddFocusEvent imgui.lua:8209 - [x] 15% ImGuiPlatformIO::ImGuiPlatformIO imgui_h.lua:1525 + [x] 15% ImGuiPlatformIO::ImGuiPlatformIO imgui_h.lua:1553 -- MISC HELPERS/UTILITIES (Geometry functions) [ ] ImBezierCubicClosestPoint @@ -148,8 +148,8 @@ imgui.cpp [x] 56% ImGuiTextFilter::PassFilter imgui.lua:19454 -- ImGuiTextBuffer, ImGuiTextIndex - [x] 5% ImGuiTextBuffer::append imgui_h.lua:2748 - [x] 17% ImGuiTextBuffer::appendf imgui_h.lua:2749 + [x] 5% ImGuiTextBuffer::append imgui_h.lua:2776 + [x] 17% ImGuiTextBuffer::appendf imgui_h.lua:2777 [ ] ImGuiTextBuffer::appendfv [ ] ImGuiTextIndex::append @@ -1093,9 +1093,9 @@ imgui_widgets.cpp [ ] ImGuiInputTextState::ReloadUserBufAndSelectAll [ ] ImGuiInputTextState::ReloadUserBufAndKeepSelection [ ] ImGuiInputTextState::ReloadUserBufAndMoveToEnd - [x] 18% ImGuiInputTextCallbackData::ImGuiInputTextCallbackData imgui_h.lua:2468 - [x] 61% ImGuiInputTextCallbackData::DeleteChars imgui_h.lua:2472 - [x] 33% ImGuiInputTextCallbackData::InsertChars imgui_h.lua:2489 + [x] 18% ImGuiInputTextCallbackData::ImGuiInputTextCallbackData imgui_h.lua:2496 + [x] 61% ImGuiInputTextCallbackData::DeleteChars imgui_h.lua:2500 + [x] 33% ImGuiInputTextCallbackData::InsertChars imgui_h.lua:2517 [x] 92% ImGui::PushPasswordFont imgui_widgets.lua:4843 [x] 98% ImGui::PopPasswordFont imgui_widgets.lua:4858 [x] 80% InputTextFilterCharacter imgui_widgets.lua:4878 @@ -1275,107 +1275,107 @@ imgui_draw.cpp -- ImDrawList [x] 30% ImDrawListSharedData::ImDrawListSharedData imgui_internal.lua:1132 [-] ImDrawListSharedData::~ImDrawListSharedData c++-only - [x] 57% ImDrawListSharedData::SetCircleTessellationMaxError imgui_draw.lua:3918 + [x] 57% ImDrawListSharedData::SetCircleTessellationMaxError imgui_draw.lua:4188 [x] 6% ImDrawList::ImDrawList imgui_h.lua:657 [-] ImDrawList::~ImDrawList c++-only - [x] 88% ImDrawList::_SetDrawListSharedData imgui_draw.lua:3935 - [x] 43% ImDrawList::_ResetForNewFrame imgui_draw.lua:3948 - [x] 64% ImDrawList::_ClearFreeMemory imgui_draw.lua:3976 + [x] 88% ImDrawList::_SetDrawListSharedData imgui_draw.lua:4205 + [x] 43% ImDrawList::_ResetForNewFrame imgui_draw.lua:4218 + [x] 64% ImDrawList::_ClearFreeMemory imgui_draw.lua:4246 [ ] ImDrawList::CloneOutput - [x] 77% ImDrawList::AddDrawCmd imgui_draw.lua:3995 - [x] 88% ImDrawList::_PopUnusedDrawCmd imgui_draw.lua:4012 - [x] 57% ImDrawList::AddCallback imgui_draw.lua:4026 - [x] 42% ImDrawList::_TryMergeDrawCmds imgui_draw.lua:4101 - [x] 33% ImDrawList::_OnChangedClipRect imgui_draw.lua:4113 - [x] 55% ImDrawList::_OnChangedTexture imgui_draw.lua:4140 - [x] 91% ImDrawList::_OnChangedVtxOffset imgui_draw.lua:4166 - [x] 57% ImDrawList::_CalcCircleAutoSegmentCount imgui_draw.lua:6582 - [x] 86% ImDrawList::PushClipRect imgui_draw.lua:6594 - [x] 60% ImDrawList::PushClipRectFullScreen imgui_draw.lua:6617 - [x] 39% ImDrawList::PopClipRect imgui_draw.lua:6622 - [x] 67% ImDrawList::PushTexture imgui_draw.lua:4382 - [x] 81% ImDrawList::PopTexture imgui_draw.lua:4391 - [x] 62% ImDrawList::PushDrawFlag imgui_draw.lua:4400 - [x] 85% ImDrawList::PopDrawFlag imgui_draw.lua:4412 - [x] 83% ImDrawList::_SetTexture imgui_draw.lua:4419 - [x] 89% ImDrawList::_SetPixelDensity imgui_draw.lua:4429 - [x] 57% ImDrawList::PrimReserve imgui_draw.lua:4469 = PrimReserve - [x] 68% ImDrawList::PrimUnreserve imgui_draw.lua:4472 - [x] 8% ImDrawList::PrimRect imgui_draw.lua:4519 - [x] 13% ImDrawList::PrimRectUV imgui_draw.lua:4528 + [x] 77% ImDrawList::AddDrawCmd imgui_draw.lua:4265 + [x] 88% ImDrawList::_PopUnusedDrawCmd imgui_draw.lua:4282 + [x] 57% ImDrawList::AddCallback imgui_draw.lua:4296 + [x] 42% ImDrawList::_TryMergeDrawCmds imgui_draw.lua:4371 + [x] 33% ImDrawList::_OnChangedClipRect imgui_draw.lua:4383 + [x] 55% ImDrawList::_OnChangedTexture imgui_draw.lua:4410 + [x] 91% ImDrawList::_OnChangedVtxOffset imgui_draw.lua:4436 + [x] 57% ImDrawList::_CalcCircleAutoSegmentCount imgui_draw.lua:6852 + [x] 86% ImDrawList::PushClipRect imgui_draw.lua:6864 + [x] 60% ImDrawList::PushClipRectFullScreen imgui_draw.lua:6887 + [x] 39% ImDrawList::PopClipRect imgui_draw.lua:6892 + [x] 67% ImDrawList::PushTexture imgui_draw.lua:4652 + [x] 81% ImDrawList::PopTexture imgui_draw.lua:4661 + [x] 62% ImDrawList::PushDrawFlag imgui_draw.lua:4670 + [x] 85% ImDrawList::PopDrawFlag imgui_draw.lua:4682 + [x] 83% ImDrawList::_SetTexture imgui_draw.lua:4689 + [x] 89% ImDrawList::_SetPixelDensity imgui_draw.lua:4699 + [x] 57% ImDrawList::PrimReserve imgui_draw.lua:4739 = PrimReserve + [x] 68% ImDrawList::PrimUnreserve imgui_draw.lua:4742 + [x] 8% ImDrawList::PrimRect imgui_draw.lua:4789 + [x] 13% ImDrawList::PrimRectUV imgui_draw.lua:4798 [ ] ImDrawList::PrimQuadUV - [x] 83% ImDrawList::_CalculateCenterBiasedOffset imgui_draw.lua:4566 = _CalculateCenterBiasedOffset - [x] 77% ImAlphaMultiply imgui_draw.lua:3830 - [x] 72% ImDrawList::_SelectLineTexture imgui_draw.lua:4601 = _SelectLineTexture - [x] 37% ImDrawList::_AddPolyline imgui_draw.lua:4614 - [x] 43% ImDrawList::AddConvexPolyFilled imgui_draw.lua:4984 - [x] 59% CalcCornerArcStepAndCount imgui_draw.lua:3897 - [x] 64% ImDrawList::_PathArcToFastEx imgui_draw.lua:6741 - [x] 63% ImDrawList::_PathArcToN imgui_draw.lua:6761 - [x] 10% ImDrawList::PathArcToFast imgui_draw.lua:6747 - [x] 46% ImDrawList::PathArcTo imgui_draw.lua:6787 - [x] 61% ImDrawList::PathEllipticalArcTo imgui_draw.lua:7377 - [x] 88% ImBezierCubicCalc imgui_draw.lua:7389 - [x] 89% ImBezierQuadraticCalc imgui_draw.lua:7395 - [x] 85% PathBezierCubicCurveToCasteljau imgui_draw.lua:7402 - [x] 90% PathBezierQuadraticCurveToCasteljau imgui_draw.lua:7420 - [x] 91% ImDrawList::PathBezierCubicCurveTo imgui_draw.lua:7434 - [x] 90% ImDrawList::PathBezierQuadraticCurveTo imgui_draw.lua:7446 - [x] 8% ImDrawList::PathRect imgui_draw.lua:5234 - [x] 46% ImDrawList::_AddLine imgui_draw.lua:5366 - [x] 4% ImDrawList::AddLine imgui_draw.lua:5375 - [x] 9% ImDrawList::AddLineH imgui_draw.lua:5403 - [x] 9% ImDrawList::AddLineV imgui_draw.lua:5459 - [x] 18% ImDrawList::_AddRectBaked imgui_draw.lua:5619 - [x] 42% ImDrawList::_AddRectTinyRounding imgui_draw.lua:5636 - [x] 12% ImDrawList::AddRect imgui_draw.lua:5762 - [x] 10% ImDrawList::_AddRectFilledBaked imgui_draw.lua:5980 - [x] 11% ImDrawList::AddRectFilled imgui_draw.lua:5990 - [x] 26% ImDrawList::AddRectFilledMultiColor imgui_draw.lua:6096 - [x] 59% ImDrawList::AddQuad imgui_draw.lua:6119 - [x] 71% ImDrawList::AddQuadFilled imgui_draw.lua:6136 - [x] 59% ImDrawList::AddTriangle imgui_draw.lua:6148 - [x] 73% ImDrawList::AddTriangleFilled imgui_draw.lua:6165 - [x] 100% ApproxApothem imgui_draw.lua:3907 - [x] 47% ImDrawList::AddCircle imgui_draw.lua:6181 - [x] 32% ImDrawList::AddCircleFilled imgui_draw.lua:6246 - [x] 86% ImDrawList::AddNgon imgui_draw.lua:6284 - [x] 95% ImDrawList::AddNgonFilled imgui_draw.lua:6332 - [x] 80% ImDrawList::AddEllipse imgui_draw.lua:6357 - [x] 88% ImDrawList::AddEllipseFilled imgui_draw.lua:6394 - [x] 73% ImDrawList::AddBezierCubic imgui_draw.lua:6435 - [x] 71% ImDrawList::AddBezierQuadratic imgui_draw.lua:6451 - [x] 65% ImDrawList::AddText imgui_draw.lua:6476 - [x] 69% ImDrawList::AddImage imgui_draw.lua:6519 + [x] 83% ImDrawList::_CalculateCenterBiasedOffset imgui_draw.lua:4836 = _CalculateCenterBiasedOffset + [x] 77% ImAlphaMultiply imgui_draw.lua:4100 + [x] 72% ImDrawList::_SelectLineTexture imgui_draw.lua:4871 = _SelectLineTexture + [x] 37% ImDrawList::_AddPolyline imgui_draw.lua:4884 + [x] 43% ImDrawList::AddConvexPolyFilled imgui_draw.lua:5254 + [x] 59% CalcCornerArcStepAndCount imgui_draw.lua:4167 + [x] 64% ImDrawList::_PathArcToFastEx imgui_draw.lua:7011 + [x] 63% ImDrawList::_PathArcToN imgui_draw.lua:7031 + [x] 10% ImDrawList::PathArcToFast imgui_draw.lua:7017 + [x] 46% ImDrawList::PathArcTo imgui_draw.lua:7057 + [x] 61% ImDrawList::PathEllipticalArcTo imgui_draw.lua:7647 + [x] 88% ImBezierCubicCalc imgui_draw.lua:7659 + [x] 89% ImBezierQuadraticCalc imgui_draw.lua:7665 + [x] 85% PathBezierCubicCurveToCasteljau imgui_draw.lua:7672 + [x] 90% PathBezierQuadraticCurveToCasteljau imgui_draw.lua:7690 + [x] 91% ImDrawList::PathBezierCubicCurveTo imgui_draw.lua:7704 + [x] 90% ImDrawList::PathBezierQuadraticCurveTo imgui_draw.lua:7716 + [x] 8% ImDrawList::PathRect imgui_draw.lua:5504 + [x] 46% ImDrawList::_AddLine imgui_draw.lua:5636 + [x] 4% ImDrawList::AddLine imgui_draw.lua:5645 + [x] 9% ImDrawList::AddLineH imgui_draw.lua:5673 + [x] 9% ImDrawList::AddLineV imgui_draw.lua:5729 + [x] 18% ImDrawList::_AddRectBaked imgui_draw.lua:5889 + [x] 42% ImDrawList::_AddRectTinyRounding imgui_draw.lua:5906 + [x] 12% ImDrawList::AddRect imgui_draw.lua:6032 + [x] 10% ImDrawList::_AddRectFilledBaked imgui_draw.lua:6250 + [x] 11% ImDrawList::AddRectFilled imgui_draw.lua:6260 + [x] 26% ImDrawList::AddRectFilledMultiColor imgui_draw.lua:6366 + [x] 59% ImDrawList::AddQuad imgui_draw.lua:6389 + [x] 71% ImDrawList::AddQuadFilled imgui_draw.lua:6406 + [x] 59% ImDrawList::AddTriangle imgui_draw.lua:6418 + [x] 73% ImDrawList::AddTriangleFilled imgui_draw.lua:6435 + [x] 100% ApproxApothem imgui_draw.lua:4177 + [x] 47% ImDrawList::AddCircle imgui_draw.lua:6451 + [x] 32% ImDrawList::AddCircleFilled imgui_draw.lua:6516 + [x] 86% ImDrawList::AddNgon imgui_draw.lua:6554 + [x] 95% ImDrawList::AddNgonFilled imgui_draw.lua:6602 + [x] 80% ImDrawList::AddEllipse imgui_draw.lua:6627 + [x] 88% ImDrawList::AddEllipseFilled imgui_draw.lua:6664 + [x] 73% ImDrawList::AddBezierCubic imgui_draw.lua:6705 + [x] 71% ImDrawList::AddBezierQuadratic imgui_draw.lua:6721 + [x] 65% ImDrawList::AddText imgui_draw.lua:6746 + [x] 69% ImDrawList::AddImage imgui_draw.lua:6789 [ ] ImDrawList::AddImageQuad - [x] 84% ImDrawList::AddImageRounded imgui_draw.lua:6549 + [x] 84% ImDrawList::AddImageRounded imgui_draw.lua:6819 -- ImTriangulator, ImDrawList concave polygon fill - [x] 35% ImTriangulatorNode::Unlink imgui_draw.lua:7478 - [x] 50% ImTriangulatorNodeSpan::push_back imgui_draw.lua:7491 - [x] 66% ImTriangulatorNodeSpan::find_erase_unsorted imgui_draw.lua:7492 - [x] 84% ImTriangulator::EstimateTriangleCount imgui_draw.lua:7508 - [x] 71% ImTriangulator::EstimateScratchBufferSize imgui_draw.lua:7510 - [x] 38% ImTriangulator::Init imgui_draw.lua:7516 - [x] 45% ImTriangulator::BuildNodes imgui_draw.lua:7541 - [x] 32% ImTriangulator::BuildReflexes imgui_draw.lua:7554 - [x] 38% ImTriangulator::BuildEars imgui_draw.lua:7566 - [x] 53% ImTriangulator::GetNextTriangle imgui_draw.lua:7582 - [x] 65% ImTriangulator::FlipNodeList imgui_draw.lua:7620 - [x] 56% ImTriangulator::IsEar imgui_draw.lua:7643 - [x] 58% ImTriangulator::ReclassifyNode imgui_draw.lua:7658 - [x] 39% ImDrawList::AddConcavePolyFilled imgui_draw.lua:7701 + [x] 35% ImTriangulatorNode::Unlink imgui_draw.lua:7748 + [x] 50% ImTriangulatorNodeSpan::push_back imgui_draw.lua:7761 + [x] 66% ImTriangulatorNodeSpan::find_erase_unsorted imgui_draw.lua:7762 + [x] 84% ImTriangulator::EstimateTriangleCount imgui_draw.lua:7778 + [x] 71% ImTriangulator::EstimateScratchBufferSize imgui_draw.lua:7780 + [x] 38% ImTriangulator::Init imgui_draw.lua:7786 + [x] 45% ImTriangulator::BuildNodes imgui_draw.lua:7811 + [x] 32% ImTriangulator::BuildReflexes imgui_draw.lua:7824 + [x] 38% ImTriangulator::BuildEars imgui_draw.lua:7836 + [x] 53% ImTriangulator::GetNextTriangle imgui_draw.lua:7852 + [x] 65% ImTriangulator::FlipNodeList imgui_draw.lua:7890 + [x] 56% ImTriangulator::IsEar imgui_draw.lua:7913 + [x] 58% ImTriangulator::ReclassifyNode imgui_draw.lua:7928 + [x] 39% ImDrawList::AddConcavePolyFilled imgui_draw.lua:7971 -- ImDrawListSplitter - [x] 58% ImDrawListSplitter::ClearFreeMemory imgui_draw.lua:4201 - [x] 63% ImDrawListSplitter::Split imgui_draw.lua:4219 - [x] 54% ImDrawListSplitter::Merge imgui_draw.lua:4245 - [x] 29% ImDrawListSplitter::SetCurrentChannel imgui_draw.lua:4336 + [x] 58% ImDrawListSplitter::ClearFreeMemory imgui_draw.lua:4471 + [x] 63% ImDrawListSplitter::Split imgui_draw.lua:4489 + [x] 54% ImDrawListSplitter::Merge imgui_draw.lua:4515 + [x] 29% ImDrawListSplitter::SetCurrentChannel imgui_draw.lua:4606 -- ImDrawData - [x] 60% ImDrawData::Clear imgui_draw.lua:3848 - [x] 68% ImGui::AddDrawListToDrawDataEx imgui_draw.lua:3861 - [x] 94% ImDrawData::AddDrawList imgui_draw.lua:3883 + [x] 60% ImDrawData::Clear imgui_draw.lua:4118 + [x] 68% ImGui::AddDrawListToDrawDataEx imgui_draw.lua:4131 + [x] 94% ImDrawData::AddDrawList imgui_draw.lua:4153 [ ] ImDrawData::DeIndexAllBuffers [ ] ImDrawData::ScaleClipRects @@ -1388,11 +1388,11 @@ imgui_draw.cpp [x] 20% ImFontConfig::ImFontConfig imgui_h.lua:957 -- ImTextureData - [x] 76% ImTextureDataGetFormatBytesPerPixel imgui_draw.lua:2601 - [ ] ImTextureDataGetStatusName - [ ] ImTextureDataGetFormatName - [x] 80% ImTextureData::Create imgui_draw.lua:2611 - [x] 71% ImTextureData::DestroyPixels imgui_draw.lua:2596 + [x] 76% ImTextureDataGetFormatBytesPerPixel imgui_draw.lua:2685 + [x] 75% ImTextureDataGetStatusName imgui_draw.lua:2662 + [x] 79% ImTextureDataGetFormatName imgui_draw.lua:2673 + [x] 80% ImTextureData::Create imgui_draw.lua:2695 + [x] 71% ImTextureData::DestroyPixels imgui_draw.lua:2680 -- ImFontAtlas, ImFontAtlasBuilder [x] 39% ImFontAtlas::ImFontAtlas imgui_h.lua:1038 @@ -1403,111 +1403,111 @@ imgui_draw.cpp [x] 70% ImFontAtlas::ClearTexData imgui_draw.lua:602 [x] 100% ImFontAtlas::CompactCache imgui_draw.lua:612 [x] 100% ImFontAtlas::SetFontLoader imgui_draw.lua:580 - [x] 81% ImFontAtlasBuildUpdateRendererHasTexturesFromContext imgui_draw.lua:1887 + [x] 81% ImFontAtlasBuildUpdateRendererHasTexturesFromContext imgui_draw.lua:1926 [x] 78% ImFontAtlasUpdateNewFrame imgui_draw.lua:690 [x] 93% ImTextureDataUpdateNewFrame imgui_draw.lua:640 [x] 44% ImFontAtlasTextureBlockConvert imgui_draw.lua:781 [x] 100% ImFontAtlasTextureBlockPostProcess imgui_draw.lua:826 [x] 48% ImFontAtlasTextureBlockPostProcessMultiply imgui_draw.lua:835 - [ ] ImFontAtlasTextureBlockFill + [x] 32% ImFontAtlasTextureBlockFill imgui_draw.lua:893 [x] 87% ImFontAtlasTextureBlockCopy imgui_draw.lua:877 - [x] 100% ImFontAtlasTextureBlockQueueUpload imgui_draw.lua:926 - [x] 99% ImTextureDataQueueUpload imgui_draw.lua:897 + [x] 100% ImFontAtlasTextureBlockQueueUpload imgui_draw.lua:948 + [x] 99% ImTextureDataQueueUpload imgui_draw.lua:919 [-] GetTexDataAsFormat obsolete [-] ImFontAtlas::GetTexDataAsAlpha8 obsolete [-] ImFontAtlas::GetTexDataAsRGBA32 obsolete [-] ImFontAtlas::Build obsolete - [x] 83% ImFontAtlas::AddFont imgui_draw.lua:3512 - [ ] Decode85Byte - [ ] Decode85 - [x] 35% GetExpectedContextFontSize imgui_draw.lua:3600 - [x] 97% ImFontAtlas::AddFontDefault imgui_draw.lua:3608 - [x] 68% ImFontAtlas::AddFontDefaultBitmap imgui_draw.lua:3675 - [x] 66% ImFontAtlas::AddFontDefaultVector imgui_draw.lua:3697 - [x] 56% ImFontAtlas::AddFontFromFileTTF imgui_draw.lua:3635 - [x] 90% ImFontAtlas::AddFontFromMemoryTTF imgui_draw.lua:3616 - [~] 0% ImFontAtlas::AddFontFromMemoryCompressedTTF imgui_draw.lua:3631 stub - [ ] ImFontAtlas::AddFontFromMemoryCompressedBase85TTF - [x] 92% ImFontAtlasBuildNotifySetFont imgui_draw.lua:2523 - [ ] ImFontAtlas::RemoveFont - [x] 93% ImFontAtlas::AddCustomRect imgui_draw.lua:3764 - [ ] ImFontAtlas::RemoveCustomRect + [x] 83% ImFontAtlas::AddFont imgui_draw.lua:3697 + [x] 78% Decode85Byte imgui_draw.lua:3785 + [x] 20% Decode85 imgui_draw.lua:3788 + [x] 35% GetExpectedContextFontSize imgui_draw.lua:3804 + [x] 97% ImFontAtlas::AddFontDefault imgui_draw.lua:3812 + [x] 68% ImFontAtlas::AddFontDefaultBitmap imgui_draw.lua:3938 + [x] 66% ImFontAtlas::AddFontDefaultVector imgui_draw.lua:3960 + [x] 56% ImFontAtlas::AddFontFromFileTTF imgui_draw.lua:3898 + [x] 90% ImFontAtlas::AddFontFromMemoryTTF imgui_draw.lua:3820 + [x] 49% ImFontAtlas::AddFontFromMemoryCompressedTTF imgui_draw.lua:3836 + [x] 87% ImFontAtlas::AddFontFromMemoryCompressedBase85TTF imgui_draw.lua:3860 + [x] 92% ImFontAtlasBuildNotifySetFont imgui_draw.lua:2562 + [x] 69% ImFontAtlas::RemoveFont imgui_draw.lua:3869 + [x] 93% ImFontAtlas::AddCustomRect imgui_draw.lua:4027 + [x] 100% ImFontAtlas::RemoveCustomRect imgui_draw.lua:4051 [-] ImFontAtlas::AddCustomRectFontGlyph obsolete [-] ImFontAtlas::AddCustomRectFontGlyphForSize obsolete - [x] 93% ImFontAtlas::GetCustomRect imgui_draw.lua:3716 - [x] 78% ImFontAtlasGetMouseCursorTexData imgui_draw.lua:3741 - [x] 87% ImFontAtlasBuildMain imgui_draw.lua:2565 - [x] 80% ImFontAtlasBuildGetOversampleFactors imgui_draw.lua:951 - [x] 91% ImFontAtlasBuildSetupFontLoader imgui_draw.lua:1857 - [ ] ImFontAtlasBuildLegacyPreloadAllGlyphRanges - [~] 0% ImFontAtlasBuildUpdatePointers imgui_draw.lua:1903 stub - [x] 52% ImFontAtlasBuildRenderBitmapFromString imgui_draw.lua:2392 - [x] 91% ImFontAtlasBuildUpdateTexDataBasic imgui_draw.lua:2423 - [x] 58% InitCornerGeometry imgui_draw.lua:2088 - [x] 78% SampleConvex imgui_draw.lua:2135 - [x] 96% SampleCornerFillOrStroke imgui_draw.lua:2146 - [x] 73% ImFontAtlasBuildUpdateTexDataCorners imgui_draw.lua:2162 - [x] 64% ImFontAtlasBuildUpdateTexDataLines imgui_draw.lua:2252 - [x] 89% ImFontAtlasFontInitOutput imgui_draw.lua:1681 - [x] 86% ImFontAtlasFontDestroyOutput imgui_draw.lua:1693 - [ ] ImFontAtlasFontRebuildOutput - [x] 94% ImFontAtlasFontSourceInit imgui_draw.lua:1706 - [x] 95% ImFontAtlasFontSourceAddToFont imgui_draw.lua:1717 - [x] 54% ImFontAtlasFontDestroySourceData imgui_draw.lua:1730 - [x] 95% ImFontAtlasBuildSetupFontBakedEllipsis imgui_draw.lua:1792 - [x] 91% ImFontAtlasBuildSetupFontBakedFallback imgui_draw.lua:1836 - [x] 88% ImFontAtlasBuildSetupFontBakedBlanks imgui_draw.lua:1528 - [x] 90% ImFontAtlasBuildSetupFontSpecialGlyphs imgui_draw.lua:1748 - [ ] ImFontAtlasBakedDiscardFontGlyph - [x] 81% ImFontAtlasBakedAdd imgui_draw.lua:1551 - [x] 89% ImFontAtlasBakedGetClosestMatch imgui_draw.lua:1588 - [x] 74% ImFontAtlasBakedDiscard imgui_draw.lua:1630 - [x] 83% ImFontAtlasFontDiscardBakes imgui_draw.lua:1659 - [x] 83% ImFontAtlasBuildDiscardBakes imgui_draw.lua:968 - [x] 92% ImFontAtlasAddDrawListSharedData imgui_draw.lua:991 - [x] 92% ImFontAtlasRemoveDrawListSharedData imgui_draw.lua:998 - [x] 79% ImFontAtlasUpdateDrawListsTextures imgui_draw.lua:1916 - [x] 94% ImFontAtlasUpdateDrawListsSharedData imgui_draw.lua:2454 - [x] 98% ImFontAtlasBuildSetTexture imgui_draw.lua:1945 - [x] 100% ImFontAtlasBuildUpdateTexData imgui_draw.lua:1955 - [x] 91% ImFontAtlasTextureAdd imgui_draw.lua:1962 + [x] 93% ImFontAtlas::GetCustomRect imgui_draw.lua:3979 + [x] 78% ImFontAtlasGetMouseCursorTexData imgui_draw.lua:4004 + [x] 87% ImFontAtlasBuildMain imgui_draw.lua:2604 + [x] 80% ImFontAtlasBuildGetOversampleFactors imgui_draw.lua:973 + [x] 91% ImFontAtlasBuildSetupFontLoader imgui_draw.lua:1896 + [x] 76% ImFontAtlasBuildLegacyPreloadAllGlyphRanges imgui_draw.lua:2629 + [~] 0% ImFontAtlasBuildUpdatePointers imgui_draw.lua:1942 stub + [x] 52% ImFontAtlasBuildRenderBitmapFromString imgui_draw.lua:2431 + [x] 91% ImFontAtlasBuildUpdateTexDataBasic imgui_draw.lua:2462 + [x] 58% InitCornerGeometry imgui_draw.lua:2127 + [x] 78% SampleConvex imgui_draw.lua:2174 + [x] 96% SampleCornerFillOrStroke imgui_draw.lua:2185 + [x] 73% ImFontAtlasBuildUpdateTexDataCorners imgui_draw.lua:2201 + [x] 64% ImFontAtlasBuildUpdateTexDataLines imgui_draw.lua:2291 + [x] 89% ImFontAtlasFontInitOutput imgui_draw.lua:1715 + [x] 86% ImFontAtlasFontDestroyOutput imgui_draw.lua:1727 + [x] 100% ImFontAtlasFontRebuildOutput imgui_draw.lua:1737 + [x] 94% ImFontAtlasFontSourceInit imgui_draw.lua:1745 + [x] 95% ImFontAtlasFontSourceAddToFont imgui_draw.lua:1756 + [x] 54% ImFontAtlasFontDestroySourceData imgui_draw.lua:1769 + [x] 95% ImFontAtlasBuildSetupFontBakedEllipsis imgui_draw.lua:1831 + [x] 91% ImFontAtlasBuildSetupFontBakedFallback imgui_draw.lua:1875 + [x] 88% ImFontAtlasBuildSetupFontBakedBlanks imgui_draw.lua:1550 + [x] 90% ImFontAtlasBuildSetupFontSpecialGlyphs imgui_draw.lua:1787 + [x] 70% ImFontAtlasBakedDiscardFontGlyph imgui_draw.lua:1568 + [x] 81% ImFontAtlasBakedAdd imgui_draw.lua:1585 + [x] 89% ImFontAtlasBakedGetClosestMatch imgui_draw.lua:1622 + [x] 74% ImFontAtlasBakedDiscard imgui_draw.lua:1664 + [x] 83% ImFontAtlasFontDiscardBakes imgui_draw.lua:1693 + [x] 83% ImFontAtlasBuildDiscardBakes imgui_draw.lua:990 + [x] 92% ImFontAtlasAddDrawListSharedData imgui_draw.lua:1013 + [x] 92% ImFontAtlasRemoveDrawListSharedData imgui_draw.lua:1020 + [x] 79% ImFontAtlasUpdateDrawListsTextures imgui_draw.lua:1955 + [x] 94% ImFontAtlasUpdateDrawListsSharedData imgui_draw.lua:2493 + [x] 98% ImFontAtlasBuildSetTexture imgui_draw.lua:1984 + [x] 100% ImFontAtlasBuildUpdateTexData imgui_draw.lua:1994 + [x] 91% ImFontAtlasTextureAdd imgui_draw.lua:2001 [-] ImFontAtlasDebugWriteTexToDisk if0 - [x] 91% ImFontAtlasTextureRepack imgui_draw.lua:1006 - [x] 94% ImFontAtlasTextureGrow imgui_draw.lua:1088 - [x] 99% ImFontAtlasTextureMakeSpace imgui_draw.lua:1127 - [x] 96% ImFontAtlasTextureGetSizeEstimate imgui_draw.lua:1997 - [x] 85% ImFontAtlasBuildClear imgui_draw.lua:2032 - [x] 95% ImFontAtlasTextureCompact imgui_draw.lua:2050 - [x] 93% ImFontAtlasBuildInit imgui_draw.lua:2465 - [x] 91% ImFontAtlasBuildDestroy imgui_draw.lua:2507 - [x] 75% ImFontAtlasPackInit imgui_draw.lua:2065 - [x] 85% ImFontAtlasPackAllocRectEntry imgui_draw.lua:1144 - [x] 93% ImFontAtlasPackReuseRectEntry imgui_draw.lua:1168 - [x] 82% ImFontAtlasPackDiscardRect imgui_draw.lua:1178 - [x] 91% ImFontAtlasPackAddRect imgui_draw.lua:1206 - [x] 75% ImFontAtlasPackGetRect imgui_draw.lua:1257 - [x] 82% ImFontAtlasPackGetRectSafe imgui_draw.lua:1272 - [x] 66% ImFontAtlasBuildAcceptCodepointForSource imgui_draw.lua:1297 - [x] 97% ImFontBaked_BuildGrowIndex imgui_draw.lua:1315 - [ ] ImFont::AddRemapCodepoint + [x] 91% ImFontAtlasTextureRepack imgui_draw.lua:1028 + [x] 94% ImFontAtlasTextureGrow imgui_draw.lua:1110 + [x] 99% ImFontAtlasTextureMakeSpace imgui_draw.lua:1149 + [x] 96% ImFontAtlasTextureGetSizeEstimate imgui_draw.lua:2036 + [x] 85% ImFontAtlasBuildClear imgui_draw.lua:2071 + [x] 95% ImFontAtlasTextureCompact imgui_draw.lua:2089 + [x] 93% ImFontAtlasBuildInit imgui_draw.lua:2504 + [x] 91% ImFontAtlasBuildDestroy imgui_draw.lua:2546 + [x] 75% ImFontAtlasPackInit imgui_draw.lua:2104 + [x] 85% ImFontAtlasPackAllocRectEntry imgui_draw.lua:1166 + [x] 93% ImFontAtlasPackReuseRectEntry imgui_draw.lua:1190 + [x] 82% ImFontAtlasPackDiscardRect imgui_draw.lua:1200 + [x] 91% ImFontAtlasPackAddRect imgui_draw.lua:1228 + [x] 75% ImFontAtlasPackGetRect imgui_draw.lua:1279 + [x] 82% ImFontAtlasPackGetRectSafe imgui_draw.lua:1294 + [x] 66% ImFontAtlasBuildAcceptCodepointForSource imgui_draw.lua:1319 + [x] 97% ImFontBaked_BuildGrowIndex imgui_draw.lua:1337 + [x] 69% ImFont::AddRemapCodepoint imgui_draw.lua:3037 [ ] ImFont::AddRemapCodepointToGlyphIndex - [x] 29% ImFontAtlas_FontHookRemapCodepoint imgui_draw.lua:2873 - [x] 70% ImFontBaked_BuildLoadGlyph imgui_draw.lua:2888 - [x] 77% ImFontBaked_BuildLoadGlyphAdvanceX imgui_draw.lua:2968 - [x] 67% BuildLoadGlyphGetAdvanceOrFallback imgui_draw.lua:3013 + [x] 26% ImFontAtlas_FontHookRemapCodepoint imgui_draw.lua:3048 + [x] 70% ImFontBaked_BuildLoadGlyph imgui_draw.lua:3063 + [x] 77% ImFontBaked_BuildLoadGlyphAdvanceX imgui_draw.lua:3143 + [x] 67% BuildLoadGlyphGetAdvanceOrFallback imgui_draw.lua:3188 [ ] ImFontAtlasDebugLogTextureRequests -- ImFontAtlas: backend for stb_truetype - [x] 84% ImGui_ImplStbTrueType_FontSrcInit imgui_draw.lua:1351 - [x] 53% ImGui_ImplStbTrueType_FontSrcDestroy imgui_draw.lua:1386 + [x] 84% ImGui_ImplStbTrueType_FontSrcInit imgui_draw.lua:1373 + [x] 53% ImGui_ImplStbTrueType_FontSrcDestroy imgui_draw.lua:1408 [ ] ImGui_ImplStbTrueType_FontSrcGetGlyphIndexFromCodepoint - [x] 43% ImGui_ImplStbTrueType_FontSrcContainsGlyph imgui_draw.lua:1391 - [x] 88% ImGui_ImplStbTrueType_FontBakedInit imgui_draw.lua:1400 - [x] 85% ImGui_ImplStbTrueType_FontBakedLoadGlyph imgui_draw.lua:1427 - [x] 74% ImFontAtlasGetFontLoaderForStbTruetype imgui_draw.lua:1511 + [x] 43% ImGui_ImplStbTrueType_FontSrcContainsGlyph imgui_draw.lua:1413 + [x] 88% ImGui_ImplStbTrueType_FontBakedInit imgui_draw.lua:1422 + [x] 85% ImGui_ImplStbTrueType_FontBakedLoadGlyph imgui_draw.lua:1449 + [x] 74% ImFontAtlasGetFontLoaderForStbTruetype imgui_draw.lua:1533 -- ImFontAtlas: glyph ranges helpers - [ ] ImFontAtlas::GetGlyphRangesDefault + [x] 15% ImFontAtlas::GetGlyphRangesDefault imgui_draw.lua:2729 [-] ImFontAtlas::GetGlyphRangesGreek obsolete [-] ImFontAtlas::GetGlyphRangesKorean obsolete [-] ImFontAtlas::GetGlyphRangesChineseFull obsolete @@ -1519,59 +1519,59 @@ imgui_draw.cpp [-] ImFontAtlas::GetGlyphRangesVietnamese obsolete -- ImFontGlyphRangesBuilder - [ ] ImFontGlyphRangesBuilder::AddText - [ ] ImFontGlyphRangesBuilder::AddRanges - [ ] ImFontGlyphRangesBuilder::BuildRanges + [x] 64% ImFontGlyphRangesBuilder::AddText imgui_draw.lua:2739 + [x] 52% ImFontGlyphRangesBuilder::AddRanges imgui_draw.lua:2755 + [x] 78% ImFontGlyphRangesBuilder::BuildRanges imgui_draw.lua:2768 -- ImFontBaked, ImFont [x] 12% ImFontBaked::ImFontBaked imgui_h.lua:844 - [x] 79% ImFontBaked::ClearOutputData imgui_draw.lua:2636 + [x] 79% ImFontBaked::ClearOutputData imgui_draw.lua:2788 [x] 10% ImFont::ImFont imgui_h.lua:901 [-] ImFont::~ImFont c++-only - [x] 49% ImFont::ClearOutputData imgui_draw.lua:2690 - [ ] ImFont::IsGlyphRangeUnused - [x] 87% ImFontAtlasBakedAddFontGlyph imgui_draw.lua:2756 - [x] 87% ImFontAtlasBakedAddFontGlyphAdvancedX imgui_draw.lua:2814 - [x] 84% ImFontAtlasBakedSetFontGlyphBitmap imgui_draw.lua:940 - [x] 85% ImFontBaked::FindGlyph imgui_draw.lua:2650 - [x] 88% ImFontBaked::FindGlyphNoFallback imgui_draw.lua:2673 - [x] 49% ImFontBaked::IsGlyphLoaded imgui_draw.lua:2665 - [x] 50% ImFont::IsGlyphInFont imgui_draw.lua:2985 - [x] 86% ImFontBaked::GetCharAdvance imgui_draw.lua:3001 - [x] 46% ImFontAtlasBakedGetId imgui_draw.lua:2705 - [x] 90% ImFont::GetFontBaked imgui_draw.lua:2839 - [x] 91% ImFontAtlasBakedGetOrAdd imgui_draw.lua:2715 - [x] 55% ImTextCalcWordWrapNextLineStart imgui_draw.lua:3023 - [x] 81% ImTextClassifierClear imgui_draw.lua:3043 - [x] 53% ImTextClassifierSetCharClass imgui_draw.lua:3054 - [x] 60% ImTextClassifierSetCharClassFromStr imgui_draw.lua:3062 - [x] 88% ImTextInitClassifiers imgui_draw.lua:3080 - [x] 35% ImFontCalcWordWrapPositionEx imgui_draw.lua:3111 - [ ] ImFont::CalcWordWrapPosition - [x] 49% ImFontCalcTextSizeEx imgui_draw.lua:3285 - [x] 91% ImFont::CalcTextSizeA imgui_draw.lua:3446 - [x] 85% ImFont::RenderChar imgui_draw.lua:3459 - [x] 66% ImFont::RenderText imgui_draw.lua:6853 + [x] 49% ImFont::ClearOutputData imgui_draw.lua:2842 + [x] 58% ImFont::IsGlyphRangeUnused imgui_draw.lua:2855 + [x] 87% ImFontAtlasBakedAddFontGlyph imgui_draw.lua:2923 + [x] 87% ImFontAtlasBakedAddFontGlyphAdvancedX imgui_draw.lua:2981 + [x] 84% ImFontAtlasBakedSetFontGlyphBitmap imgui_draw.lua:962 + [x] 85% ImFontBaked::FindGlyph imgui_draw.lua:2802 + [x] 88% ImFontBaked::FindGlyphNoFallback imgui_draw.lua:2825 + [x] 49% ImFontBaked::IsGlyphLoaded imgui_draw.lua:2817 + [x] 50% ImFont::IsGlyphInFont imgui_draw.lua:3160 + [x] 86% ImFontBaked::GetCharAdvance imgui_draw.lua:3176 + [x] 46% ImFontAtlasBakedGetId imgui_draw.lua:2872 + [x] 90% ImFont::GetFontBaked imgui_draw.lua:3006 + [x] 91% ImFontAtlasBakedGetOrAdd imgui_draw.lua:2882 + [x] 55% ImTextCalcWordWrapNextLineStart imgui_draw.lua:3198 + [x] 81% ImTextClassifierClear imgui_draw.lua:3218 + [x] 53% ImTextClassifierSetCharClass imgui_draw.lua:3229 + [x] 60% ImTextClassifierSetCharClassFromStr imgui_draw.lua:3237 + [x] 88% ImTextInitClassifiers imgui_draw.lua:3255 + [x] 35% ImFontCalcWordWrapPositionEx imgui_draw.lua:3286 + [x] 93% ImFont::CalcWordWrapPosition imgui_draw.lua:3451 + [x] 49% ImFontCalcTextSizeEx imgui_draw.lua:3470 + [x] 91% ImFont::CalcTextSizeA imgui_draw.lua:3631 + [x] 85% ImFont::RenderChar imgui_draw.lua:3644 + [x] 66% ImFont::RenderText imgui_draw.lua:7123 -- ImGui Internal Render Helpers - [x] 58% ImGui::RenderArrow imgui_draw.lua:7100 - [x] 88% ImGui::RenderBullet imgui_draw.lua:7132 - [x] 66% ImGui::RenderCheckMark imgui_draw.lua:7144 - [x] 90% ImGui::RenderArrowPointingAt imgui_draw.lua:7169 + [x] 58% ImGui::RenderArrow imgui_draw.lua:7370 + [x] 88% ImGui::RenderBullet imgui_draw.lua:7402 + [x] 66% ImGui::RenderCheckMark imgui_draw.lua:7414 + [x] 90% ImGui::RenderArrowPointingAt imgui_draw.lua:7439 [x] 93% ImGui::RenderArrowDockMenu imgui.lua:4551 - [x] 100% ImAcos01 imgui_draw.lua:7182 - [x] 95% ImGui::RenderRectFilledInRangeH imgui_draw.lua:7198 - [x] 80% ImGui::RenderRectFilledWithHole imgui_draw.lua:7355 - [x] 81% ImGui::CalcRoundingFlagsForRectInRect imgui_draw.lua:7253 - [x] 79% ImGui::RenderColorRectWithAlphaCheckerboard imgui_draw.lua:7289 + [x] 100% ImAcos01 imgui_draw.lua:7452 + [x] 95% ImGui::RenderRectFilledInRangeH imgui_draw.lua:7468 + [x] 80% ImGui::RenderRectFilledWithHole imgui_draw.lua:7625 + [x] 81% ImGui::CalcRoundingFlagsForRectInRect imgui_draw.lua:7523 + [x] 79% ImGui::RenderColorRectWithAlphaCheckerboard imgui_draw.lua:7559 -- Decompression code - [ ] stb_decompress_length - [ ] stb__match - [ ] stb__lit - [ ] stb_decompress_token - [ ] stb_adler32 - [ ] stb_decompress + [x] 59% stb_decompress_length imgui_draw.lua:8085 + [x] 49% stb__match imgui_draw.lua:8093 + [x] 80% stb__lit imgui_draw.lua:8109 + [x] 50% stb_decompress_token imgui_draw.lua:8121 + [x] 34% stb_adler32 imgui_draw.lua:8142 + [x] 44% stb_decompress imgui_draw.lua:8164 -- Default font data (ProggyClean.ttf) [ ] ImGui_GetDefaultCompressedFontDataProggyClean @@ -1909,16 +1909,16 @@ imgui.h [ ] IM_MSVC_RUNTIME_CHECKS_OFF::index_from_ptr -- Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload) - [x] 80% ImGuiInputTextCallbackData::SelectAll imgui_h.lua:2518 + [x] 80% ImGuiInputTextCallbackData::SelectAll imgui_h.lua:2546 [ ] ImGuiInputTextCallbackData::SetSelection - [x] 83% ImGuiInputTextCallbackData::ClearSelection imgui_h.lua:2519 - [x] 89% ImGuiInputTextCallbackData::HasSelection imgui_h.lua:2520 - [x] 29% ImGuiWindowClass::ImGuiWindowClass imgui_h.lua:2384 - [x] 0% ImGuiPayload::ImGuiPayload imgui_h.lua:2728 - [x] 61% ImGuiPayload::Clear imgui_h.lua:2724 - [x] 55% ImGuiPayload::IsDataType imgui_h.lua:2725 - [x] 100% ImGuiPayload::IsPreview imgui_h.lua:2726 - [x] 100% ImGuiPayload::IsDelivery imgui_h.lua:2727 + [x] 83% ImGuiInputTextCallbackData::ClearSelection imgui_h.lua:2547 + [x] 89% ImGuiInputTextCallbackData::HasSelection imgui_h.lua:2548 + [x] 29% ImGuiWindowClass::ImGuiWindowClass imgui_h.lua:2412 + [x] 0% ImGuiPayload::ImGuiPayload imgui_h.lua:2756 + [x] 61% ImGuiPayload::Clear imgui_h.lua:2752 + [x] 55% ImGuiPayload::IsDataType imgui_h.lua:2753 + [x] 100% ImGuiPayload::IsPreview imgui_h.lua:2754 + [x] 100% ImGuiPayload::IsDelivery imgui_h.lua:2755 -- Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor) [ ] ImGuiOnceUponAFrame::ImGuiOnceUponAFrame @@ -1926,15 +1926,15 @@ imgui.h [x] 80% ImGuiTextFilter::Clear imgui.lua:19388 [x] 100% ImGuiTextFilter::IsActive imgui.lua:19389 [-] ImGuiTextFilter::Draw obsolete - [x] 0% ImGuiTextBuffer::ImGuiTextBuffer imgui_h.lua:2745 + [x] 0% ImGuiTextBuffer::ImGuiTextBuffer imgui_h.lua:2773 [ ] ImGuiTextBuffer::begin [ ] ImGuiTextBuffer::end - [x] 14% ImGuiTextBuffer::size imgui_h.lua:2751 - [x] 33% ImGuiTextBuffer::empty imgui_h.lua:2747 - [x] 40% ImGuiTextBuffer::clear imgui_h.lua:2746 + [x] 14% ImGuiTextBuffer::size imgui_h.lua:2779 + [x] 33% ImGuiTextBuffer::empty imgui_h.lua:2775 + [x] 40% ImGuiTextBuffer::clear imgui_h.lua:2774 [ ] ImGuiTextBuffer::resize [ ] ImGuiTextBuffer::reserve - [x] 31% ImGuiTextBuffer::c_str imgui_h.lua:2750 + [x] 31% ImGuiTextBuffer::c_str imgui_h.lua:2778 [ ] ImGuiStoragePair::ImGuiStoragePair [ ] ImGuiStorage::Clear [x] 100% ImGuiListClipper::IncludeItemByIndex imgui.lua:19619 @@ -1948,7 +1948,7 @@ imgui.h [-] operator/= c++-only [-] operator== c++-only [-] operator!= c++-only - [x] n/a IM_MSVC_RUNTIME_CHECKS_RESTORE::ImColor imgui_h.lua:2761 = setmetatable ( { } , { + [x] n/a IM_MSVC_RUNTIME_CHECKS_RESTORE::ImColor imgui_h.lua:2789 = setmetatable ( { } , { [-] IM_MSVC_RUNTIME_CHECKS_RESTORE::operatorImU32 c++-only [-] IM_MSVC_RUNTIME_CHECKS_RESTORE::operatorImVec4 c++-only [ ] IM_MSVC_RUNTIME_CHECKS_RESTORE::SetHSV @@ -1961,7 +1961,7 @@ imgui.h [x] 14% ImDrawCmd::ImDrawCmd imgui_h.lua:507 [x] 18% ImDrawListSplitter::ImDrawListSplitter imgui_h.lua:594 [-] ImDrawListSplitter::~ImDrawListSplitter c++-only - [x] 92% ImDrawListSplitter::Clear imgui_draw.lua:4196 + [x] 92% ImDrawListSplitter::Clear imgui_draw.lua:4466 [ ] ImDrawList::GetClipRectMin [ ] ImDrawList::GetClipRectMax [x] 80% ImDrawList::AddPolyline imgui_internal.lua:1089 @@ -1969,11 +1969,11 @@ imgui.h [x] 16% ImDrawList::PathLineTo imgui_internal.lua:1045 [x] 48% ImDrawList::PathLineToMergeDuplicate imgui_internal.lua:1055 [x] 94% ImDrawList::PathFillConvex imgui_internal.lua:1065 - [x] 94% ImDrawList::PathFillConcave imgui_draw.lua:7795 + [x] 94% ImDrawList::PathFillConcave imgui_draw.lua:8065 [x] 75% ImDrawList::PathStroke imgui_internal.lua:1073 - [x] 89% ImDrawList::ChannelsSplit imgui_draw.lua:4377 - [x] 80% ImDrawList::ChannelsMerge imgui_draw.lua:4378 - [x] 89% ImDrawList::ChannelsSetCurrent imgui_draw.lua:4380 + [x] 89% ImDrawList::ChannelsSplit imgui_draw.lua:4647 + [x] 80% ImDrawList::ChannelsMerge imgui_draw.lua:4648 + [x] 89% ImDrawList::ChannelsSetCurrent imgui_draw.lua:4650 [x] 16% ImDrawList::PrimWriteVtx imgui_h.lua:631 [x] 44% ImDrawList::PrimWriteIdx imgui_h.lua:641 [x] 89% ImDrawList::PrimVtx imgui_h.lua:649 @@ -1996,11 +1996,11 @@ imgui.h -- Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFontGlyphRangesBuilder, ImFont) [x] 21% ImFontGlyph::ImFontGlyph imgui_h.lua:1126 - [ ] ImFontGlyphRangesBuilder::ImFontGlyphRangesBuilder - [ ] ImFontGlyphRangesBuilder::Clear - [ ] ImFontGlyphRangesBuilder::GetBit - [ ] ImFontGlyphRangesBuilder::SetBit - [ ] ImFontGlyphRangesBuilder::AddChar + [x] 13% ImFontGlyphRangesBuilder::ImFontGlyphRangesBuilder imgui_h.lua:1150 + [x] 63% ImFontGlyphRangesBuilder::Clear imgui_h.lua:1156 + [x] 68% ImFontGlyphRangesBuilder::GetBit imgui_h.lua:1163 + [x] 51% ImFontGlyphRangesBuilder::SetBit imgui_h.lua:1165 + [x] 100% ImFontGlyphRangesBuilder::AddChar imgui_h.lua:1167 [x] 14% ImFontAtlasRect::ImFontAtlasRect imgui_h.lua:1098 [-] ImFontAtlas::SetTexID obsolete [-] ImFontAtlas::IsBuilt obsolete @@ -2014,14 +2014,14 @@ imgui.h [ ] ImDrawCmd::GetTexID -- Viewports - [x] 7% ImGuiViewport::ImGuiViewport imgui_h.lua:1491 + [x] 7% ImGuiViewport::ImGuiViewport imgui_h.lua:1519 [-] ImGuiViewport::~ImGuiViewport c++-only - [x] 90% ImGuiViewport::GetCenter imgui_h.lua:1481 - [x] 90% ImGuiViewport::GetWorkCenter imgui_h.lua:1485 + [x] 90% ImGuiViewport::GetCenter imgui_h.lua:1509 + [x] 90% ImGuiViewport::GetWorkCenter imgui_h.lua:1513 -- ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformMonitor, ImGuiPlatformImeData) - [x] 42% ImGuiPlatformMonitor::ImGuiPlatformMonitor imgui_h.lua:1585 - [x] 24% ImGuiPlatformImeData::ImGuiPlatformImeData imgui_h.lua:1391 + [x] 42% ImGuiPlatformMonitor::ImGuiPlatformMonitor imgui_h.lua:1613 + [x] 24% ImGuiPlatformImeData::ImGuiPlatformImeData imgui_h.lua:1419 -- Obsolete functions and types [-] PushFont obsolete @@ -2265,7 +2265,7 @@ imgui_internal.h -- Settings support [x] 18% ImGuiWindowSettings::ImGuiWindowSettings imgui_internal.lua:2662 [ ] ImGuiWindowSettings::GetName - [x] 13% ImGuiSettingsHandler::ImGuiSettingsHandler imgui_h.lua:2898 + [x] 13% ImGuiSettingsHandler::ImGuiSettingsHandler imgui_h.lua:2926 -- Metrics, Debug Tools [x] 7% ImGuiDebugAllocInfo::ImGuiDebugAllocInfo imgui_internal.lua:1865 @@ -2521,7 +2521,7 @@ Struct fields (name found in the port / total; missing listed). Field names are ImFontBaked 17 / 17 ImFontConfig 25 / 25 ImFontGlyph 14 / 14 - ImFontGlyphRangesBuilder 0 / 1 missing: UsedChars + ImFontGlyphRangesBuilder 1 / 1 ImFontLoader 2 / 2 ImFontStackData 3 / 3 ImGuiBoxSelectState 16 / 16 diff --git a/imgui_draw.lua b/imgui_draw.lua index fc44323..fa43184 100644 --- a/imgui_draw.lua +++ b/imgui_draw.lua @@ -888,6 +888,28 @@ function ImFontAtlasTextureBlockCopy(src_tex, src_x, src_y, dst_tex, dst_x, dst_ end end +--- @param dst_tex ImTextureData +--- @param col ImU32 +function ImFontAtlasTextureBlockFill(dst_tex, dst_x, dst_y, w, h, col) + if dst_tex.Format == ImTextureFormat.Alpha8 then + local col_a = bit32.band(bit32.rshift(col, IM_COL32_A_SHIFT), 0xFF) + for y = 0, h - 1 do + local p, base = dst_tex:GetPixelsAt(dst_x, dst_y + y) + for i = base, base + w - 1 do p[i] = col_a end + end + else + -- [Luau] Pixels is a byte table: write the 4 bytes of the little-endian ImU32 + local c0, c1, c2, c3 = bit32.band(col, 0xFF), bit32.band(bit32.rshift(col, 8), 0xFF), bit32.band(bit32.rshift(col, 16), 0xFF), bit32.band(bit32.rshift(col, 24), 0xFF) + for y = 0, h - 1 do + local p, i = dst_tex:GetPixelsAt(dst_x, dst_y + y) + for _ = w, 1, -1 do + p[i] = c0; p[i + 1] = c1; p[i + 2] = c2; p[i + 3] = c3 + i = i + 4 + end + end + end +end + -- Queue texture block update for renderer backend --- @param tex ImTextureData --- @param x int @@ -1542,6 +1564,18 @@ function ImFontAtlasBuildSetupFontBakedBlanks(atlas, baked) end end +--- @param glyph ImFontGlyph +function ImFontAtlasBakedDiscardFontGlyph(atlas, font, baked, glyph) + if glyph.PackId ~= ImFontAtlasRectId_Invalid then + ImFontAtlasPackDiscardRect(atlas, glyph.PackId) + glyph.PackId = ImFontAtlasRectId_Invalid + end + local c = glyph.Codepoint + IM_ASSERT(font.FallbackChar ~= c and font.EllipsisChar ~= c) -- Unsupported for simplicity + baked.IndexLookup.Data[c + 1] = IM_FONTGLYPH_INDEX_UNUSED + baked.IndexAdvanceX.Data[c + 1] = baked.FallbackAdvanceX +end + --- @param atlas ImFontAtlas --- @param font ImFont --- @param font_size float @@ -1700,6 +1734,11 @@ function ImFontAtlasFontDestroyOutput(atlas, font) end end +function ImFontAtlasFontRebuildOutput(atlas, font) + ImFontAtlasFontDestroyOutput(atlas, font) + ImFontAtlasFontInitOutput(atlas, font) +end + --- @param atlas ImFontAtlas --- @param src ImFontConfig --- @return boolean @@ -2586,6 +2625,32 @@ function ImFontAtlasBuildMain(atlas) atlas.TexIsBuilt = true end +-- [Luau] Ported but its call above stays disabled: the Roblox/LÖVE backends support RendererHasTextures. +function ImFontAtlasBuildLegacyPreloadAllGlyphRanges(atlas) + atlas.Builder.PreloadedAllGlyphsRanges = true + for _, font in atlas.Fonts:iter() do + local baked = font:GetFontBaked(font.LegacySize) + if font.FallbackChar ~= 0 then + baked:FindGlyph(font.FallbackChar) + end + if font.EllipsisChar ~= 0 then + baked:FindGlyph(font.EllipsisChar) + end + for _, src in font.Sources:iter() do + local ranges = src.GlyphRanges and src.GlyphRanges or atlas:GetGlyphRangesDefault() + local i = 1 + while ranges[i] ~= 0 do + local c = ranges[i] + while c <= ranges[i + 1] and c <= IM_UNICODE_CODEPOINT_MAX do + baked:FindGlyph(c) + c = c + 1 + end + i = i + 2 + end + end + end +end + ------------------------------------------------------------------------------- -- [SECTION] ImTextureData ------------------------------------------------------------------------------- @@ -2593,6 +2658,25 @@ end -- - ImTextureData:DestroyPixels() ------------------------------------------------------------------------------- +--- @param status ImTextureStatus +function ImTextureDataGetStatusName(status) + if status == ImTextureStatus.OK then return "OK" + elseif status == ImTextureStatus.Destroyed then return "Destroyed" + elseif status == ImTextureStatus.WantCreate then return "WantCreate" + elseif status == ImTextureStatus.WantUpdates then return "WantUpdates" + elseif status == ImTextureStatus.WantDestroy then return "WantDestroy" + end + return "N/A" +end + +--- @param format ImTextureFormat +function ImTextureDataGetFormatName(format) + if format == ImTextureFormat.Alpha8 then return "Alpha8" + elseif format == ImTextureFormat.RGBA32 then return "RGBA32" + end + return "N/A" +end + function MT.ImTextureData:DestroyPixels() self.Pixels = nil self.UseColors = false @@ -2629,6 +2713,74 @@ function MT.ImTextureData:Create(format, w, h) self.UpdateRect.h = 0 end +------------------------------------------------------------------------------- +-- [SECTION] ImFontAtlas: glyph ranges helpers +------------------------------------------------------------------------------- +-- - GetGlyphRangesDefault() +-- [Luau] The obsolete GetGlyphRangesXXX() (IMGUI_DISABLE_OBSOLETE_FUNCTIONS) are not ported. +------------------------------------------------------------------------------- + +-- Retrieve list of range (2 int per range, values are inclusive) +local GlyphRangesDefault = +{ + 0x0020, 0x00FF, -- Basic Latin + Latin Supplement + 0, +} +function MT.ImFontAtlas:GetGlyphRangesDefault() + return GlyphRangesDefault +end + +------------------------------------------------------------------------------- +-- [SECTION] ImFontGlyphRangesBuilder +------------------------------------------------------------------------------- + +--- @param text ImString +--- @param text_end? int # exclusive, 1-based +function MT.ImFontGlyphRangesBuilder:AddText(text, text_end) + if text_end == nil then + text_end = #text + 1 + end + local s = 1 + while s < text_end do + local c_len, c = ImStd.ImTextCharFromUtf8(text, s, text_end) + s = s + c_len + if c_len == 0 then + break + end + self:AddChar(c) + end +end + +--- @param ranges ImWchar[] # 1-based, zero-terminated +function MT.ImFontGlyphRangesBuilder:AddRanges(ranges) + local i = 1 + while ranges[i] ~= 0 do + local c = ranges[i] + while c <= ranges[i + 1] and c <= IM_UNICODE_CODEPOINT_MAX do + self:AddChar(c) + c = c + 1 + end + i = i + 2 + end +end + +--- @param out_ranges ImVector +function MT.ImFontGlyphRangesBuilder:BuildRanges(out_ranges) + local max_codepoint = IM_UNICODE_CODEPOINT_MAX + local n = 0 + while n <= max_codepoint do + if self:GetBit(n) then + out_ranges:push_back(n) + while n < max_codepoint and self:GetBit(n + 1) do + n = n + 1 + end + out_ranges:push_back(n) + end + n = n + 1 + end + out_ranges:push_back(0) +end + ------------------------------------------------------------------------------- -- [SECTION] ImFontBaked, ImFont ------------------------------------------------------------------------------- @@ -2698,6 +2850,21 @@ function MT.ImFont:ClearOutputData() self.LastBaked = nil end +-- API is designed this way to avoid exposing the 8K page size +-- e.g. use with IsGlyphRangeUnused(0, 255) +function MT.ImFont:IsGlyphRangeUnused(c_begin, c_last) + local page_begin = math.floor(c_begin / 8192) + local page_last = math.floor(c_last / 8192) + for page_n = page_begin, page_last do + if bit32.rshift(page_n, 3) < (IM_UNICODE_CODEPOINT_MAX + 1) / 8192 / 8 then -- sizeof(Used8kPagesMap) + if bit32.band(self.Used8kPagesMap[bit32.rshift(page_n, 3) + 1] or 0, bit32.lshift(1, bit32.band(page_n, 7))) ~= 0 then + return false + end + end + end + return true +end + --- @param font_id ImGuiID --- @param baked_size float --- @param rasterizer_density float @@ -2865,6 +3032,14 @@ function MT.ImFont:GetFontBaked(size, density) return baked end +-- Makes 'from_codepoint' character points to 'to_codepoint' glyph. +-- [Luau] AddRemapCodepointToGlyphIndex() not ported: needs the 1.93 loader split (FontSrcGetGlyphIndexFromCodepoint). +function MT.ImFont:AddRemapCodepoint(from_codepoint, to_codepoint) + local data = to_codepoint + IM_ASSERT(bit32.band(data, bit32.lshift(1, 31)) == 0) + self.RemapPairs[from_codepoint] = data +end + --- @param atlas ImFontAtlas --- @param font ImFont --- @param c ImWchar @@ -2872,7 +3047,7 @@ end --- @nodiscard local function ImFontAtlas_FontHookRemapCodepoint(atlas, font, c) -- IM_UNUSED(atlas) - if #font.RemapPairs > 0 then + if next(font.RemapPairs) ~= nil then -- [Luau] font->RemapPairs.Data.Size != 0 (RemapPairs is a hash table) local ret = font.RemapPairs[c] return (ret ~= nil) and ret or c end @@ -3267,6 +3442,16 @@ function ImFontCalcWordWrapPositionEx_Uncached(baked, size, text, pos, text_end, return s end +--- @param size float +--- @param text ImString +--- @param pos int # [Luau] 1-based start position (C++ 'text' pointer) +--- @param text_end int # exclusive +--- @param wrap_width float +--- @return int +function MT.ImFont:CalcWordWrapPosition(size, text, pos, text_end, wrap_width) + return ImFontCalcWordWrapPositionEx(self, size, text, pos, text_end, wrap_width, ImDrawTextFlags.None) +end + --- @param font ImFont --- @param size float --- @param max_width float @@ -3594,6 +3779,25 @@ function MT.ImFontAtlas:AddFont(font_cfg_in) return font end +-- Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder) +local stb_decompress_length +local stb_decompress +local function Decode85Byte(c) return (c >= 92) and (c - 36) or (c - 35) end -- c >= '\\' +--- @param src string +--- @param dst buffer +local function Decode85(src, dst) + local d = 0 + local src_len = #src + local s = 1 + while s + 4 <= src_len do -- [Luau] while (*src): stop at the last complete 5-char group + local b0, b1, b2, b3, b4 = string.byte(src, s, s + 4) + local tmp = (Decode85Byte(b0) + 85 * (Decode85Byte(b1) + 85 * (Decode85Byte(b2) + 85 * (Decode85Byte(b3) + 85 * Decode85Byte(b4))))) % 4294967296 + buffer.writeu8(dst, d + 0, tmp % 256); buffer.writeu8(dst, d + 1, math.floor(tmp / 256) % 256); buffer.writeu8(dst, d + 2, math.floor(tmp / 65536) % 256); buffer.writeu8(dst, d + 3, math.floor(tmp / 16777216) % 256) -- We can't assume little-endianness. + s = s + 5 + d = d + 4 + end +end + -- This duplicates some of the logic in UpdateFontsNewFrame() which is a bit chicken-and-eggy/tricky to extract due to variety of codepaths and possible initialization ordering. --- @param ctx ImGuiContext --- @return float @@ -3627,9 +3831,68 @@ function MT.ImFontAtlas:AddFontFromMemoryTTF(font_data, font_data_size, size_pix return self:AddFont(font_cfg) end --- TODO: GetDefaultCompressedFontDataProggyClean, GetDefaultCompressedFontDataProggyForever -function MT.ImFontAtlas:AddFontFromMemoryCompressedTTF() - -- TODO: +--- @param compressed_ttf_data buffer|string|ImU8[] # [Luau] stb_compress() output: buffer, string or 1-based byte table +--- @param compressed_ttf_size int +function MT.ImFontAtlas:AddFontFromMemoryCompressedTTF(compressed_ttf_data, compressed_ttf_size, size_pixels, font_cfg_template, glyph_ranges) + -- [Luau] normalize input to a buffer + if type(compressed_ttf_data) == "string" then + compressed_ttf_data = buffer.fromstring(compressed_ttf_data) + elseif type(compressed_ttf_data) == "table" then + local b = buffer.create(compressed_ttf_size) + for n = 1, compressed_ttf_size do buffer.writeu8(b, n - 1, compressed_ttf_data[n]) end + compressed_ttf_data = b + end + local buf_decompressed_size = stb_decompress_length(compressed_ttf_data) + local buf_decompressed_data = buffer.create(buf_decompressed_size) + stb_decompress(buf_decompressed_data, compressed_ttf_data, compressed_ttf_size) + + -- [Luau] FontData is a 1-based byte table (see stbtt / ImFileLoadToMemory) + local ttf_data = table.create and table.create(buf_decompressed_size) or {} + for n = 1, buf_decompressed_size do ttf_data[n] = buffer.readu8(buf_decompressed_data, n - 1) end + + local font_cfg = font_cfg_template and font_cfg_template or ImFontConfig() + IM_ASSERT(font_cfg.FontData == nil) + font_cfg.FontDataOwnedByAtlas = true + return self:AddFontFromMemoryTTF(ttf_data, buf_decompressed_size, size_pixels or 0.0, font_cfg, glyph_ranges) +end + +--- @param compressed_ttf_data_base85 string +function MT.ImFontAtlas:AddFontFromMemoryCompressedBase85TTF(compressed_ttf_data_base85, size_pixels, font_cfg, glyph_ranges) + local compressed_ttf_size = math.floor((#compressed_ttf_data_base85 + 4) / 5) * 4 + local compressed_ttf = buffer.create(compressed_ttf_size) + Decode85(compressed_ttf_data_base85, compressed_ttf) + local font = self:AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges) + return font +end + +--- @param font ImFont +function MT.ImFontAtlas:RemoveFont(font) + IM_ASSERT(not self.Locked, "Cannot modify a locked ImFontAtlas!") + + ImFontAtlasFontDestroyOutput(self, font) + for _, src in font.Sources:iter() do + ImFontAtlasFontDestroySourceData(self, src) + end + local src_n = 1 + while src_n <= self.Sources.Size do + if self.Sources.Data[src_n].DstFont == font then + self.Sources:erase(src_n) + else + src_n = src_n + 1 + end + end + + local removed = self.Fonts:find_erase(font) + IM_ASSERT(removed) + + ImFontAtlasBuildUpdatePointers(self) + + font.OwnerAtlas = nil + + -- Notify external systems + local new_current_font = nil + if self.Fonts.Size > 0 then new_current_font = self.Fonts.Data[1] end + ImFontAtlasBuildNotifySetFont(self, font, new_current_font) end function MT.ImFontAtlas:AddFontFromFileTTF(filename, size_pixels, font_cfg_template, glyph_ranges) @@ -3785,6 +4048,13 @@ function MT.ImFontAtlas:AddCustomRect(width, height, out_r) return r_id end +function MT.ImFontAtlas:RemoveCustomRect(id) + if ImFontAtlasPackGetRectSafe(self, id) == nil then + return + end + ImFontAtlasPackDiscardRect(self, id) +end + local function IM_NORMALIZE2F_OVER_ZERO(VX, VY) local d2 = VX * VX + VY * VY if d2 > 0.0 then @@ -7797,4 +8067,134 @@ function MT.ImDrawList:PathFillConcave(col) self._Path.Size = 0 end +------------------------------------------------------------------------------- +-- [SECTION] Decompression code +------------------------------------------------------------------------------- +-- Compressed with stb_compress() then converted to a C array and encoded as base85. +-- Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file. +-- The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. +-- Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h +-- [Luau] Input and output are buffers, pointers are 0-based byte offsets into them. +------------------------------------------------------------------------------- + +do +local readu8 = buffer.readu8 +local writeu8 = buffer.writeu8 + +--- @param input buffer +function stb_decompress_length(input) + return readu8(input, 8) * 16777216 + readu8(input, 9) * 65536 + readu8(input, 10) * 256 + readu8(input, 11) +end + +local stb__barrier_out_e, stb__barrier_out_b +local stb__barrier_in_b +local stb__dout +local stb__out, stb__in -- [Luau] buffers the offsets above point into +local function stb__match(data, length) + -- INVERSE of memmove... write each byte before copying the next... + IM_ASSERT(stb__dout + length <= stb__barrier_out_e) + if stb__dout + length > stb__barrier_out_e then stb__dout = stb__dout + length; return end + if data < stb__barrier_out_b then stb__dout = stb__barrier_out_e + 1; return end + if stb__dout - data >= length then -- [Luau] no overlap: block copy + buffer.copy(stb__out, stb__dout, stb__out, data, length) + stb__dout = stb__dout + length + return + end + local out = stb__out + local dout = stb__dout + for n = 0, length - 1 do writeu8(out, dout + n, readu8(out, data + n)) end + stb__dout = dout + length +end + +local function stb__lit(data, length) + IM_ASSERT(stb__dout + length <= stb__barrier_out_e) + if stb__dout + length > stb__barrier_out_e then stb__dout = stb__dout + length; return end + if data < stb__barrier_in_b then stb__dout = stb__barrier_out_e + 1; return end + buffer.copy(stb__out, stb__dout, stb__in, data, length) + stb__dout = stb__dout + length +end + +local function stb__in2(i, x) return readu8(stb__in, i + x) * 256 + readu8(stb__in, i + x + 1) end +local function stb__in3(i, x) return readu8(stb__in, i + x) * 65536 + stb__in2(i, x + 1) end +local function stb__in4(i, x) return readu8(stb__in, i + x) * 16777216 + stb__in3(i, x + 1) end + +local function stb_decompress_token(i) + local i0 = readu8(stb__in, i) + if i0 >= 0x20 then -- use fewer if's for cases that expand small + if i0 >= 0x80 then stb__match(stb__dout - readu8(stb__in, i + 1) - 1, i0 - 0x80 + 1); i = i + 2 + elseif i0 >= 0x40 then stb__match(stb__dout - (stb__in2(i, 0) - 0x4000 + 1), readu8(stb__in, i + 2) + 1); i = i + 3 + else --[[ *i >= 0x20 ]] stb__lit(i + 1, i0 - 0x20 + 1); i = i + 1 + (i0 - 0x20 + 1) + end + else -- more ifs for cases that expand large, since overhead is amortized + if i0 >= 0x18 then stb__match(stb__dout - (stb__in3(i, 0) - 0x180000 + 1), readu8(stb__in, i + 3) + 1); i = i + 4 + elseif i0 >= 0x10 then stb__match(stb__dout - (stb__in3(i, 0) - 0x100000 + 1), stb__in2(i, 3) + 1); i = i + 5 + elseif i0 >= 0x08 then stb__lit(i + 2, stb__in2(i, 0) - 0x0800 + 1); i = i + 2 + (stb__in2(i, 0) - 0x0800 + 1) + elseif i0 == 0x07 then stb__lit(i + 3, stb__in2(i, 1) + 1); i = i + 3 + (stb__in2(i, 1) + 1) + elseif i0 == 0x06 then stb__match(stb__dout - (stb__in3(i, 1) + 1), readu8(stb__in, i + 4) + 1); i = i + 5 + elseif i0 == 0x04 then stb__match(stb__dout - (stb__in3(i, 1) + 1), stb__in2(i, 4) + 1); i = i + 6 + end + end + return i +end + +--- @param buf buffer +--- @param buflen int +local function stb_adler32(adler32, buf, buflen) + local ADLER_MOD = 65521 + local s1 = adler32 % 65536 + local s2 = math.floor(adler32 / 65536) + local blocklen = buflen % 5552 + + local p = 0 + while buflen > 0 do + for _ = 1, blocklen do + s1 = s1 + readu8(buf, p); s2 = s2 + s1 + p = p + 1 + end + + s1 = s1 % ADLER_MOD; s2 = s2 % ADLER_MOD + buflen = buflen - blocklen + blocklen = 5552 + end + return s2 * 65536 + s1 +end + +--- @param output buffer +--- @param i buffer +function stb_decompress(output, i, length) + stb__in = i + if stb__in4(0, 0) ~= 0x57bC0000 then return 0 end + if stb__in4(0, 4) ~= 0 then return 0 end -- error! stream is > 4GB + local olen = stb_decompress_length(i) + stb__barrier_in_b = 0 + stb__barrier_out_e = olen + stb__barrier_out_b = 0 + stb__out = output + local p = 16 + + stb__dout = 0 + while true do + local old_p = p + p = stb_decompress_token(p) + if p == old_p then + if readu8(i, p) == 0x05 and readu8(i, p + 1) == 0xfa then + IM_ASSERT(stb__dout == olen) + if stb__dout ~= olen then return 0 end + if stb_adler32(1, output, olen) ~= stb__in4(p, 2) then + return 0 + end + return olen + else + IM_ASSERT(false) -- NOTREACHED + return 0 + end + end + IM_ASSERT(stb__dout <= olen) + if stb__dout > olen then + return 0 + end + end +end +end + return true -- [Roblox] ModuleScripts must return exactly one value diff --git a/imgui_h.lua b/imgui_h.lua index 5f7cf11..3de8e67 100644 --- a/imgui_h.lua +++ b/imgui_h.lua @@ -1138,6 +1138,34 @@ function ImFontGlyph() } end +-- Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges(). +-- This is essentially a tightly packed of vector of 64k booleans = 8KB storage. +--- @class ImFontGlyphRangesBuilder +--- @field UsedChars ImVector # Store 1-bit per Unicode code point (0=unused, 1=used) +MT.ImFontGlyphRangesBuilder = {} +MT.ImFontGlyphRangesBuilder.__index = MT.ImFontGlyphRangesBuilder + +--- @return ImFontGlyphRangesBuilder +--- @nodiscard +function ImFontGlyphRangesBuilder() + local this = setmetatable({ UsedChars = ImVector() }, MT.ImFontGlyphRangesBuilder) + this:Clear() + return this +end + +function MT.ImFontGlyphRangesBuilder:Clear() + local size_in_bytes = (IM_UNICODE_CODEPOINT_MAX + 1) / 8 + self.UsedChars:resize(size_in_bytes / 4) + local data = self.UsedChars.Data + for i = 1, self.UsedChars.Size do data[i] = 0 end +end +-- Get bit n in the array +function MT.ImFontGlyphRangesBuilder:GetBit(n) local off = bit32.rshift(n, 5); local mask = bit32.lshift(1, bit32.band(n, 31)); return bit32.band(self.UsedChars.Data[off + 1], mask) ~= 0 end +-- Set bit n in the array +function MT.ImFontGlyphRangesBuilder:SetBit(n) local off = bit32.rshift(n, 5); local mask = bit32.lshift(1, bit32.band(n, 31)); self.UsedChars.Data[off + 1] = bit32.bor(self.UsedChars.Data[off + 1], mask) end +-- Add character +function MT.ImFontGlyphRangesBuilder:AddChar(c) self:SetBit(c) end + ------------------------------------------------------------------------------- -- [SECTION] ImGuiIO ------------------------------------------------------------------------------- diff --git a/tools/test/check_all.sh b/tools/test/check_all.sh index 8104f58..baca1fc 100755 --- a/tools/test/check_all.sh +++ b/tools/test/check_all.sh @@ -25,6 +25,7 @@ CHECKS=( "dock_ini|ROUNDTRIP OK|$R --main tools/test/scripts/t_dock_ini.luau --frames 60" "dock_move|OK|$R --main tools/test/scripts/t_dock_move.luau --frames 80" "passthru|PASSTHRU OK|$R --main tools/test/scripts/t_passthru.luau --frames 40" +"fonts|FONTS OK|$R --main tools/test/scripts/t_fonts.luau --frames 8" "textproxy|PROXY OK|$R --main tools/test/scripts/t_textproxy.luau --frames 30" "style_editor|SE OK|$R --main tools/test/scripts/t_style_editor.luau --frames 20" "style_leak|STYLE OK|$R --main tools/test/scripts/t_style_leak.luau --frames 60 --open" diff --git a/tools/test/scripts/t_fonts.luau b/tools/test/scripts/t_fonts.luau new file mode 100644 index 0000000..0bd2b65 --- /dev/null +++ b/tools/test/scripts/t_fonts.luau @@ -0,0 +1,174 @@ +-- Font pieces: ImFontGlyphRangesBuilder, ImFont:CalcWordWrapPosition() vs TextWrapped(), IsGlyphRangeUnused(), +-- stb_decompress + Decode85 via AddFontFromMemoryCompressedBase85TTF() (same glyphs/metrics as the raw TTF). +local G = require(game:GetService("ReplicatedStorage"):WaitForChild("ImGui")) +local ImGui, ImVec2 = G.ImGui, G.ImVec2 +ImGui.CreateContext(); G.ImGui_ImplRoblox.Init() +local io = ImGui.GetIO() +local failed = {} +local function check(ok, msg) if not ok then table.insert(failed, msg); print("FAIL " .. msg) end end + +-- GlyphRangesBuilder +local builder = G.ImFontGlyphRangesBuilder() +builder:AddText("Hello \u{e9}") +local ranges = G.ImVector() +builder:BuildRanges(ranges) +local got = table.concat(table.move(ranges.Data, 1, ranges.Size, 1, {}), ",") +check(got == "32,32,72,72,101,101,108,108,111,111,233,233,0", "BuildRanges " .. got) +builder:Clear() +builder:AddRanges(io.Fonts:GetGlyphRangesDefault()) +builder:AddChar(0x41) -- already in range +ranges = G.ImVector(); builder:BuildRanges(ranges) +check(ranges.Size == 3 and ranges.Data[1] == 0x20 and ranges.Data[2] == 0xFF and ranges.Data[3] == 0, "AddRanges default") +check(builder:GetBit(0x20) and not builder:GetBit(0x1F) and not builder:GetBit(0x100), "GetBit") + +-- stb-compressed + base85 ProggyClean.ttf (generated with an stb_compress-format encoder + binary_to_compressed_c's base85) +local B85 = ([==[ +7])#######hV0qs#####]h?>#/:jl&Ql#v#[Zre=N=K_o(-(##mQ%##B>A0F_%#g(g/'##r[(##PF6'I>#'####<_[FH +O97MKO->>#i6YY#i1JuB5eI`[VRUV$=.>#K####+>00FnH/5`S7g1TS->>#k%S+Hot3>MYJGiTLPUV$>eFVCUwS>#9G:;$n%###Sh(a1aA.;6BE-hAeI1=#au8eZ2D$CI[Mn20Gb?=iMPrIL +DSGkFI5>##Q+`AMB%]`ac<%##CFgn*$<,;.OOMDgEKnIS7EM9>ZoSAZ$*3)qMQv//L^MkA#wmCAMUnG<-7F>HM +DHw>Pt*p+M[ul=QY^Y&2wbq& +TB-K'@IZC'%]#V'Uv'n'[R%1(D6?c(OD1$)e>Lr(Z*24)C5Yb)R/uY)#PPj)uaFu)pEt**@7KY*jO*dskh5??pb?^Y44[W7m@O9&/?o&YNgT?-'aPdsd(-qA0[9_#WMT9AcO#wm%e;e3?oWq/R1,XIghlWnL4mEX_v(R^+$4:A6.*x6Y+w_,ED)`, +PIDRpbf::fN$F.N4Bv:/>80xm6wgLiuWsFXrv)AHt/sl19::#%T1?Ynm49;SFb8/N7n.a>$P%O)]J/0j$)macqO]pg2V2u$&t@##5f1$# +E@%%#Uqn%#fKb&#v&U'#0WH(#@2<)#Pc/*#a=#+#qnl+#+I`,#;$S-#KTF.#[/:/#l`-0#&;w0#6lj1#oiFJ('Moe2;4HZ$mgfX-b/g/HIt71#DRTPn<<>P0]15/$[K$?:b1#^QZ`*uqmV-8lt.ZRwbVRqjtH*PhBQ(-t]N-0*aYMiEVq7a=W4#`6_c)$/*JL(L-^(]$wIMlcs(UsvHv,,rbA#/2u]O +hdcHMucWU-k^n:$VGR;oFHnq7e(Q&#uDdE&];bLcqC/^daSxFNtTGw.P3w.Ln1k,O7$22%r]2U%qS#n8as:jrQ=$##/)>uuN?Sq7^fV2ivEjJN-MT;-UJ;QMM=6##Cni&O1/Ut'7#[UN>+]K3M@2+8UkW1#k.WUN4DU;-j8(1$)[888aOHpgh<7r7#n8I?%R7p7tGF]u%OtlSE4$##6We'8SdfFI +WVZ>nZ6c8MPhc(.i10p7x0'.=;lxb-4r'E>qC0%%?].e;I#72LclTAO0qD>$Vvnq2h^fW-LL4OiYW-mNFJuH&O(35&85c58@Y31#_Lx-[?u>q7:5i8K5(;mOM8#=Q'`+%&7'6i#BtxA?0KPM-1PHM&/esr7gC>B$1wGJ(>Q5t7]#:xT:tl.$Tvx;-%&26&`JT58^V_,FWN-c0F####HSI@1K<8FN&?bO'2[IfM +j'YWN,et`e;)LBf68(24gj1WXW'afQfFv7V.8R02?[LUlDN3cha'&]T&#b96$2*T5s7L5jv[&tsR%3dG2M0.(58=RK=`37;ENkWl9)Y7dp7v_k;fk&Z31P>5r'ZC$M&7&i)5SkFGm;i'72Ljb]1#+BcK:Fgs.F8`aBNT($28/7*.H1GrvqoTa2`b:EO-=sKj9 +crw0#.4D.M(sm;51/tW8Y@@S/#1jn8BZT/-Y,lJa-2Ht$i=(HMv'(P8Y>4AuNb6j9hP6(d?^OE23bsR&ZePWV&-=i>RM-']:uc%4;r>8R$tZgSN$fo1#8&n/;%G7@[Jf4x+.bjq7rlBEYk>h-%(X8j9VCxj2OM:/1_>qs7fEt-$n17tQE&9A.S+Ne+3]a:%$MLp7t]Wx'>3Ks7wtpDP.%L)$Q]BDN +NOZf:iskA#j:8T@)BC[.<2N=8c4G`&EW@$%,m/:PIh)PEq3:+x&'-t0sc;>[:Q-;4*88df9dk@]?Y'/ehS@A:R&m2_(:)QYJwTme-LEcuko$4B:T1=^J$&2(+@-]Ziu,ae_-tbUGDN`-Ra$;hhjW/v[lA3pKq^ +H<;&(8#DwP3c)/-SoDu7GaHQ:AX=W%+7k,4dQ,N11A>2Bv%03M_/wU&oNi5A)(&3MslOf-.brg=5SHx#7jg]O.F`c)6jK788At1#UfqV-`K<=ijV +anS,,diDack,uG%(q-&>^Ep&?uTh&UIULu:N*DkDaoK>0T>R@@ho/P+uw^$r?%=FY%8=cFU_Kffo7m-u8NI/5'$NF81.taNq7)?Kq^T+DB)Wg>jV +(ckS*I,1qAb-ZQS/U@)2.KDgU#Kk95sor>e@>(QYI<%Z*uB-x0*0K39$uQRX^T]M9_U?^?XD-:8t`MqM0pLP9BmS6(xp?e9dca,bq<3K*^w@T[ +bub7%Vu;S8/G5F%0'8rVUDCnNj9%dMllOf-B)(Wf2(73)oGHH;IoZp0Q1Gp7%Wc&#v6D39^P()HBs(2';aFq72v6b6P77'&h2da6Rm3/Zt8#QHo4`)XmW7h'<>e+2NgM9dboLavtx$$ +KIK$>1fAoU4NP^0whIt7^iWx''x:Q:`PRB$lhV29)-.K<)dFu3^;mU8UO1S*KTJ/M$=Iw3qi6JN4AFoOalkGNhxNv'HM)?-0(Oh;0:aJsj[lT'5kWm83sdC%hHV7;LSbPxwh9. +L,hs7Elx2)+C30*5d'q7#L?T0W#H^Zths.L2*578H]]^-nO,X&2/Z&FM9%%B8&E#>OgR?RC5'T*;Xx9RhdA7(L01H;Pk1NV87(p7Qd41#fFQ;-xe=C$uf['$C+RPs51b-<8x.4rJ;pt-aA,q7Z6QYq]s/FN6PT[% +gdf68Omx0#HA2s-tGPSIU*@w^dr,X/kJm;?T$dF#IwGP$hn1a*]p7,M.S?M9a$nx0;,Gp74,IpgKNdm'@Bt784N&:DUix*=bc^_sR8w[gJj7*:6:5`)QLb:^i?lw%rMgu>q78aq5M?^w>%IVPp7M8td=/H+s7>&d:;k:&qK=?ex%a*sYPO[+<%&K2;8;fD.$Wk@vPTlC:R +,9R>%-u#6AQ]m&6e32?%THYs%m-n58^<(0E=f2#$wonB$QB]m8R(7mMSpse*)jK29*O$90+$bk)VgB^m/i9R$)8LV4iPpdFBFX)-Q6s58&a3dX&TB59&@_[KAuJmSp13/%8Pp'5D2ZJ:j3:`f+5d+Nc2r.([59p7 +6A#'v>J6u'm[2Q8CS+5rbs14$nK%B>m%6Q:`%P1):BA*N1a-A)96D3#1TCt7#IgE#U/VR=`(qQ(U:c58:RRPDZ+,58@`EdtKP>[PQd/,M9u#>9d*-g)&%B@-j<1e(>ih29via.-S?5`8FO:;B&?ch'PMk8@YG@*n +P@st7QGt-$,``wP[ZNC(uTEq70l)?[nS$i$FKgS8jJN9Bp'CUH-MgU,3D7)D_0'?D_=g>d&QMFJk*7&Pp7Gt3[T +TwY+Y0v2o0DvI^#s-%g:26KE>o_`h*%L^VH1LbC=3;xji-O7r'Lf7KW4N+[&i7PW87O,i8DUjTBFRS?$UG1o*(VRd;4QG1#mpl%$>iraIcDKQ(d%g4(L@Q.Mv?^O&gCAr7t$.Ae*b8k&;1=6`d=_d'-05fD.D)E. +uFxZ(d4vQ8.(J(8.%NX-X3RpK:'oLabx4I-1q.:)0..,umo%x+B7$S)0p71m99pnERN93)9I$)#(IM_Yd>#6x;XCg]5<-3efW85,/n1#S]C'qqvcD2n4`8u9j<-E`Y%&`Qhg*tt2e$N$t49<#oW&^a*@,$^^dk7xK)$GJP/M>KO0&ND_j9>>P&#JuF.3 +SI:OPE*XF>dOo#P-(I7Vj;vrlm968R,tB,cS(]FeW&&O`9$-L-5#aS-Ak*o#iSuvYmTPpq9&E*n&%lBap7aS=r7jnP7Ah-]pK>xo_N]mjvPjtJ.2/*'W$4BFQ8bN((&WpULN`$^3i'@+G%.[#.$_6>3)jr[PA +&Wp5Uk_uk%Hk@bNH`(S%T)p/MdebV$4iQr7(QMG%k%8bRfU/L.bn/mSCf>SI$`G%h9JSpB%>xsF,^-Ehgn*Q8&j]K@wMQh=6)m$1_b-;I?Q5;7>`*6lg3G;sv&:`[JLN9wgr'mKDKNrkdkasN/x0,l$q71^?Xh*X[8^PL*q%6cv58_S*1# +bX`0MITc080x^@ilsnlf[L7I%(3mLC(BZE5+?,P@)$+1#DqsJaN-U:/-u?68)p<9j7E%>i?Ia;-kH/D,v(mn8=0'.$Nu49@Bm*1#XYs5CvbQa86j-bS`c5m8RiE1#4l^&#pCa$UOs068Z1-E5RhYl$Oh%TW*)LTA +.#$]UnM;TK9(Dl%8`?6B6E>WgZ3of$O1Up@XbS2L[OtL:aqtqK:M2j*_@-:)LF5F%sd40:3Fr_&]?'k9W@dFuw&hMM8Ia^vr'sj#j1>f:^OuVh29)g09Tq-.78(S%?7NCU29fbbgNaEJ)7rU2`cGs_*,K)1#FCR(Q=Q7i8sDwUjLe.0M2('B$dwW88%vrv@bNOG%K8tMB`6XF-:/::;-:`6r0U=0$``Xp9Knp*-cUpeHl%w,;s+e<_3cs?-#s&r0 +1B^]02M(wYNshr00dW_ZG]0a;Gx4ND*&9;-HM%VqIL6GDsDZki/S0K)KF,:pgT4,%4K]dM*x8h8WVl6`g#gG$mhmF,,i2v*wBS1MFM0`&,:PP:[J'LPk%']h5(Wxd>i9UXuQk&18(&H;%Ug'hT6Sv_Q93J04r7<,vNP%2d97xbEgJKQGVgB#r3 +FO4;89*^EfckAhDPC)c<6v690M?r&(GDc^$Ki+58v&LnF)iRTRpw<8Up^,(dPss3,0Z)kT#1i]$-KIZ7LI)3S`ig1(p^^URhRi*N,%$c4L4udO(jG9%[vg2V7I(e&NYhMBQ4T:r2`e0l:lJB$h +.`Pg+e]wY%jfNf$)']6K8lDKaC90I.p<3q7dQtA`Q`5?`(qQvc_6b,3O3)9gwixH-]$SR8vjMhdwMD$[V3xR&vCIpT$Vbk1f=RRblisvHe#Zq9Ske(9iR6XLQES29JsZIM-2>rDjiGr^89KO0-^'q718r_&61D58 +w+r_&.lCW/6iG<-`*wQ%8DQ^OmBjE%9X`E.1EDS@#j/q'J5x8-cxfJssL4($Uflq7hxad=4O:C4K9+hER0^F9G+UQc8W:uQ&/0'IAOl%4a*0Y^GM#RcGM9#ult_Ks$#B@`T.1rC$#`@`T.,Mc##T@`T.74i$# +WrG<-N2:W.2`($#irG<-@nuc<)0o6D]bdUCFdg+>?Wae3;BR12A::MB +h]8;-?(DYGUq`uGNDw1B];8;-SHpw'r?Z.#K0f-#=ic+#En82'B0pi'FHPJ( +Ja1,)N#ic)R;ID*VS*&+Zla]+_.B>,cF#v,_REmh1W@`$0u68%47no%8ONP&,a@pu,eXPV-iq18.m3io.qKIP/ud*20#'bi0'?BJ19if,=(N^o232;D3 +7Jr%4;cR]4?%4>5C=ku5GUKV6Kn,87O0do7SHDP8Wa%29[#]i9`;=J:dSt+;hlTc;l.6D>&:fu>*RFV?.k'8@2-_o@6E?PA:^v1Bikur-m-VS.qE75/u^nl/#wNM0'90/1+Qgf1/jGG23,))3 +7D``3;]@A4?uwx4C7XY5GO9;6Khpr6O*QS7hPn:ZKe0GMgc>c`Mq&Sn8h?YPLS-JUrBB`WH+,AO,Wm+MTm6fqOR(>PCeG`NqHn@k_;LfUox3creaQ(st)7VZ`5Quc4R>MBmeu:QS(f7eQfi:di++PfiuIoe1#Don +^w>igqOb1g:-r+DPn?VQ$(_.hbS8GDRI]1pm*m(EM(1DER=L`E2m(GVYq)>G['EYGbKAVHdW]rH0%]4ol2u4Jn>:PJsSUlJ(UFcVwl6MK%53JLTUxLpbwnWH#N#hF@0*K2,4IL2fCd<-gCd<-hCd<-iCd<-jCd<- +kCd<-lCd<-mCd<-nCd<-@Dd<-ADd<-BDd<-CDd<-DDd<-EJ)X-v0P]'Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2Gt.g2TmOh2Y#oTC$NXVCThmfGY4&>-K*IT-K*IT-K*IT- +K*IT-K*IT-K*IT-K*IT-K*IT-K*IT-K*IT-K*IT-K*IT-K*IT-K*IT-18ZI'Et,gjm,(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DPO/(DP+-XlC#m8Atkt>Ns +]==]):gsub("\n", "") + +local raw_data, raw_size = G.ImStd.ImFileLoadToMemory("fonts/ProggyClean.ttf", "rb") +local raw = io.Fonts:AddFontFromMemoryTTF(raw_data, raw_size, 13.0) +local comp = io.Fonts:AddFontFromMemoryCompressedBase85TTF(B85, 13.0) +check(comp ~= nil, "AddFontFromMemoryCompressedBase85TTF returned nil") +local comp_data = comp.Sources.Data[1].FontData +local same = comp.Sources.Data[1].FontDataSize == raw_size +for n = 1, raw_size do if not same then break end same = comp_data[n] == raw_data[n] end +check(same, "decompressed bytes differ from fonts/ProggyClean.ttf") + +local TEXT = "The quick brown fox jumps over the lazy dog again and again" +local W = 100 +local f = 0 +game:GetService("RunService").Stepped:Connect(function() + f += 1 + G.ImGui_ImplRoblox.NewFrame() + ImGui.NewFrame() + ImGui.SetNextWindowPos(ImVec2(10, 10)); ImGui.SetNextWindowSize(ImVec2(400, 300)) + ImGui.Begin("Fonts") + ImGui.PushFont(raw, 13.0) + ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + W) + ImGui.TextWrapped(TEXT) + local wrapped_h = ImGui.GetItemRectSize().y + ImGui.PopTextWrapPos() + local line_h = ImGui.GetTextLineHeight() + ImGui.PopFont() + if f <= 3 then + ImGui.PushFont(comp, 13.0) + ImGui.Text("Hello \u{e9}") + ImGui.PopFont() + end + ImGui.End() + ImGui.Render(); G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData()) + + if f == 3 then + -- CalcWordWrapPosition(): same line breaks as TextWrapped(). ProggyClean 13px = 7px per char -> 14 chars per 100px line + local te = #TEXT + 1 + local s, lines, breaks = 1, 0, {} + while s < te do + local e = raw:CalcWordWrapPosition(13.0, TEXT, s, te, W) + lines += 1; table.insert(breaks, e) + s = e + while s < te and TEXT:sub(s, s) == " " do s += 1 end -- ImTextCalcWordWrapNextLineStart(): skip blanks + end + check(breaks[1] == 10, "first wrap after 'The quick': " .. tostring(breaks[1])) -- "The quick" | "brown fox" | ... + check(TEXT:sub(11, breaks[2] - 1) == "brown fox", "second line '" .. TEXT:sub(11, breaks[2] - 1) .. "'") + check(wrapped_h == lines * line_h, ("TextWrapped height %s vs %d lines * %s"):format(wrapped_h, lines, line_h)) + + -- Compressed font: same glyphs and metrics as the raw TTF + local br, bc = raw:GetFontBaked(13.0), comp:GetFontBaked(13.0) + check(br.Ascent == bc.Ascent and br.Descent == bc.Descent, "ascent/descent") + for _, c in { 0x48, 0x65, 0x6C, 0xE9, 0x41, 0x7E } do + local gr, gc = br:FindGlyph(c), bc:FindGlyph(c) + check(gc.Visible and gc.X1 > gc.X0 and gc.Y1 > gc.Y0, "compressed glyph empty " .. c) + check(gr.AdvanceX == gc.AdvanceX and gr.X0 == gc.X0 and gr.Y0 == gc.Y0 and gr.X1 == gc.X1 and gr.Y1 == gc.Y1, "glyph metrics " .. c) + end + local str = "Hello \u{e9}" + local sr, sc = raw:CalcTextSizeA(13.0, 1e30, 0, str, 1, #str + 1), comp:CalcTextSizeA(13.0, 1e30, 0, str, 1, #str + 1) + check(sr.x == sc.x and sr.y == sc.y and sc.x > 0, "CalcTextSizeA") + check(not comp:IsGlyphRangeUnused(0, 255) and comp:IsGlyphRangeUnused(0x4E00, 0x9FFF), "IsGlyphRangeUnused") + + -- AddRemapCodepoint(): '$' loads the 'A' glyph (applies to glyphs loaded afterwards: new 20px baked) + comp:AddRemapCodepoint(0x24, 0x41) + local b20 = comp:GetFontBaked(20.0) + local gd, ga = b20:FindGlyph(0x24), raw:GetFontBaked(20.0):FindGlyph(0x41) + check(gd.X0 == ga.X0 and gd.Y0 == ga.Y0 and gd.X1 == ga.X1 and gd.Y1 == ga.Y1, "AddRemapCodepoint") + + -- RemoveCustomRect() + local atlas = io.Fonts + local id = atlas:AddCustomRect(8, 8) + check(atlas:GetCustomRect(id, G.ImFontAtlasRect()) == true, "AddCustomRect") + atlas:RemoveCustomRect(id) + check(not atlas:GetCustomRect(id, G.ImFontAtlasRect()), "RemoveCustomRect") + + -- RemoveFont() + local nfonts, nsrc = atlas.Fonts.Size, atlas.Sources.Size + atlas:RemoveFont(comp) + check(atlas.Fonts.Size == nfonts - 1 and atlas.Sources.Size == nsrc - 1 and not atlas.Fonts:contains(comp), "RemoveFont") + + -- ImFontAtlasTextureBlockFill(), ImTextureDataGetXXXName() + local tex = G.ImTextureData(); tex:Create(G.ImTextureFormat.RGBA32, 4, 4) + G.ImFontAtlasTextureBlockFill(tex, 1, 2, 2, 1, G.IM_COL32(1, 2, 3, 4)) + local px = table.concat(tex.Pixels, ",", 33, 48) + check(px == "0,0,0,0,1,2,3,4,1,2,3,4,0,0,0,0" and tex.Pixels[29] == 0 and tex.Pixels[53] == 0, "TextureBlockFill " .. px) + check(G.ImTextureDataGetStatusName(tex.Status) == "WantCreate" and G.ImTextureDataGetFormatName(tex.Format) == "RGBA32", "texture names") + end + if f == 5 and #failed == 0 then print("FONTS OK") end +end)