Rename table unicode_text to rp_unicode_text

This commit is contained in:
Wuzzy 2024-11-22 18:08:06 +01:00
parent 3d587e3b48
commit 30ecccba5a
9 changed files with 20 additions and 20 deletions

View File

@ -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)

View File

@ -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") )

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -4,7 +4,7 @@
dofile("init.lua")
dofile("../tga_encoder/init.lua")
font = unicode_text.hexfont(
font = rp_unicode_text.hexfont(
{
kerning = true,
}

View File

@ -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 },

View File

@ -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

View File

@ -198,4 +198,4 @@ assert(
table.concat(codepoints, " ") == "119 240 9829 66376"
)
unicode_text.utf8 = utf8
rp_unicode_text.utf8 = utf8