What would be make this mod *really* amazing would be the ability to change font size from the editing dialog (even if it was for the entire sign rather than the differential colours you've acheived). It's always annoyed me how rubbish the classic signs look, and this gives the option of any font type you wish. (Of course even better would be autosizing to automatically calculate the maximum size possible on any given sign)
I admit I don't really understand what you are doing with your code, but it couldn't be that much slower to just add up the widths of all the characters rather than averaging. And that would also give you the option of accurate vertical and horizontal centering. Given that the texture is only built when the sign is edited (I think?), it wouldn't matter if it was a bit slow, after all how often do players actually edit signs. I'd love it (because I'd like to know how to create textures on the fly) if you explained it a bit more clearly...
BUG :-(
However there's a bug with the resizing of the fonts in signs_lib. I've just download the latest git and on 0.4.11
The larger the actual font size, the smaller it is displayed on the sign
Try the following to resize to a larger amount and see how microscopic it gets (or just copy the supplied fonts into the texture directory)...
Code: Select all
#!/usr/bin/python
from PIL import Image
import os, sys
pathOut = "/home/david/.minetest/mods/homedecor_modpack/signs_lib/textures/"
pathIn = "/home/david/.minetest/mods/homedecor_modpack/signs_lib/extra_fonts/34px/"
dirs = os.listdir( pathIn )
tgtHeight = 56
def resize():
for item in dirs:
if os.path.isfile(pathIn+item):
print(pathIn+item)
im = Image.open(pathIn+item)
f, e = os.path.splitext(pathOut+item)
tgtWidth = int(im.size[0]*(tgtHeight/im.size[1]))
size = tgtWidth,tgtHeight
imResize = im.resize(size, Image.ANTIALIAS)
imResize.save(f + '.png', 'PNG', quality=90)
resize()
However if you edit the code to
Code: Select all
-- Size of the canvas, in characters.
local CHARS_PER_LINE = 15
local NUMBER_OF_LINES = 1
Then I get the following (using 56px high font):-
And the following doing nothing but replacing the above font with a 15px high font in the textures directory.