From 8fa83824085b46ccec10e4d54643f1219482d5d8 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 15 Mar 2023 16:56:11 +0100 Subject: [PATCH] * Rename render_utf8_text() to render_text() This patch also un-exposes render_utf8_line(). --- examples.lua | 20 ++++++++++---------- hexdraw.lua | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples.lua b/examples.lua index a7bde53..fd9558f 100755 --- a/examples.lua +++ b/examples.lua @@ -55,18 +55,18 @@ print_bitmap(bitmap_1) print("---") -- everything looks like U+FFFD REPLACEMENT CHARACTER without fonts -text_bitmap_0 = hexdraw.render_utf8_line("wð♥𐍈😀!🂐겫") +text_bitmap_0 = hexdraw.render_text("wð♥𐍈😀!🂐겫") print_bitmap(text_bitmap_0) print("---") hexdraw.load_hex_font("/usr/share/unifont/unifont.hex") hexdraw.load_hex_font("unifont_upper.hex") -text_bitmap_1 = hexdraw.render_utf8_line("wð♥𐍈😀!🂐겫") +text_bitmap_1 = hexdraw.render_text("wð♥𐍈😀!🂐겫") print_bitmap(text_bitmap_1) print("---") -text_bitmap_2 = hexdraw.render_utf8_line( +text_bitmap_2 = hexdraw.render_text( "wð♥𐍈😀!🂐겫", { background_color = { 7 }, @@ -77,7 +77,7 @@ text_bitmap_2 = hexdraw.render_utf8_line( print_bitmap(text_bitmap_2) print("---") -text_bitmap_3 = hexdraw.render_utf8_line( +text_bitmap_3 = hexdraw.render_text( "wð♥𐍈😀!🂐겫", { background_color = { 7 }, @@ -96,15 +96,15 @@ tga_encoder.image(text_bitmap_1):save( "text_bitmap_1.tga", { colormap = { - { 255, 127, 000 }, - { 000, 127, 255 }, + [0]={ 255, 127, 000 }, + [255]={ 000, 127, 255 }, } } ) -- R8G8B8A8 compressed image tga_encoder.image( - hexdraw.render_utf8_line( + hexdraw.render_text( "wð♥𐍈😀!🂐겫", { background_color = { 0, 0, 0, 0 }, @@ -122,7 +122,7 @@ tga_encoder.image( -- uncompressed grayscale image tga_encoder.image( - hexdraw.render_utf8_line( + hexdraw.render_text( "wð♥𐍈😀!🂐겫", { background_color = { 0 }, @@ -144,7 +144,7 @@ file:close() print(text) -- render text (RGB, white-on-black) -local pixels = hexdraw.render_utf8_text( +local pixels = hexdraw.render_text( text, { background_color = { 000, 000, 000 }, @@ -186,7 +186,7 @@ local file = io.open("UTF-8-demo.txt") local text = file:read("*all") file:close() -local pixels = hexdraw.render_utf8_text(text) +local pixels = hexdraw.render_text(text) -- tga_encoder uses grayscale colors if no colormap is given tga_encoder.image(pixels):save("UTF-8-demo.tga") diff --git a/hexdraw.lua b/hexdraw.lua index 2373e76..00d070d 100755 --- a/hexdraw.lua +++ b/hexdraw.lua @@ -345,7 +345,7 @@ assert( nil == is_combining_character["00F0"] ) assert( nil == is_combining_character["2665"] ) assert( nil == is_combining_character["010348"] ) -hexdraw.render_utf8_line = function(utf8_text, properties) +local render_utf8_line = function(utf8_text, properties) assert( "string" == type(utf8_text) ) @@ -440,7 +440,7 @@ hexdraw.render_utf8_line = function(utf8_text, properties) return result end -hexdraw.render_utf8_text = function(utf8_text, properties) +hexdraw.render_text = function(utf8_text, properties) local properties = properties or {} assert( "table" == type(properties) @@ -462,7 +462,7 @@ hexdraw.render_utf8_text = function(utf8_text, properties) local result -- TODO: implement UAX #14 for utf8_line in string.gmatch(utf8_text .. "\n", "([^\n]*)\n") do - local pixels = hexdraw.render_utf8_line( + local pixels = render_utf8_line( utf8_line, properties )