From 30ecccba5aac6e4e04800f993b28507a635cc752 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 22 Nov 2024 18:08:06 +0100 Subject: [PATCH] Rename table unicode_text to rp_unicode_text --- mods/rp_signs/init.lua | 4 ++-- mods/rp_unicode_text/README.rst | 10 +++++----- mods/rp_unicode_text/hexfont.lua | 12 ++++++------ mods/rp_unicode_text/init.lua | 2 +- mods/rp_unicode_text/luabidi/bidi.lua | 2 +- mods/rp_unicode_text/screenshot.lua | 2 +- mods/rp_unicode_text/test.lua | 4 ++-- mods/rp_unicode_text/unicodedata.lua | 2 +- mods/rp_unicode_text/utf8.lua | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mods/rp_signs/init.lua b/mods/rp_signs/init.lua index 6044cc30..0d17be05 100644 --- a/mods/rp_signs/init.lua +++ b/mods/rp_signs/init.lua @@ -35,7 +35,7 @@ local META_IMAGE_EMPTY = "!" -- Load font -local font = unicode_text.hexfont({ +local font = rp_unicode_text.hexfont({ background_color = { 0, 0, 0, 0 }, --transparent -- Note: This color will be inverted on signs that are painted black foreground_color = { 0, 0, 0, 255 }, -- black @@ -494,7 +494,7 @@ local function crop_text(txt) if not txt then return "" end - return unicode_text.utf8.crop_text(txt, SIGN_MAX_TEXT_LENGTH) + return rp_unicode_text.utf8.crop_text(txt, SIGN_MAX_TEXT_LENGTH) end -- Formspec pages for sign (different background textures) diff --git a/mods/rp_unicode_text/README.rst b/mods/rp_unicode_text/README.rst index 4b0c2673..7f25e2c5 100644 --- a/mods/rp_unicode_text/README.rst +++ b/mods/rp_unicode_text/README.rst @@ -37,7 +37,7 @@ If you are impatient, just copy and paste the following example code: .. code:: - local font = unicode_text.hexfont() + local font = rp_unicode_text.hexfont() font:load_glyphs(io.lines("unifont.hex")) font:load_glyphs(io.lines("unifont_upper.hex")) local pixels = font:render_text("wð♥𐍈😀!🂐겫") @@ -57,13 +57,13 @@ To create a hexfont table with default parameters, do: .. code:: - font = unicode_text.hexfont() + font = rp_unicode_text.hexfont() The above code is equivalent to the following code: .. code:: - font = unicode_text.hexfont( + font = rp_unicode_text.hexfont( { background_color = { 0x00 }, foreground_color = { 0xFF }, @@ -130,7 +130,7 @@ The above code writes an uncompressed 80×16 grayscale bitmap. Pixels Tables +++++++++++++ -Pixels tables represent output rendered by `unicode_text`. +Pixels tables represent output rendered by `rp_unicode_text`. Pixels tables contains tables that represent scanlines. @@ -442,7 +442,7 @@ writes an uncompressed 8bpp grayscale TGA file with 632 × 3408 pixels: .. code:: - font = unicode_text.hexfont() + font = rp_unicode_text.hexfont() font:load_glyphs( io.lines("unifont.hex") ) font:load_glyphs( io.lines("unifont_upper.hex") ) diff --git a/mods/rp_unicode_text/hexfont.lua b/mods/rp_unicode_text/hexfont.lua index 34429f92..dc23f53c 100644 --- a/mods/rp_unicode_text/hexfont.lua +++ b/mods/rp_unicode_text/hexfont.lua @@ -252,13 +252,13 @@ hexfont.render_line = function(self, text) for i = 1, 16 do result[i] = {} end - local codepoints = unicode_text.utf8.text_to_codepoints(text) + local codepoints = rp_unicode_text.utf8.text_to_codepoints(text) if ENABLE_BIDI then - codepoints = unicode_text.bidi.get_visual_reordering(codepoints) + codepoints = rp_unicode_text.bidi.get_visual_reordering(codepoints) end for i = 1, #codepoints do local codepoint = codepoints[i] - local ucdata = unicode_text.unicodedata[codepoint] + local ucdata = rp_unicode_text.unicodedata[codepoint] local bitmap_hex = self[codepoint] -- use U+FFFD as fallback character if nil == bitmap_hex then @@ -325,7 +325,7 @@ hexfont.render_text = function(self, text) local result local max_width = 0 - local codepoints = unicode_text.utf8.text_to_codepoints(text) + local codepoints = rp_unicode_text.utf8.text_to_codepoints(text) -- According to UAX #14, line breaks happen on: -- • U+000A LINE FEED @@ -358,7 +358,7 @@ hexfont.render_text = function(self, text) -- FIXME: Code below should only operate on codepoints! Converting -- back and forth makes it needlessly slow – but I do not know how -- to split a table properly to get a single table for each line … - text = unicode_text.utf8.codepoints_to_text(codepoints) + text = rp_unicode_text.utf8.codepoints_to_text(codepoints) local utf8_lines = string.split(text, "\n", true) for _, utf8_line in pairs(utf8_lines) do local pixels = self:render_line(utf8_line) @@ -394,4 +394,4 @@ hexfont.render_text = function(self, text) return result end -unicode_text.hexfont = hexfont +rp_unicode_text.hexfont = hexfont diff --git a/mods/rp_unicode_text/init.lua b/mods/rp_unicode_text/init.lua index 0d7675e4..ad43d494 100644 --- a/mods/rp_unicode_text/init.lua +++ b/mods/rp_unicode_text/init.lua @@ -14,7 +14,7 @@ Overflow oder eine Format String Vulnerability zwischen die anderen Codezeilen und schreibe das auch nicht dran. ]]-- -unicode_text = {} +rp_unicode_text = {} local modpath = minetest and minetest.get_modpath and diff --git a/mods/rp_unicode_text/luabidi/bidi.lua b/mods/rp_unicode_text/luabidi/bidi.lua index e663ec2a..ea4cce1b 100644 --- a/mods/rp_unicode_text/luabidi/bidi.lua +++ b/mods/rp_unicode_text/luabidi/bidi.lua @@ -1444,4 +1444,4 @@ bidi.BIDI_CLASS_FSI = FSI -- @field bidi.BIDI_CLASS_PDI bidi.BIDI_CLASS_PDI = PDI -unicode_text.bidi = bidi +rp_unicode_text.bidi = bidi diff --git a/mods/rp_unicode_text/screenshot.lua b/mods/rp_unicode_text/screenshot.lua index f0776e91..64b55cb4 100644 --- a/mods/rp_unicode_text/screenshot.lua +++ b/mods/rp_unicode_text/screenshot.lua @@ -4,7 +4,7 @@ dofile("init.lua") dofile("../tga_encoder/init.lua") -font = unicode_text.hexfont( +font = rp_unicode_text.hexfont( { kerning = true, } diff --git a/mods/rp_unicode_text/test.lua b/mods/rp_unicode_text/test.lua index 3c46918b..5cc31e2b 100644 --- a/mods/rp_unicode_text/test.lua +++ b/mods/rp_unicode_text/test.lua @@ -4,7 +4,7 @@ dofile("init.lua") dofile("../tga_encoder/init.lua") -font_1 = unicode_text.hexfont( +font_1 = rp_unicode_text.hexfont( { kerning = true, } @@ -28,7 +28,7 @@ local pixels = font_1:render_text(text) local image = tga_encoder.image(pixels) image:save("test.tga") -font_2 = unicode_text.hexfont( +font_2 = rp_unicode_text.hexfont( { background_color = { 1 }, foreground_color = { 0 }, diff --git a/mods/rp_unicode_text/unicodedata.lua b/mods/rp_unicode_text/unicodedata.lua index e51d4520..80f3a89c 100644 --- a/mods/rp_unicode_text/unicodedata.lua +++ b/mods/rp_unicode_text/unicodedata.lua @@ -139,4 +139,4 @@ assert( "Latin" == w.script) w = unicodedata[0x00AD] -- SOFT HYPHEN assert( true == w.default_ignorable_codepoint) -unicode_text.unicodedata = unicodedata +rp_unicode_text.unicodedata = unicodedata diff --git a/mods/rp_unicode_text/utf8.lua b/mods/rp_unicode_text/utf8.lua index 620dad24..c914446b 100644 --- a/mods/rp_unicode_text/utf8.lua +++ b/mods/rp_unicode_text/utf8.lua @@ -198,4 +198,4 @@ assert( table.concat(codepoints, " ") == "119 240 9829 66376" ) -unicode_text.utf8 = utf8 +rp_unicode_text.utf8 = utf8