From 46d2ce085ea47f7f9b86ec74858c6cc1317b04a6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Rollo Date: Tue, 19 Dec 2017 21:52:49 +0100 Subject: [PATCH] Multiple fonts and UTF chars support --- README.md | 10 + font_lib/API.md | 57 ++++- font_lib/README.md | 4 +- font_lib/font_default.lua | 12 + font_lib/init.lua | 241 ++++++++++++------ ...{font_lib_00.png => font_default_0000.png} | Bin ...{font_lib_20.png => font_default_0020.png} | Bin ...{font_lib_21.png => font_default_0021.png} | Bin ...{font_lib_22.png => font_default_0022.png} | Bin ...{font_lib_23.png => font_default_0023.png} | Bin ...{font_lib_24.png => font_default_0024.png} | Bin ...{font_lib_25.png => font_default_0025.png} | Bin ...{font_lib_26.png => font_default_0026.png} | Bin ...{font_lib_27.png => font_default_0027.png} | Bin ...{font_lib_28.png => font_default_0028.png} | Bin ...{font_lib_29.png => font_default_0029.png} | Bin ...{font_lib_2a.png => font_default_002a.png} | Bin ...{font_lib_2b.png => font_default_002b.png} | Bin ...{font_lib_2c.png => font_default_002c.png} | Bin ...{font_lib_2d.png => font_default_002d.png} | Bin ...{font_lib_2e.png => font_default_002e.png} | Bin ...{font_lib_2f.png => font_default_002f.png} | Bin ...{font_lib_30.png => font_default_0030.png} | Bin ...{font_lib_31.png => font_default_0031.png} | Bin ...{font_lib_32.png => font_default_0032.png} | Bin ...{font_lib_33.png => font_default_0033.png} | Bin ...{font_lib_34.png => font_default_0034.png} | Bin ...{font_lib_35.png => font_default_0035.png} | Bin ...{font_lib_36.png => font_default_0036.png} | Bin ...{font_lib_37.png => font_default_0037.png} | Bin ...{font_lib_38.png => font_default_0038.png} | Bin ...{font_lib_39.png => font_default_0039.png} | Bin ...{font_lib_3a.png => font_default_003a.png} | Bin ...{font_lib_3b.png => font_default_003b.png} | Bin ...{font_lib_3c.png => font_default_003c.png} | Bin ...{font_lib_3d.png => font_default_003d.png} | Bin ...{font_lib_3e.png => font_default_003e.png} | Bin ...{font_lib_3f.png => font_default_003f.png} | Bin ...{font_lib_40.png => font_default_0040.png} | Bin ...{font_lib_41.png => font_default_0041.png} | Bin ...{font_lib_42.png => font_default_0042.png} | Bin ...{font_lib_43.png => font_default_0043.png} | Bin ...{font_lib_44.png => font_default_0044.png} | Bin ...{font_lib_45.png => font_default_0045.png} | Bin ...{font_lib_46.png => font_default_0046.png} | Bin ...{font_lib_47.png => font_default_0047.png} | Bin ...{font_lib_48.png => font_default_0048.png} | Bin ...{font_lib_49.png => font_default_0049.png} | Bin ...{font_lib_4a.png => font_default_004a.png} | Bin ...{font_lib_4b.png => font_default_004b.png} | Bin ...{font_lib_4c.png => font_default_004c.png} | Bin ...{font_lib_4d.png => font_default_004d.png} | Bin ...{font_lib_4e.png => font_default_004e.png} | Bin ...{font_lib_4f.png => font_default_004f.png} | Bin ...{font_lib_50.png => font_default_0050.png} | Bin ...{font_lib_51.png => font_default_0051.png} | Bin ...{font_lib_52.png => font_default_0052.png} | Bin ...{font_lib_53.png => font_default_0053.png} | Bin ...{font_lib_54.png => font_default_0054.png} | Bin ...{font_lib_55.png => font_default_0055.png} | Bin ...{font_lib_56.png => font_default_0056.png} | Bin ...{font_lib_57.png => font_default_0057.png} | Bin ...{font_lib_58.png => font_default_0058.png} | Bin ...{font_lib_59.png => font_default_0059.png} | Bin ...{font_lib_5a.png => font_default_005a.png} | Bin ...{font_lib_5b.png => font_default_005b.png} | Bin ...{font_lib_5c.png => font_default_005c.png} | Bin ...{font_lib_5d.png => font_default_005d.png} | Bin ...{font_lib_5e.png => font_default_005e.png} | Bin ...{font_lib_5f.png => font_default_005f.png} | Bin ...{font_lib_60.png => font_default_0060.png} | Bin ...{font_lib_61.png => font_default_0061.png} | Bin ...{font_lib_62.png => font_default_0062.png} | Bin ...{font_lib_63.png => font_default_0063.png} | Bin ...{font_lib_64.png => font_default_0064.png} | Bin ...{font_lib_65.png => font_default_0065.png} | Bin ...{font_lib_66.png => font_default_0066.png} | Bin ...{font_lib_67.png => font_default_0067.png} | Bin ...{font_lib_68.png => font_default_0068.png} | Bin ...{font_lib_69.png => font_default_0069.png} | Bin ...{font_lib_6a.png => font_default_006a.png} | Bin ...{font_lib_6b.png => font_default_006b.png} | Bin ...{font_lib_6c.png => font_default_006c.png} | Bin ...{font_lib_6d.png => font_default_006d.png} | Bin ...{font_lib_6e.png => font_default_006e.png} | Bin ...{font_lib_6f.png => font_default_006f.png} | Bin ...{font_lib_70.png => font_default_0070.png} | Bin ...{font_lib_71.png => font_default_0071.png} | Bin ...{font_lib_72.png => font_default_0072.png} | Bin ...{font_lib_73.png => font_default_0073.png} | Bin ...{font_lib_74.png => font_default_0074.png} | Bin ...{font_lib_75.png => font_default_0075.png} | Bin ...{font_lib_76.png => font_default_0076.png} | Bin ...{font_lib_77.png => font_default_0077.png} | Bin ...{font_lib_78.png => font_default_0078.png} | Bin ...{font_lib_79.png => font_default_0079.png} | Bin ...{font_lib_7a.png => font_default_007a.png} | Bin ...{font_lib_7b.png => font_default_007b.png} | Bin ...{font_lib_7c.png => font_default_007c.png} | Bin ...{font_lib_7d.png => font_default_007d.png} | Bin ...{font_lib_7e.png => font_default_007e.png} | Bin ...{font_lib_8a.png => font_default_008a.png} | Bin ...{font_lib_8d.png => font_default_008d.png} | Bin ...{font_lib_a1.png => font_default_00a1.png} | Bin ...{font_lib_b1.png => font_default_00b1.png} | Bin ...{font_lib_bf.png => font_default_00bf.png} | Bin ...{font_lib_c1.png => font_default_00c1.png} | Bin ...{font_lib_c2.png => font_default_00c2.png} | Bin ...{font_lib_c3.png => font_default_00c3.png} | Bin ...{font_lib_c4.png => font_default_00c4.png} | Bin ...{font_lib_c5.png => font_default_00c5.png} | Bin ...{font_lib_c6.png => font_default_00c6.png} | Bin ...{font_lib_c7.png => font_default_00c7.png} | Bin ...{font_lib_c8.png => font_default_00c8.png} | Bin ...{font_lib_c9.png => font_default_00c9.png} | Bin ...{font_lib_ca.png => font_default_00ca.png} | Bin ...{font_lib_cb.png => font_default_00cb.png} | Bin ...{font_lib_cc.png => font_default_00cc.png} | Bin ...{font_lib_cd.png => font_default_00cd.png} | Bin ...{font_lib_ce.png => font_default_00ce.png} | Bin ...{font_lib_cf.png => font_default_00cf.png} | Bin ...{font_lib_d0.png => font_default_00d0.png} | Bin ...{font_lib_d1.png => font_default_00d1.png} | Bin ...{font_lib_d2.png => font_default_00d2.png} | Bin ...{font_lib_d3.png => font_default_00d3.png} | Bin ...{font_lib_d4.png => font_default_00d4.png} | Bin ...{font_lib_d5.png => font_default_00d5.png} | Bin ...{font_lib_d6.png => font_default_00d6.png} | Bin ...{font_lib_d7.png => font_default_00d7.png} | Bin ...{font_lib_d8.png => font_default_00d8.png} | Bin ...{font_lib_d9.png => font_default_00d9.png} | Bin ...{font_lib_da.png => font_default_00da.png} | Bin ...{font_lib_db.png => font_default_00db.png} | Bin ...{font_lib_dc.png => font_default_00dc.png} | Bin ...{font_lib_dd.png => font_default_00dd.png} | Bin ...{font_lib_e0.png => font_default_00e0.png} | Bin ...{font_lib_e1.png => font_default_00e1.png} | Bin ...{font_lib_e2.png => font_default_00e2.png} | Bin ...{font_lib_e3.png => font_default_00e3.png} | Bin ...{font_lib_e4.png => font_default_00e4.png} | Bin ...{font_lib_e5.png => font_default_00e5.png} | Bin ...{font_lib_e6.png => font_default_00e6.png} | Bin ...{font_lib_e7.png => font_default_00e7.png} | Bin ...{font_lib_e8.png => font_default_00e8.png} | Bin ...{font_lib_e9.png => font_default_00e9.png} | Bin ...{font_lib_ea.png => font_default_00ea.png} | Bin ...{font_lib_eb.png => font_default_00eb.png} | Bin ...{font_lib_ec.png => font_default_00ec.png} | Bin ...{font_lib_ed.png => font_default_00ed.png} | Bin ...{font_lib_ee.png => font_default_00ee.png} | Bin ...{font_lib_ef.png => font_default_00ef.png} | Bin ...{font_lib_f2.png => font_default_00f2.png} | Bin ...{font_lib_f4.png => font_default_00f4.png} | Bin ...{font_lib_f5.png => font_default_00f5.png} | Bin ...{font_lib_f6.png => font_default_00f6.png} | Bin ...{font_lib_f7.png => font_default_00f7.png} | Bin ...{font_lib_f9.png => font_default_00f9.png} | Bin ...{font_lib_fa.png => font_default_00fa.png} | Bin ...{font_lib_fb.png => font_default_00fb.png} | Bin ...{font_lib_fc.png => font_default_00fc.png} | Bin ...{font_lib_fd.png => font_default_00fd.png} | Bin ...{font_lib_ff.png => font_default_00ff.png} | Bin font_lib/tools/make_font_lua.sh | 48 ++++ 163 files changed, 291 insertions(+), 81 deletions(-) create mode 100644 font_lib/font_default.lua rename font_lib/textures/{font_lib_00.png => font_default_0000.png} (100%) rename font_lib/textures/{font_lib_20.png => font_default_0020.png} (100%) rename font_lib/textures/{font_lib_21.png => font_default_0021.png} (100%) rename font_lib/textures/{font_lib_22.png => font_default_0022.png} (100%) rename font_lib/textures/{font_lib_23.png => font_default_0023.png} (100%) rename font_lib/textures/{font_lib_24.png => font_default_0024.png} (100%) rename font_lib/textures/{font_lib_25.png => font_default_0025.png} (100%) rename font_lib/textures/{font_lib_26.png => font_default_0026.png} (100%) rename font_lib/textures/{font_lib_27.png => font_default_0027.png} (100%) rename font_lib/textures/{font_lib_28.png => font_default_0028.png} (100%) rename font_lib/textures/{font_lib_29.png => font_default_0029.png} (100%) rename font_lib/textures/{font_lib_2a.png => font_default_002a.png} (100%) rename font_lib/textures/{font_lib_2b.png => font_default_002b.png} (100%) rename font_lib/textures/{font_lib_2c.png => font_default_002c.png} (100%) rename font_lib/textures/{font_lib_2d.png => font_default_002d.png} (100%) rename font_lib/textures/{font_lib_2e.png => font_default_002e.png} (100%) rename font_lib/textures/{font_lib_2f.png => font_default_002f.png} (100%) rename font_lib/textures/{font_lib_30.png => font_default_0030.png} (100%) rename font_lib/textures/{font_lib_31.png => font_default_0031.png} (100%) rename font_lib/textures/{font_lib_32.png => font_default_0032.png} (100%) rename font_lib/textures/{font_lib_33.png => font_default_0033.png} (100%) rename font_lib/textures/{font_lib_34.png => font_default_0034.png} (100%) rename font_lib/textures/{font_lib_35.png => font_default_0035.png} (100%) rename font_lib/textures/{font_lib_36.png => font_default_0036.png} (100%) rename font_lib/textures/{font_lib_37.png => font_default_0037.png} (100%) rename font_lib/textures/{font_lib_38.png => font_default_0038.png} (100%) rename font_lib/textures/{font_lib_39.png => font_default_0039.png} (100%) rename font_lib/textures/{font_lib_3a.png => font_default_003a.png} (100%) rename font_lib/textures/{font_lib_3b.png => font_default_003b.png} (100%) rename font_lib/textures/{font_lib_3c.png => font_default_003c.png} (100%) rename font_lib/textures/{font_lib_3d.png => font_default_003d.png} (100%) rename font_lib/textures/{font_lib_3e.png => font_default_003e.png} (100%) rename font_lib/textures/{font_lib_3f.png => font_default_003f.png} (100%) rename font_lib/textures/{font_lib_40.png => font_default_0040.png} (100%) rename font_lib/textures/{font_lib_41.png => font_default_0041.png} (100%) rename font_lib/textures/{font_lib_42.png => font_default_0042.png} (100%) rename font_lib/textures/{font_lib_43.png => font_default_0043.png} (100%) rename font_lib/textures/{font_lib_44.png => font_default_0044.png} (100%) rename font_lib/textures/{font_lib_45.png => font_default_0045.png} (100%) rename font_lib/textures/{font_lib_46.png => font_default_0046.png} (100%) rename font_lib/textures/{font_lib_47.png => font_default_0047.png} (100%) rename font_lib/textures/{font_lib_48.png => font_default_0048.png} (100%) rename font_lib/textures/{font_lib_49.png => font_default_0049.png} (100%) rename font_lib/textures/{font_lib_4a.png => font_default_004a.png} (100%) rename font_lib/textures/{font_lib_4b.png => font_default_004b.png} (100%) rename font_lib/textures/{font_lib_4c.png => font_default_004c.png} (100%) rename font_lib/textures/{font_lib_4d.png => font_default_004d.png} (100%) rename font_lib/textures/{font_lib_4e.png => font_default_004e.png} (100%) rename font_lib/textures/{font_lib_4f.png => font_default_004f.png} (100%) rename font_lib/textures/{font_lib_50.png => font_default_0050.png} (100%) rename font_lib/textures/{font_lib_51.png => font_default_0051.png} (100%) rename font_lib/textures/{font_lib_52.png => font_default_0052.png} (100%) rename font_lib/textures/{font_lib_53.png => font_default_0053.png} (100%) rename font_lib/textures/{font_lib_54.png => font_default_0054.png} (100%) rename font_lib/textures/{font_lib_55.png => font_default_0055.png} (100%) rename font_lib/textures/{font_lib_56.png => font_default_0056.png} (100%) rename font_lib/textures/{font_lib_57.png => font_default_0057.png} (100%) rename font_lib/textures/{font_lib_58.png => font_default_0058.png} (100%) rename font_lib/textures/{font_lib_59.png => font_default_0059.png} (100%) rename font_lib/textures/{font_lib_5a.png => font_default_005a.png} (100%) rename font_lib/textures/{font_lib_5b.png => font_default_005b.png} (100%) rename font_lib/textures/{font_lib_5c.png => font_default_005c.png} (100%) rename font_lib/textures/{font_lib_5d.png => font_default_005d.png} (100%) rename font_lib/textures/{font_lib_5e.png => font_default_005e.png} (100%) rename font_lib/textures/{font_lib_5f.png => font_default_005f.png} (100%) rename font_lib/textures/{font_lib_60.png => font_default_0060.png} (100%) rename font_lib/textures/{font_lib_61.png => font_default_0061.png} (100%) rename font_lib/textures/{font_lib_62.png => font_default_0062.png} (100%) rename font_lib/textures/{font_lib_63.png => font_default_0063.png} (100%) rename font_lib/textures/{font_lib_64.png => font_default_0064.png} (100%) rename font_lib/textures/{font_lib_65.png => font_default_0065.png} (100%) rename font_lib/textures/{font_lib_66.png => font_default_0066.png} (100%) rename font_lib/textures/{font_lib_67.png => font_default_0067.png} (100%) rename font_lib/textures/{font_lib_68.png => font_default_0068.png} (100%) rename font_lib/textures/{font_lib_69.png => font_default_0069.png} (100%) rename font_lib/textures/{font_lib_6a.png => font_default_006a.png} (100%) rename font_lib/textures/{font_lib_6b.png => font_default_006b.png} (100%) rename font_lib/textures/{font_lib_6c.png => font_default_006c.png} (100%) rename font_lib/textures/{font_lib_6d.png => font_default_006d.png} (100%) rename font_lib/textures/{font_lib_6e.png => font_default_006e.png} (100%) rename font_lib/textures/{font_lib_6f.png => font_default_006f.png} (100%) rename font_lib/textures/{font_lib_70.png => font_default_0070.png} (100%) rename font_lib/textures/{font_lib_71.png => font_default_0071.png} (100%) rename font_lib/textures/{font_lib_72.png => font_default_0072.png} (100%) rename font_lib/textures/{font_lib_73.png => font_default_0073.png} (100%) rename font_lib/textures/{font_lib_74.png => font_default_0074.png} (100%) rename font_lib/textures/{font_lib_75.png => font_default_0075.png} (100%) rename font_lib/textures/{font_lib_76.png => font_default_0076.png} (100%) rename font_lib/textures/{font_lib_77.png => font_default_0077.png} (100%) rename font_lib/textures/{font_lib_78.png => font_default_0078.png} (100%) rename font_lib/textures/{font_lib_79.png => font_default_0079.png} (100%) rename font_lib/textures/{font_lib_7a.png => font_default_007a.png} (100%) rename font_lib/textures/{font_lib_7b.png => font_default_007b.png} (100%) rename font_lib/textures/{font_lib_7c.png => font_default_007c.png} (100%) rename font_lib/textures/{font_lib_7d.png => font_default_007d.png} (100%) rename font_lib/textures/{font_lib_7e.png => font_default_007e.png} (100%) rename font_lib/textures/{font_lib_8a.png => font_default_008a.png} (100%) rename font_lib/textures/{font_lib_8d.png => font_default_008d.png} (100%) rename font_lib/textures/{font_lib_a1.png => font_default_00a1.png} (100%) rename font_lib/textures/{font_lib_b1.png => font_default_00b1.png} (100%) rename font_lib/textures/{font_lib_bf.png => font_default_00bf.png} (100%) rename font_lib/textures/{font_lib_c1.png => font_default_00c1.png} (100%) rename font_lib/textures/{font_lib_c2.png => font_default_00c2.png} (100%) rename font_lib/textures/{font_lib_c3.png => font_default_00c3.png} (100%) rename font_lib/textures/{font_lib_c4.png => font_default_00c4.png} (100%) rename font_lib/textures/{font_lib_c5.png => font_default_00c5.png} (100%) rename font_lib/textures/{font_lib_c6.png => font_default_00c6.png} (100%) rename font_lib/textures/{font_lib_c7.png => font_default_00c7.png} (100%) rename font_lib/textures/{font_lib_c8.png => font_default_00c8.png} (100%) rename font_lib/textures/{font_lib_c9.png => font_default_00c9.png} (100%) rename font_lib/textures/{font_lib_ca.png => font_default_00ca.png} (100%) rename font_lib/textures/{font_lib_cb.png => font_default_00cb.png} (100%) rename font_lib/textures/{font_lib_cc.png => font_default_00cc.png} (100%) rename font_lib/textures/{font_lib_cd.png => font_default_00cd.png} (100%) rename font_lib/textures/{font_lib_ce.png => font_default_00ce.png} (100%) rename font_lib/textures/{font_lib_cf.png => font_default_00cf.png} (100%) rename font_lib/textures/{font_lib_d0.png => font_default_00d0.png} (100%) rename font_lib/textures/{font_lib_d1.png => font_default_00d1.png} (100%) rename font_lib/textures/{font_lib_d2.png => font_default_00d2.png} (100%) rename font_lib/textures/{font_lib_d3.png => font_default_00d3.png} (100%) rename font_lib/textures/{font_lib_d4.png => font_default_00d4.png} (100%) rename font_lib/textures/{font_lib_d5.png => font_default_00d5.png} (100%) rename font_lib/textures/{font_lib_d6.png => font_default_00d6.png} (100%) rename font_lib/textures/{font_lib_d7.png => font_default_00d7.png} (100%) rename font_lib/textures/{font_lib_d8.png => font_default_00d8.png} (100%) rename font_lib/textures/{font_lib_d9.png => font_default_00d9.png} (100%) rename font_lib/textures/{font_lib_da.png => font_default_00da.png} (100%) rename font_lib/textures/{font_lib_db.png => font_default_00db.png} (100%) rename font_lib/textures/{font_lib_dc.png => font_default_00dc.png} (100%) rename font_lib/textures/{font_lib_dd.png => font_default_00dd.png} (100%) rename font_lib/textures/{font_lib_e0.png => font_default_00e0.png} (100%) rename font_lib/textures/{font_lib_e1.png => font_default_00e1.png} (100%) rename font_lib/textures/{font_lib_e2.png => font_default_00e2.png} (100%) rename font_lib/textures/{font_lib_e3.png => font_default_00e3.png} (100%) rename font_lib/textures/{font_lib_e4.png => font_default_00e4.png} (100%) rename font_lib/textures/{font_lib_e5.png => font_default_00e5.png} (100%) rename font_lib/textures/{font_lib_e6.png => font_default_00e6.png} (100%) rename font_lib/textures/{font_lib_e7.png => font_default_00e7.png} (100%) rename font_lib/textures/{font_lib_e8.png => font_default_00e8.png} (100%) rename font_lib/textures/{font_lib_e9.png => font_default_00e9.png} (100%) rename font_lib/textures/{font_lib_ea.png => font_default_00ea.png} (100%) rename font_lib/textures/{font_lib_eb.png => font_default_00eb.png} (100%) rename font_lib/textures/{font_lib_ec.png => font_default_00ec.png} (100%) rename font_lib/textures/{font_lib_ed.png => font_default_00ed.png} (100%) rename font_lib/textures/{font_lib_ee.png => font_default_00ee.png} (100%) rename font_lib/textures/{font_lib_ef.png => font_default_00ef.png} (100%) rename font_lib/textures/{font_lib_f2.png => font_default_00f2.png} (100%) rename font_lib/textures/{font_lib_f4.png => font_default_00f4.png} (100%) rename font_lib/textures/{font_lib_f5.png => font_default_00f5.png} (100%) rename font_lib/textures/{font_lib_f6.png => font_default_00f6.png} (100%) rename font_lib/textures/{font_lib_f7.png => font_default_00f7.png} (100%) rename font_lib/textures/{font_lib_f9.png => font_default_00f9.png} (100%) rename font_lib/textures/{font_lib_fa.png => font_default_00fa.png} (100%) rename font_lib/textures/{font_lib_fb.png => font_default_00fb.png} (100%) rename font_lib/textures/{font_lib_fc.png => font_default_00fc.png} (100%) rename font_lib/textures/{font_lib_fd.png => font_default_00fd.png} (100%) rename font_lib/textures/{font_lib_ff.png => font_default_00ff.png} (100%) create mode 100755 font_lib/tools/make_font_lua.sh diff --git a/README.md b/README.md index 0bc0f83..e96ddd7 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,16 @@ For more information, see the [forum topic](https://forum.minetest.net/viewtopic ## Changelog +### 2017-12-19 + +This change is a preparation to merge Andrzej Pieńkowski fork (apienk) : new font and support of UTF chars. + +- Font\_lib support for multiple fonts (nothing yet visible in mods) ; + +- Font\_lib support for Unicode characters (limited to Unicode Plane 0: 0000-FFFF, see [Wikipedia](https://en.wikipedia.org/wiki/Unicode)) ; + +- New "default" font with original textures from Vanessa Ezekowitz (VanessaE) ; + ### 2017-12-10 - Compatibility of signs mod with signs_lib (thanks to gpcf) ; diff --git a/font_lib/API.md b/font_lib/API.md index 7ec499b..b8bc97a 100644 --- a/font_lib/API.md +++ b/font_lib/API.md @@ -2,19 +2,24 @@ This document describes Font Lib API. Font Lib creates textures for font display on entities. ## Provided methods -### get\_line\_width -**font\_lib.get\_line\_width(text)** +### get\_text\_size +**font\_lib.get\_text\_size(font\_name, text)** + +Computes size for a given font and text + +**font\_name**: Font name of registered font to use -Computes line width for a given font height and text **text**: Text to be rendered -**Returns**: rendered text width +**Returns**: rendered text width, height ### make\_line\_texture -**font\_lib.make\_line\_texture(text, texturew, x, y)** +**font\_lib.make\_line\_texture(font\_name, text, width, x, y)** Builds texture part for a text line +**font\_name**: Font name of registered font to use + **text**: Text to be rendered **texturew**: Width of the texture (extra text is not rendered) @@ -26,10 +31,12 @@ Builds texture part for a text line **Returns**: Texture string ### make\_multiline\_texture -**font\_lib.make\_multiline\_texture(text, texturew, textureh, maxlines, valign, color)** +**font\_lib.make\_multiline\_texture(font\_name, text, width, height, maxlines, valign, color)** Builds texture for a multiline colored text +**font\_name**: Font name of registered font to use + **text**: Text to be rendered **texturew**: Width of the texture (extra text will be truncated) @@ -38,10 +45,46 @@ Builds texture for a multiline colored text **maxlines**: Maximum number of lines -**valign**: Vertical text align ("top" or "center") +**valign**: Vertical text align ("top", "bottom" or "center") **color**: Color of the text **Returns**: Texture string +### register\_font +**font\_lib.register_font(font\_name, height, widths)** + +Registers a new font in font_lib. + +**font\_name**: Name of the font to register (this name will be used to address the font later) + +**height**: Height of the font in pixels (all font textures should have the same height) + +**widths** : An array containing the width of each font texture, indexed by its UTF code + +All textures corresponding to the indexes in **widths** array should be present in textures directory with a name matching the pattern : + +**font\__.png** + +: Name of the font as given in the first argument + +: UTF code of the char in 4 hexadecimal digits + +To ease that declaration, a shell is provided to build a .lua file from the texture files (see provided tools). + +### set\_fallback\_font +**function font\_lib.set\_fallback\_font(font\_name)** + +Defines the fallback font to be used instead of given font if not registered. + +**font\_name**: Name of the font to be used as fallback font (has to be registered) + +## Provided tools + +### make_font_lua.sh + +Still in early stage of development. + +This script analyses textures in textures directory and creates a font\_.lua files with a call to register_font with images information. + diff --git a/font_lib/README.md b/font_lib/README.md index 67903a9..6b53a6b 100644 --- a/font_lib/README.md +++ b/font_lib/README.md @@ -6,9 +6,9 @@ This library for font display on entities (to be used with display_lib for sign **License**: LGPL -(Font taken from VanessaE's homedecor/signs_lib, originally under WTFPL) +(Default font taken from VanessaE's homedecor/signs_lib, originally under WTFPL) **API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/font_lib/API.md) document please. -For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?f=11&t=13563) at the Minetest forums. +For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=13563) at the Minetest forums. diff --git a/font_lib/font_default.lua b/font_lib/font_default.lua new file mode 100644 index 0000000..fef847a --- /dev/null +++ b/font_lib/font_default.lua @@ -0,0 +1,12 @@ +--[[ + + generated by ./make_font_mod.sh Sun Dec 17 21:23:59 CET 2017 + +--]] + +font_lib.register_font( + 'default', + 12, + { [0]=6, [32]=4, [33]=3, [34]=4, [35]=7, [36]=6, [37]=8, [38]=8, [39]=3, [40]=4, [41]=4, [42]=4, [43]=7, [44]=3, [45]=5, [46]=3, [47]=5, [48]=6, [49]=4, [50]=6, [51]=6, [52]=7, [53]=6, [54]=6, [55]=6, [56]=6, [57]=6, [58]=3, [59]=3, [60]=5, [61]=6, [62]=5, [63]=6, [64]=11, [65]=8, [66]=7, [67]=8, [68]=7, [69]=6, [70]=6, [71]=8, [72]=7, [73]=3, [74]=6, [75]=8, [76]=6, [77]=10, [78]=8, [79]=8, [80]=7, [81]=8, [82]=7, [83]=7, [84]=7, [85]=7, [86]=8, [87]=11, [88]=8, [89]=9, [90]=7, [91]=4, [92]=5, [93]=4, [94]=5, [95]=7, [96]=3, [97]=7, [98]=6, [99]=5, [100]=6, [101]=6, [102]=5, [103]=6, [104]=6, [105]=3, [106]=3, [107]=7, [108]=3, [109]=9, [110]=6, [111]=6, [112]=6, [113]=6, [114]=5, [115]=6, [116]=4, [117]=6, [118]=6, [119]=8, [120]=7, [121]=6, [122]=6, [123]=5, [124]=3, [125]=5, [126]=6, [138]=6, [141]=3, [161]=3, [177]=6, [191]=6, [193]=8, [194]=8, [195]=8, [196]=8, [197]=8, [198]=10, [199]=8, [200]=6, [201]=6, [202]=6, [203]=6, [204]=3, [205]=3, [206]=3, [207]=3, [208]=8, [209]=8, [210]=8, [211]=8, [212]=8, [213]=8, [214]=8, [215]=6, [216]=8, [217]=7, [218]=7, [219]=7, [220]=7, [221]=9, [224]=7, [225]=7, [226]=7, [227]=7, [228]=7, [229]=7, [230]=9, [231]=5, [232]=6, [233]=6, [234]=6, [235]=6, [236]=3, [237]=3, [238]=3, [239]=3, [242]=6, [244]=6, [245]=6, [246]=6, [247]=6, [249]=6, [250]=6, [251]=6, [252]=6, [253]=6, [255]=6 } +); + diff --git a/font_lib/init.lua b/font_lib/init.lua index 9dd6908..c1cee07 100644 --- a/font_lib/init.lua +++ b/font_lib/init.lua @@ -21,26 +21,12 @@ font_lib = {} font_lib.path = minetest.get_modpath("font_lib") -font_lib.font_height = 12 -font_lib.font = {} +font_lib.registered_fonts = {} -- Local functions +------------------ -local function get_next_char(text, pos) - pos = pos + 1 - local char = text:sub(pos, pos):byte() - if char >= 0x80 then - if char == 0xc2 or char == 0xc3 then - pos = pos + 1 - char = (char - 0xc2) * 0x40 + text:sub(pos, pos):byte() - else - char = 0 - end - end - if font_lib.font[char] == nil then char=0 end - - return char, pos -end +-- Split multiline text into array of lines, with maximum lines. local function split_lines(text, maxlines) local splits = text:split("\n") @@ -55,49 +41,125 @@ local function split_lines(text, maxlines) end end --- Computes line width for a given font height and text --- @param text Text to be rendered --- @return Rendered text width +-- Returns next char, managing ascii and unicode plane 0 (0000-FFFF). -function font_lib.get_line_width(text) - local char - local width = 0 - local p=0 - - while p < #text do - char, p = get_next_char(text, p) - width = width + font_lib.font[char].width +local function get_next_char(text, pos) + pos = pos + 1 + local char = text:sub(pos, pos):byte() + + -- 4 bytes char not managed + if char >= 0xF0 then + pos = pos + 3 + return 0, pos + end + + -- 3 bytes char not managed + if char >= 0xE0 then + pos = pos + 2 + return 0, pos + end + + -- 2 bytes char (little endian) + if char >= 0x80 then + pos = pos + 1 + return char * 0x100 + text:sub(pos, pos):byte(), pos + end + + -- 1 byte char + return char, pos +end + +-- Returns font properties to be used according to font_name + +local function get_font(font_name) + local font = font_lib.registered_fonts[font_name] + + if font == nil then + local message + + if font_name == nil then + message = "No font given" + else + message = "Font \""..font_name.."\" unregistered" + end + + if font_lib.fallback_font == nil then + minetest.log("error", message.." and no other font registered.") + else + minetest.log("info", message..", using font \""..font_lib.fallback_font.."\".") + font = font_lib.registered_fonts[font_lib.fallback_font] + end end - return width + return font +end + +-- API functions +---------------- + +-- Computes text size for a given font and text (ignores new lines) +-- @param font_name Font to be used +-- @param text Text to be rendered +-- @return Rendered text (width, height) + +function font_lib.get_text_size(font_name, text) + local char + local width = 0 + local pos = 0 + local font = get_font(font_name) + + if font == nil then + return 0, 0 + else + while pos < #text do + char, pos = get_next_char(text, pos) + -- Ignore chars with no texture + if font.widths[char] ~= nil then + width = width + font.widths[char] + end + end + end + + return width, font.height end --- Builds texture part for a text line +-- @param font_name Font to be used -- @param text Text to be rendered --- @param texturew Width of the texture (extra text is not rendered) +-- @param width Width of the texture (extra text is not rendered) -- @param x Starting x position in texture -- @param y Vertical position of the line in texture -- @return Texture string -function font_lib.make_line_texture(text, texturew, x, y) - local char +--> ADD ALIGN +function font_lib.make_line_texture(font_name, text, width, x, y) local texture = "" - local p=0 - - while p < #text do - char, p = get_next_char(text, p) + local char + local pos = 0 + local font = get_font(font_name) - -- Add image only if it is visible (at least partly) - if x + font_lib.font[char].width >= 0 and x <= texturew then - texture = texture..string.format(":%d,%d=%s", x, y, font_lib.font[char].filename) + if font ~= nil then + while pos < #text do + char, pos = get_next_char(text, pos) + + -- Ignore chars with no texture + if font.widths[char] ~= nil then + -- Add image only if it is visible (at least partly) + if x + font.widths[char] >= 0 and x <= width then + texture = texture.. + string.format(":%d,%d=font_%s_%04x.png", + x, y, font.name, char) + end + x = x + font.widths[char] + end end - x = x + font_lib.font[char].width - end + return texture end --- Builds texture for a multiline colored text +-- @param font_name Font to be used -- @param text Text to be rendered -- @param texturew Width of the texture (extra text will be truncated) -- @param textureh Height of the texture @@ -106,29 +168,78 @@ end -- @param color Color of the text -- @return Texture string -function font_lib.make_multiline_texture(text, texturew, textureh, maxlines, valign, color) +function font_lib.make_multiline_texture(font_name, text, width, height, + maxlines, valign, color) local texture = "" - local lines = split_lines(text, maxlines) - local y - - if valign == "top" then - y = font_lib.font_height / 2 - 1 - else - y = (textureh - font_lib.font_height * #lines) / 2 - end - + local lines = {} + local textheight = 0 + local y, w, h + + for num, line in pairs(split_lines(text, maxlines)) do + w, h = font_lib.get_text_size(font_name, line) + lines[num] = { text = line, width = w, height = h, } + textheight = textheight + h + end + + if #lines then + if valign == "top" then + y = 0 + elseif valign == "bottom" then + y = height - textheight + else + y = (height - textheight) / 2 + end + end + for _, line in pairs(lines) do - texture = texture..font_lib.make_line_texture(line, texturew, - (texturew - font_lib.get_line_width(line)) / 2, y) - y = y + font_lib.font_height + texture = texture.. + font_lib.make_line_texture(font_name, line.text, width, + (width - line.width) / 2, y) + y = y + line.height end - texture = string.format("[combine:%dx%d", texturew, textureh)..texture + texture = string.format("[combine:%dx%d", width, height)..texture if color then texture = texture.."^[colorize:"..color end return texture end +--- Register a new font +-- Textures corresponding to the font should be named after following patern : +-- font__.png +-- : name of the font +-- : 4 digit hexadecimal unicode of the char +-- If registering different sizes, add size in the font name (e.g. times_10, times_12...) +-- @param height Font height in pixels +-- @param widths Array of character widths in pixel, indexed by unicode number. + +function font_lib.register_font(font_name, height, widths) + if font_lib.registered_fonts[font_name] ~= nil then + minetest.log("error", "Font \""..font_name.."\" already registered.") + return + end + + font_lib.registered_fonts[font_name] = + { name = font_name, height = height, widths = widths } + + -- If no fallback font, set it (so, first font registered will be the default fallback font) + if font_lib.fallback_font == nil then + font_lib.fallback_font = font_name + end +end + +--- Define the fallback font +-- This font will be used instead of given font if not registered. +-- @param font_name Name of the font to be used as fallback font (has to be registered). + +function font_lib.set_fallback_font(font_name) + if font_lib.registered_fonts[font_name] == nil then + minetest.log("error", "Fallback font \""..font_name.."\" not registered.") + else + font_lib.fallback_font = font_name + end +end + --- Standard on_display_update entity callback. -- Node should have a corresponding display_entity with size, resolution and maxlines fields and -- optionally valign and color fields @@ -141,31 +252,17 @@ function font_lib.on_display_update(pos, objref) local ndef = minetest.registered_nodes[minetest.get_node(pos).name] local entity = objref:get_luaentity() - if entity and ndef.display_entities[entity.name] then + if entity and ndef.display_entities[entity.name] then local def = ndef.display_entities[entity.name] objref:set_properties({ textures={font_lib.make_multiline_texture( - text, def.size.x*def.resolution.x, def.size.y*def.resolution.y, + def.font_name, text, def.size.x*def.resolution.x, def.size.y*def.resolution.y, def.maxlines, def.valign, def.color)}, visual_size = def.size }) end end --- Populate fonts table - -local filename -for char = 0,255 do - filename = string.format("font_lib_%02x.png", char) - local file=io.open(font_lib.path.."/textures/"..filename,"rb") - if file~=nil then - -- Get png width, suposing png width is less than 256 (it is the case for all font textures) - -- All font png are smaller than 256x256 --> read only last byte - file:seek("set",19) - local w = file:read(1) - file:close() - font_lib.font[char] = {filename=filename, width=w:byte()} - end -end +dofile(font_lib.path.."/font_default.lua") diff --git a/font_lib/textures/font_lib_00.png b/font_lib/textures/font_default_0000.png similarity index 100% rename from font_lib/textures/font_lib_00.png rename to font_lib/textures/font_default_0000.png diff --git a/font_lib/textures/font_lib_20.png b/font_lib/textures/font_default_0020.png similarity index 100% rename from font_lib/textures/font_lib_20.png rename to font_lib/textures/font_default_0020.png diff --git a/font_lib/textures/font_lib_21.png b/font_lib/textures/font_default_0021.png similarity index 100% rename from font_lib/textures/font_lib_21.png rename to font_lib/textures/font_default_0021.png diff --git a/font_lib/textures/font_lib_22.png b/font_lib/textures/font_default_0022.png similarity index 100% rename from font_lib/textures/font_lib_22.png rename to font_lib/textures/font_default_0022.png diff --git a/font_lib/textures/font_lib_23.png b/font_lib/textures/font_default_0023.png similarity index 100% rename from font_lib/textures/font_lib_23.png rename to font_lib/textures/font_default_0023.png diff --git a/font_lib/textures/font_lib_24.png b/font_lib/textures/font_default_0024.png similarity index 100% rename from font_lib/textures/font_lib_24.png rename to font_lib/textures/font_default_0024.png diff --git a/font_lib/textures/font_lib_25.png b/font_lib/textures/font_default_0025.png similarity index 100% rename from font_lib/textures/font_lib_25.png rename to font_lib/textures/font_default_0025.png diff --git a/font_lib/textures/font_lib_26.png b/font_lib/textures/font_default_0026.png similarity index 100% rename from font_lib/textures/font_lib_26.png rename to font_lib/textures/font_default_0026.png diff --git a/font_lib/textures/font_lib_27.png b/font_lib/textures/font_default_0027.png similarity index 100% rename from font_lib/textures/font_lib_27.png rename to font_lib/textures/font_default_0027.png diff --git a/font_lib/textures/font_lib_28.png b/font_lib/textures/font_default_0028.png similarity index 100% rename from font_lib/textures/font_lib_28.png rename to font_lib/textures/font_default_0028.png diff --git a/font_lib/textures/font_lib_29.png b/font_lib/textures/font_default_0029.png similarity index 100% rename from font_lib/textures/font_lib_29.png rename to font_lib/textures/font_default_0029.png diff --git a/font_lib/textures/font_lib_2a.png b/font_lib/textures/font_default_002a.png similarity index 100% rename from font_lib/textures/font_lib_2a.png rename to font_lib/textures/font_default_002a.png diff --git a/font_lib/textures/font_lib_2b.png b/font_lib/textures/font_default_002b.png similarity index 100% rename from font_lib/textures/font_lib_2b.png rename to font_lib/textures/font_default_002b.png diff --git a/font_lib/textures/font_lib_2c.png b/font_lib/textures/font_default_002c.png similarity index 100% rename from font_lib/textures/font_lib_2c.png rename to font_lib/textures/font_default_002c.png diff --git a/font_lib/textures/font_lib_2d.png b/font_lib/textures/font_default_002d.png similarity index 100% rename from font_lib/textures/font_lib_2d.png rename to font_lib/textures/font_default_002d.png diff --git a/font_lib/textures/font_lib_2e.png b/font_lib/textures/font_default_002e.png similarity index 100% rename from font_lib/textures/font_lib_2e.png rename to font_lib/textures/font_default_002e.png diff --git a/font_lib/textures/font_lib_2f.png b/font_lib/textures/font_default_002f.png similarity index 100% rename from font_lib/textures/font_lib_2f.png rename to font_lib/textures/font_default_002f.png diff --git a/font_lib/textures/font_lib_30.png b/font_lib/textures/font_default_0030.png similarity index 100% rename from font_lib/textures/font_lib_30.png rename to font_lib/textures/font_default_0030.png diff --git a/font_lib/textures/font_lib_31.png b/font_lib/textures/font_default_0031.png similarity index 100% rename from font_lib/textures/font_lib_31.png rename to font_lib/textures/font_default_0031.png diff --git a/font_lib/textures/font_lib_32.png b/font_lib/textures/font_default_0032.png similarity index 100% rename from font_lib/textures/font_lib_32.png rename to font_lib/textures/font_default_0032.png diff --git a/font_lib/textures/font_lib_33.png b/font_lib/textures/font_default_0033.png similarity index 100% rename from font_lib/textures/font_lib_33.png rename to font_lib/textures/font_default_0033.png diff --git a/font_lib/textures/font_lib_34.png b/font_lib/textures/font_default_0034.png similarity index 100% rename from font_lib/textures/font_lib_34.png rename to font_lib/textures/font_default_0034.png diff --git a/font_lib/textures/font_lib_35.png b/font_lib/textures/font_default_0035.png similarity index 100% rename from font_lib/textures/font_lib_35.png rename to font_lib/textures/font_default_0035.png diff --git a/font_lib/textures/font_lib_36.png b/font_lib/textures/font_default_0036.png similarity index 100% rename from font_lib/textures/font_lib_36.png rename to font_lib/textures/font_default_0036.png diff --git a/font_lib/textures/font_lib_37.png b/font_lib/textures/font_default_0037.png similarity index 100% rename from font_lib/textures/font_lib_37.png rename to font_lib/textures/font_default_0037.png diff --git a/font_lib/textures/font_lib_38.png b/font_lib/textures/font_default_0038.png similarity index 100% rename from font_lib/textures/font_lib_38.png rename to font_lib/textures/font_default_0038.png diff --git a/font_lib/textures/font_lib_39.png b/font_lib/textures/font_default_0039.png similarity index 100% rename from font_lib/textures/font_lib_39.png rename to font_lib/textures/font_default_0039.png diff --git a/font_lib/textures/font_lib_3a.png b/font_lib/textures/font_default_003a.png similarity index 100% rename from font_lib/textures/font_lib_3a.png rename to font_lib/textures/font_default_003a.png diff --git a/font_lib/textures/font_lib_3b.png b/font_lib/textures/font_default_003b.png similarity index 100% rename from font_lib/textures/font_lib_3b.png rename to font_lib/textures/font_default_003b.png diff --git a/font_lib/textures/font_lib_3c.png b/font_lib/textures/font_default_003c.png similarity index 100% rename from font_lib/textures/font_lib_3c.png rename to font_lib/textures/font_default_003c.png diff --git a/font_lib/textures/font_lib_3d.png b/font_lib/textures/font_default_003d.png similarity index 100% rename from font_lib/textures/font_lib_3d.png rename to font_lib/textures/font_default_003d.png diff --git a/font_lib/textures/font_lib_3e.png b/font_lib/textures/font_default_003e.png similarity index 100% rename from font_lib/textures/font_lib_3e.png rename to font_lib/textures/font_default_003e.png diff --git a/font_lib/textures/font_lib_3f.png b/font_lib/textures/font_default_003f.png similarity index 100% rename from font_lib/textures/font_lib_3f.png rename to font_lib/textures/font_default_003f.png diff --git a/font_lib/textures/font_lib_40.png b/font_lib/textures/font_default_0040.png similarity index 100% rename from font_lib/textures/font_lib_40.png rename to font_lib/textures/font_default_0040.png diff --git a/font_lib/textures/font_lib_41.png b/font_lib/textures/font_default_0041.png similarity index 100% rename from font_lib/textures/font_lib_41.png rename to font_lib/textures/font_default_0041.png diff --git a/font_lib/textures/font_lib_42.png b/font_lib/textures/font_default_0042.png similarity index 100% rename from font_lib/textures/font_lib_42.png rename to font_lib/textures/font_default_0042.png diff --git a/font_lib/textures/font_lib_43.png b/font_lib/textures/font_default_0043.png similarity index 100% rename from font_lib/textures/font_lib_43.png rename to font_lib/textures/font_default_0043.png diff --git a/font_lib/textures/font_lib_44.png b/font_lib/textures/font_default_0044.png similarity index 100% rename from font_lib/textures/font_lib_44.png rename to font_lib/textures/font_default_0044.png diff --git a/font_lib/textures/font_lib_45.png b/font_lib/textures/font_default_0045.png similarity index 100% rename from font_lib/textures/font_lib_45.png rename to font_lib/textures/font_default_0045.png diff --git a/font_lib/textures/font_lib_46.png b/font_lib/textures/font_default_0046.png similarity index 100% rename from font_lib/textures/font_lib_46.png rename to font_lib/textures/font_default_0046.png diff --git a/font_lib/textures/font_lib_47.png b/font_lib/textures/font_default_0047.png similarity index 100% rename from font_lib/textures/font_lib_47.png rename to font_lib/textures/font_default_0047.png diff --git a/font_lib/textures/font_lib_48.png b/font_lib/textures/font_default_0048.png similarity index 100% rename from font_lib/textures/font_lib_48.png rename to font_lib/textures/font_default_0048.png diff --git a/font_lib/textures/font_lib_49.png b/font_lib/textures/font_default_0049.png similarity index 100% rename from font_lib/textures/font_lib_49.png rename to font_lib/textures/font_default_0049.png diff --git a/font_lib/textures/font_lib_4a.png b/font_lib/textures/font_default_004a.png similarity index 100% rename from font_lib/textures/font_lib_4a.png rename to font_lib/textures/font_default_004a.png diff --git a/font_lib/textures/font_lib_4b.png b/font_lib/textures/font_default_004b.png similarity index 100% rename from font_lib/textures/font_lib_4b.png rename to font_lib/textures/font_default_004b.png diff --git a/font_lib/textures/font_lib_4c.png b/font_lib/textures/font_default_004c.png similarity index 100% rename from font_lib/textures/font_lib_4c.png rename to font_lib/textures/font_default_004c.png diff --git a/font_lib/textures/font_lib_4d.png b/font_lib/textures/font_default_004d.png similarity index 100% rename from font_lib/textures/font_lib_4d.png rename to font_lib/textures/font_default_004d.png diff --git a/font_lib/textures/font_lib_4e.png b/font_lib/textures/font_default_004e.png similarity index 100% rename from font_lib/textures/font_lib_4e.png rename to font_lib/textures/font_default_004e.png diff --git a/font_lib/textures/font_lib_4f.png b/font_lib/textures/font_default_004f.png similarity index 100% rename from font_lib/textures/font_lib_4f.png rename to font_lib/textures/font_default_004f.png diff --git a/font_lib/textures/font_lib_50.png b/font_lib/textures/font_default_0050.png similarity index 100% rename from font_lib/textures/font_lib_50.png rename to font_lib/textures/font_default_0050.png diff --git a/font_lib/textures/font_lib_51.png b/font_lib/textures/font_default_0051.png similarity index 100% rename from font_lib/textures/font_lib_51.png rename to font_lib/textures/font_default_0051.png diff --git a/font_lib/textures/font_lib_52.png b/font_lib/textures/font_default_0052.png similarity index 100% rename from font_lib/textures/font_lib_52.png rename to font_lib/textures/font_default_0052.png diff --git a/font_lib/textures/font_lib_53.png b/font_lib/textures/font_default_0053.png similarity index 100% rename from font_lib/textures/font_lib_53.png rename to font_lib/textures/font_default_0053.png diff --git a/font_lib/textures/font_lib_54.png b/font_lib/textures/font_default_0054.png similarity index 100% rename from font_lib/textures/font_lib_54.png rename to font_lib/textures/font_default_0054.png diff --git a/font_lib/textures/font_lib_55.png b/font_lib/textures/font_default_0055.png similarity index 100% rename from font_lib/textures/font_lib_55.png rename to font_lib/textures/font_default_0055.png diff --git a/font_lib/textures/font_lib_56.png b/font_lib/textures/font_default_0056.png similarity index 100% rename from font_lib/textures/font_lib_56.png rename to font_lib/textures/font_default_0056.png diff --git a/font_lib/textures/font_lib_57.png b/font_lib/textures/font_default_0057.png similarity index 100% rename from font_lib/textures/font_lib_57.png rename to font_lib/textures/font_default_0057.png diff --git a/font_lib/textures/font_lib_58.png b/font_lib/textures/font_default_0058.png similarity index 100% rename from font_lib/textures/font_lib_58.png rename to font_lib/textures/font_default_0058.png diff --git a/font_lib/textures/font_lib_59.png b/font_lib/textures/font_default_0059.png similarity index 100% rename from font_lib/textures/font_lib_59.png rename to font_lib/textures/font_default_0059.png diff --git a/font_lib/textures/font_lib_5a.png b/font_lib/textures/font_default_005a.png similarity index 100% rename from font_lib/textures/font_lib_5a.png rename to font_lib/textures/font_default_005a.png diff --git a/font_lib/textures/font_lib_5b.png b/font_lib/textures/font_default_005b.png similarity index 100% rename from font_lib/textures/font_lib_5b.png rename to font_lib/textures/font_default_005b.png diff --git a/font_lib/textures/font_lib_5c.png b/font_lib/textures/font_default_005c.png similarity index 100% rename from font_lib/textures/font_lib_5c.png rename to font_lib/textures/font_default_005c.png diff --git a/font_lib/textures/font_lib_5d.png b/font_lib/textures/font_default_005d.png similarity index 100% rename from font_lib/textures/font_lib_5d.png rename to font_lib/textures/font_default_005d.png diff --git a/font_lib/textures/font_lib_5e.png b/font_lib/textures/font_default_005e.png similarity index 100% rename from font_lib/textures/font_lib_5e.png rename to font_lib/textures/font_default_005e.png diff --git a/font_lib/textures/font_lib_5f.png b/font_lib/textures/font_default_005f.png similarity index 100% rename from font_lib/textures/font_lib_5f.png rename to font_lib/textures/font_default_005f.png diff --git a/font_lib/textures/font_lib_60.png b/font_lib/textures/font_default_0060.png similarity index 100% rename from font_lib/textures/font_lib_60.png rename to font_lib/textures/font_default_0060.png diff --git a/font_lib/textures/font_lib_61.png b/font_lib/textures/font_default_0061.png similarity index 100% rename from font_lib/textures/font_lib_61.png rename to font_lib/textures/font_default_0061.png diff --git a/font_lib/textures/font_lib_62.png b/font_lib/textures/font_default_0062.png similarity index 100% rename from font_lib/textures/font_lib_62.png rename to font_lib/textures/font_default_0062.png diff --git a/font_lib/textures/font_lib_63.png b/font_lib/textures/font_default_0063.png similarity index 100% rename from font_lib/textures/font_lib_63.png rename to font_lib/textures/font_default_0063.png diff --git a/font_lib/textures/font_lib_64.png b/font_lib/textures/font_default_0064.png similarity index 100% rename from font_lib/textures/font_lib_64.png rename to font_lib/textures/font_default_0064.png diff --git a/font_lib/textures/font_lib_65.png b/font_lib/textures/font_default_0065.png similarity index 100% rename from font_lib/textures/font_lib_65.png rename to font_lib/textures/font_default_0065.png diff --git a/font_lib/textures/font_lib_66.png b/font_lib/textures/font_default_0066.png similarity index 100% rename from font_lib/textures/font_lib_66.png rename to font_lib/textures/font_default_0066.png diff --git a/font_lib/textures/font_lib_67.png b/font_lib/textures/font_default_0067.png similarity index 100% rename from font_lib/textures/font_lib_67.png rename to font_lib/textures/font_default_0067.png diff --git a/font_lib/textures/font_lib_68.png b/font_lib/textures/font_default_0068.png similarity index 100% rename from font_lib/textures/font_lib_68.png rename to font_lib/textures/font_default_0068.png diff --git a/font_lib/textures/font_lib_69.png b/font_lib/textures/font_default_0069.png similarity index 100% rename from font_lib/textures/font_lib_69.png rename to font_lib/textures/font_default_0069.png diff --git a/font_lib/textures/font_lib_6a.png b/font_lib/textures/font_default_006a.png similarity index 100% rename from font_lib/textures/font_lib_6a.png rename to font_lib/textures/font_default_006a.png diff --git a/font_lib/textures/font_lib_6b.png b/font_lib/textures/font_default_006b.png similarity index 100% rename from font_lib/textures/font_lib_6b.png rename to font_lib/textures/font_default_006b.png diff --git a/font_lib/textures/font_lib_6c.png b/font_lib/textures/font_default_006c.png similarity index 100% rename from font_lib/textures/font_lib_6c.png rename to font_lib/textures/font_default_006c.png diff --git a/font_lib/textures/font_lib_6d.png b/font_lib/textures/font_default_006d.png similarity index 100% rename from font_lib/textures/font_lib_6d.png rename to font_lib/textures/font_default_006d.png diff --git a/font_lib/textures/font_lib_6e.png b/font_lib/textures/font_default_006e.png similarity index 100% rename from font_lib/textures/font_lib_6e.png rename to font_lib/textures/font_default_006e.png diff --git a/font_lib/textures/font_lib_6f.png b/font_lib/textures/font_default_006f.png similarity index 100% rename from font_lib/textures/font_lib_6f.png rename to font_lib/textures/font_default_006f.png diff --git a/font_lib/textures/font_lib_70.png b/font_lib/textures/font_default_0070.png similarity index 100% rename from font_lib/textures/font_lib_70.png rename to font_lib/textures/font_default_0070.png diff --git a/font_lib/textures/font_lib_71.png b/font_lib/textures/font_default_0071.png similarity index 100% rename from font_lib/textures/font_lib_71.png rename to font_lib/textures/font_default_0071.png diff --git a/font_lib/textures/font_lib_72.png b/font_lib/textures/font_default_0072.png similarity index 100% rename from font_lib/textures/font_lib_72.png rename to font_lib/textures/font_default_0072.png diff --git a/font_lib/textures/font_lib_73.png b/font_lib/textures/font_default_0073.png similarity index 100% rename from font_lib/textures/font_lib_73.png rename to font_lib/textures/font_default_0073.png diff --git a/font_lib/textures/font_lib_74.png b/font_lib/textures/font_default_0074.png similarity index 100% rename from font_lib/textures/font_lib_74.png rename to font_lib/textures/font_default_0074.png diff --git a/font_lib/textures/font_lib_75.png b/font_lib/textures/font_default_0075.png similarity index 100% rename from font_lib/textures/font_lib_75.png rename to font_lib/textures/font_default_0075.png diff --git a/font_lib/textures/font_lib_76.png b/font_lib/textures/font_default_0076.png similarity index 100% rename from font_lib/textures/font_lib_76.png rename to font_lib/textures/font_default_0076.png diff --git a/font_lib/textures/font_lib_77.png b/font_lib/textures/font_default_0077.png similarity index 100% rename from font_lib/textures/font_lib_77.png rename to font_lib/textures/font_default_0077.png diff --git a/font_lib/textures/font_lib_78.png b/font_lib/textures/font_default_0078.png similarity index 100% rename from font_lib/textures/font_lib_78.png rename to font_lib/textures/font_default_0078.png diff --git a/font_lib/textures/font_lib_79.png b/font_lib/textures/font_default_0079.png similarity index 100% rename from font_lib/textures/font_lib_79.png rename to font_lib/textures/font_default_0079.png diff --git a/font_lib/textures/font_lib_7a.png b/font_lib/textures/font_default_007a.png similarity index 100% rename from font_lib/textures/font_lib_7a.png rename to font_lib/textures/font_default_007a.png diff --git a/font_lib/textures/font_lib_7b.png b/font_lib/textures/font_default_007b.png similarity index 100% rename from font_lib/textures/font_lib_7b.png rename to font_lib/textures/font_default_007b.png diff --git a/font_lib/textures/font_lib_7c.png b/font_lib/textures/font_default_007c.png similarity index 100% rename from font_lib/textures/font_lib_7c.png rename to font_lib/textures/font_default_007c.png diff --git a/font_lib/textures/font_lib_7d.png b/font_lib/textures/font_default_007d.png similarity index 100% rename from font_lib/textures/font_lib_7d.png rename to font_lib/textures/font_default_007d.png diff --git a/font_lib/textures/font_lib_7e.png b/font_lib/textures/font_default_007e.png similarity index 100% rename from font_lib/textures/font_lib_7e.png rename to font_lib/textures/font_default_007e.png diff --git a/font_lib/textures/font_lib_8a.png b/font_lib/textures/font_default_008a.png similarity index 100% rename from font_lib/textures/font_lib_8a.png rename to font_lib/textures/font_default_008a.png diff --git a/font_lib/textures/font_lib_8d.png b/font_lib/textures/font_default_008d.png similarity index 100% rename from font_lib/textures/font_lib_8d.png rename to font_lib/textures/font_default_008d.png diff --git a/font_lib/textures/font_lib_a1.png b/font_lib/textures/font_default_00a1.png similarity index 100% rename from font_lib/textures/font_lib_a1.png rename to font_lib/textures/font_default_00a1.png diff --git a/font_lib/textures/font_lib_b1.png b/font_lib/textures/font_default_00b1.png similarity index 100% rename from font_lib/textures/font_lib_b1.png rename to font_lib/textures/font_default_00b1.png diff --git a/font_lib/textures/font_lib_bf.png b/font_lib/textures/font_default_00bf.png similarity index 100% rename from font_lib/textures/font_lib_bf.png rename to font_lib/textures/font_default_00bf.png diff --git a/font_lib/textures/font_lib_c1.png b/font_lib/textures/font_default_00c1.png similarity index 100% rename from font_lib/textures/font_lib_c1.png rename to font_lib/textures/font_default_00c1.png diff --git a/font_lib/textures/font_lib_c2.png b/font_lib/textures/font_default_00c2.png similarity index 100% rename from font_lib/textures/font_lib_c2.png rename to font_lib/textures/font_default_00c2.png diff --git a/font_lib/textures/font_lib_c3.png b/font_lib/textures/font_default_00c3.png similarity index 100% rename from font_lib/textures/font_lib_c3.png rename to font_lib/textures/font_default_00c3.png diff --git a/font_lib/textures/font_lib_c4.png b/font_lib/textures/font_default_00c4.png similarity index 100% rename from font_lib/textures/font_lib_c4.png rename to font_lib/textures/font_default_00c4.png diff --git a/font_lib/textures/font_lib_c5.png b/font_lib/textures/font_default_00c5.png similarity index 100% rename from font_lib/textures/font_lib_c5.png rename to font_lib/textures/font_default_00c5.png diff --git a/font_lib/textures/font_lib_c6.png b/font_lib/textures/font_default_00c6.png similarity index 100% rename from font_lib/textures/font_lib_c6.png rename to font_lib/textures/font_default_00c6.png diff --git a/font_lib/textures/font_lib_c7.png b/font_lib/textures/font_default_00c7.png similarity index 100% rename from font_lib/textures/font_lib_c7.png rename to font_lib/textures/font_default_00c7.png diff --git a/font_lib/textures/font_lib_c8.png b/font_lib/textures/font_default_00c8.png similarity index 100% rename from font_lib/textures/font_lib_c8.png rename to font_lib/textures/font_default_00c8.png diff --git a/font_lib/textures/font_lib_c9.png b/font_lib/textures/font_default_00c9.png similarity index 100% rename from font_lib/textures/font_lib_c9.png rename to font_lib/textures/font_default_00c9.png diff --git a/font_lib/textures/font_lib_ca.png b/font_lib/textures/font_default_00ca.png similarity index 100% rename from font_lib/textures/font_lib_ca.png rename to font_lib/textures/font_default_00ca.png diff --git a/font_lib/textures/font_lib_cb.png b/font_lib/textures/font_default_00cb.png similarity index 100% rename from font_lib/textures/font_lib_cb.png rename to font_lib/textures/font_default_00cb.png diff --git a/font_lib/textures/font_lib_cc.png b/font_lib/textures/font_default_00cc.png similarity index 100% rename from font_lib/textures/font_lib_cc.png rename to font_lib/textures/font_default_00cc.png diff --git a/font_lib/textures/font_lib_cd.png b/font_lib/textures/font_default_00cd.png similarity index 100% rename from font_lib/textures/font_lib_cd.png rename to font_lib/textures/font_default_00cd.png diff --git a/font_lib/textures/font_lib_ce.png b/font_lib/textures/font_default_00ce.png similarity index 100% rename from font_lib/textures/font_lib_ce.png rename to font_lib/textures/font_default_00ce.png diff --git a/font_lib/textures/font_lib_cf.png b/font_lib/textures/font_default_00cf.png similarity index 100% rename from font_lib/textures/font_lib_cf.png rename to font_lib/textures/font_default_00cf.png diff --git a/font_lib/textures/font_lib_d0.png b/font_lib/textures/font_default_00d0.png similarity index 100% rename from font_lib/textures/font_lib_d0.png rename to font_lib/textures/font_default_00d0.png diff --git a/font_lib/textures/font_lib_d1.png b/font_lib/textures/font_default_00d1.png similarity index 100% rename from font_lib/textures/font_lib_d1.png rename to font_lib/textures/font_default_00d1.png diff --git a/font_lib/textures/font_lib_d2.png b/font_lib/textures/font_default_00d2.png similarity index 100% rename from font_lib/textures/font_lib_d2.png rename to font_lib/textures/font_default_00d2.png diff --git a/font_lib/textures/font_lib_d3.png b/font_lib/textures/font_default_00d3.png similarity index 100% rename from font_lib/textures/font_lib_d3.png rename to font_lib/textures/font_default_00d3.png diff --git a/font_lib/textures/font_lib_d4.png b/font_lib/textures/font_default_00d4.png similarity index 100% rename from font_lib/textures/font_lib_d4.png rename to font_lib/textures/font_default_00d4.png diff --git a/font_lib/textures/font_lib_d5.png b/font_lib/textures/font_default_00d5.png similarity index 100% rename from font_lib/textures/font_lib_d5.png rename to font_lib/textures/font_default_00d5.png diff --git a/font_lib/textures/font_lib_d6.png b/font_lib/textures/font_default_00d6.png similarity index 100% rename from font_lib/textures/font_lib_d6.png rename to font_lib/textures/font_default_00d6.png diff --git a/font_lib/textures/font_lib_d7.png b/font_lib/textures/font_default_00d7.png similarity index 100% rename from font_lib/textures/font_lib_d7.png rename to font_lib/textures/font_default_00d7.png diff --git a/font_lib/textures/font_lib_d8.png b/font_lib/textures/font_default_00d8.png similarity index 100% rename from font_lib/textures/font_lib_d8.png rename to font_lib/textures/font_default_00d8.png diff --git a/font_lib/textures/font_lib_d9.png b/font_lib/textures/font_default_00d9.png similarity index 100% rename from font_lib/textures/font_lib_d9.png rename to font_lib/textures/font_default_00d9.png diff --git a/font_lib/textures/font_lib_da.png b/font_lib/textures/font_default_00da.png similarity index 100% rename from font_lib/textures/font_lib_da.png rename to font_lib/textures/font_default_00da.png diff --git a/font_lib/textures/font_lib_db.png b/font_lib/textures/font_default_00db.png similarity index 100% rename from font_lib/textures/font_lib_db.png rename to font_lib/textures/font_default_00db.png diff --git a/font_lib/textures/font_lib_dc.png b/font_lib/textures/font_default_00dc.png similarity index 100% rename from font_lib/textures/font_lib_dc.png rename to font_lib/textures/font_default_00dc.png diff --git a/font_lib/textures/font_lib_dd.png b/font_lib/textures/font_default_00dd.png similarity index 100% rename from font_lib/textures/font_lib_dd.png rename to font_lib/textures/font_default_00dd.png diff --git a/font_lib/textures/font_lib_e0.png b/font_lib/textures/font_default_00e0.png similarity index 100% rename from font_lib/textures/font_lib_e0.png rename to font_lib/textures/font_default_00e0.png diff --git a/font_lib/textures/font_lib_e1.png b/font_lib/textures/font_default_00e1.png similarity index 100% rename from font_lib/textures/font_lib_e1.png rename to font_lib/textures/font_default_00e1.png diff --git a/font_lib/textures/font_lib_e2.png b/font_lib/textures/font_default_00e2.png similarity index 100% rename from font_lib/textures/font_lib_e2.png rename to font_lib/textures/font_default_00e2.png diff --git a/font_lib/textures/font_lib_e3.png b/font_lib/textures/font_default_00e3.png similarity index 100% rename from font_lib/textures/font_lib_e3.png rename to font_lib/textures/font_default_00e3.png diff --git a/font_lib/textures/font_lib_e4.png b/font_lib/textures/font_default_00e4.png similarity index 100% rename from font_lib/textures/font_lib_e4.png rename to font_lib/textures/font_default_00e4.png diff --git a/font_lib/textures/font_lib_e5.png b/font_lib/textures/font_default_00e5.png similarity index 100% rename from font_lib/textures/font_lib_e5.png rename to font_lib/textures/font_default_00e5.png diff --git a/font_lib/textures/font_lib_e6.png b/font_lib/textures/font_default_00e6.png similarity index 100% rename from font_lib/textures/font_lib_e6.png rename to font_lib/textures/font_default_00e6.png diff --git a/font_lib/textures/font_lib_e7.png b/font_lib/textures/font_default_00e7.png similarity index 100% rename from font_lib/textures/font_lib_e7.png rename to font_lib/textures/font_default_00e7.png diff --git a/font_lib/textures/font_lib_e8.png b/font_lib/textures/font_default_00e8.png similarity index 100% rename from font_lib/textures/font_lib_e8.png rename to font_lib/textures/font_default_00e8.png diff --git a/font_lib/textures/font_lib_e9.png b/font_lib/textures/font_default_00e9.png similarity index 100% rename from font_lib/textures/font_lib_e9.png rename to font_lib/textures/font_default_00e9.png diff --git a/font_lib/textures/font_lib_ea.png b/font_lib/textures/font_default_00ea.png similarity index 100% rename from font_lib/textures/font_lib_ea.png rename to font_lib/textures/font_default_00ea.png diff --git a/font_lib/textures/font_lib_eb.png b/font_lib/textures/font_default_00eb.png similarity index 100% rename from font_lib/textures/font_lib_eb.png rename to font_lib/textures/font_default_00eb.png diff --git a/font_lib/textures/font_lib_ec.png b/font_lib/textures/font_default_00ec.png similarity index 100% rename from font_lib/textures/font_lib_ec.png rename to font_lib/textures/font_default_00ec.png diff --git a/font_lib/textures/font_lib_ed.png b/font_lib/textures/font_default_00ed.png similarity index 100% rename from font_lib/textures/font_lib_ed.png rename to font_lib/textures/font_default_00ed.png diff --git a/font_lib/textures/font_lib_ee.png b/font_lib/textures/font_default_00ee.png similarity index 100% rename from font_lib/textures/font_lib_ee.png rename to font_lib/textures/font_default_00ee.png diff --git a/font_lib/textures/font_lib_ef.png b/font_lib/textures/font_default_00ef.png similarity index 100% rename from font_lib/textures/font_lib_ef.png rename to font_lib/textures/font_default_00ef.png diff --git a/font_lib/textures/font_lib_f2.png b/font_lib/textures/font_default_00f2.png similarity index 100% rename from font_lib/textures/font_lib_f2.png rename to font_lib/textures/font_default_00f2.png diff --git a/font_lib/textures/font_lib_f4.png b/font_lib/textures/font_default_00f4.png similarity index 100% rename from font_lib/textures/font_lib_f4.png rename to font_lib/textures/font_default_00f4.png diff --git a/font_lib/textures/font_lib_f5.png b/font_lib/textures/font_default_00f5.png similarity index 100% rename from font_lib/textures/font_lib_f5.png rename to font_lib/textures/font_default_00f5.png diff --git a/font_lib/textures/font_lib_f6.png b/font_lib/textures/font_default_00f6.png similarity index 100% rename from font_lib/textures/font_lib_f6.png rename to font_lib/textures/font_default_00f6.png diff --git a/font_lib/textures/font_lib_f7.png b/font_lib/textures/font_default_00f7.png similarity index 100% rename from font_lib/textures/font_lib_f7.png rename to font_lib/textures/font_default_00f7.png diff --git a/font_lib/textures/font_lib_f9.png b/font_lib/textures/font_default_00f9.png similarity index 100% rename from font_lib/textures/font_lib_f9.png rename to font_lib/textures/font_default_00f9.png diff --git a/font_lib/textures/font_lib_fa.png b/font_lib/textures/font_default_00fa.png similarity index 100% rename from font_lib/textures/font_lib_fa.png rename to font_lib/textures/font_default_00fa.png diff --git a/font_lib/textures/font_lib_fb.png b/font_lib/textures/font_default_00fb.png similarity index 100% rename from font_lib/textures/font_lib_fb.png rename to font_lib/textures/font_default_00fb.png diff --git a/font_lib/textures/font_lib_fc.png b/font_lib/textures/font_default_00fc.png similarity index 100% rename from font_lib/textures/font_lib_fc.png rename to font_lib/textures/font_default_00fc.png diff --git a/font_lib/textures/font_lib_fd.png b/font_lib/textures/font_default_00fd.png similarity index 100% rename from font_lib/textures/font_lib_fd.png rename to font_lib/textures/font_default_00fd.png diff --git a/font_lib/textures/font_lib_ff.png b/font_lib/textures/font_default_00ff.png similarity index 100% rename from font_lib/textures/font_lib_ff.png rename to font_lib/textures/font_default_00ff.png diff --git a/font_lib/tools/make_font_lua.sh b/font_lib/tools/make_font_lua.sh new file mode 100755 index 0000000..b751612 --- /dev/null +++ b/font_lib/tools/make_font_lua.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +scriptname=$0 +identify="identify" + +font_name=default + +for f in textures/font_${font_name}_????.png +do + if [[ $f =~ textures/font_${font_name}_([0-9a-fA-F]{4}).png ]] + then + code=$((16#${BASH_REMATCH[1]})) + size=$(identify $f | cut -d " " -f 3) + w=$(echo $size | cut -d "x" -f 1) + h=$(echo $size | cut -d "x" -f 2) + + if [ -z "$font_height" ] + then + font_height=$h + else + if [ $font_height -ne $h ] + then + echo "Error : $f as height of $h pixels, previous textures have a height of $font_height pixels. All textures should have the same height." + fi + fi + + if [ -z "$font_widths" ] + then + font_widths="[$code]=$w" + else + font_widths="$font_widths, [$code]=$w" + fi + fi +done + +echo "--[[ + +$luafile generated by $scriptname $(date) + +--]] + +font_lib.register_font( + '$font_name', + $font_height, + { $font_widths } +); +" > font_$font_name.lua +