diff --git a/MANIFEST b/MANIFEST index 4125ff2..136358b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -13,7 +13,9 @@ examples/sample.pywmsetirc wmdocklib/5x7.xpm wmdocklib/6x8.xpm wmdocklib/6x8slant.xpm +wmdocklib/7x8zx.xpm wmdocklib/8x8.xpm +wmdocklib/8x8zx.xpm wmdocklib/README wmdocklib/__init__.py wmdocklib/pywmgeneral.c diff --git a/wmdocklib/7x8zx.xpm b/wmdocklib/7x8zx.xpm new file mode 100644 index 0000000..124584b --- /dev/null +++ b/wmdocklib/7x8zx.xpm @@ -0,0 +1,57 @@ +/* XPM */ +static char *_x_zx[] = { +/* columns rows colors chars-per-pixel */ +"128 48 2 1", +"% c black", +" c gray100", +/* pixels */ +" ", +" % % % %%% % %% % % % % % %%%% %% ", +" % % % % % %%%%% %% % % % % % % % % % % % %% % % ", +" % %%%% % % % % % % % % % % % % % ", +" % % %%%%% % % % % % % %%%%% %%%%% %%%%% % % % % % ", +" % % % % %% % % % % % % % %% % %% % % ", +" % %%%%%% %%%%% % %% %%% % % % % % % % %% % %%%% %%%%% ", +" % % ", +" ", +" %%%% %%%% % %%%%%% %%%% %%%%%% %%%% %%%% %%%% %%%% %%%% %%%%% %%%% ", +"% % % % %% % % % % % % % % % % % % % % % % % % % % % ", +" % %% % % %%%%% %%%%% % %%%% % % % % %%%%% % % % % %% % % %%%%% % ", +" %%%% % % % % % % % % % %%%%% % % % % %%%% %%%%%% % % % ", +"% % % %%%%%% % % % % % % % % % % %%%%% % % % % % % % % ", +"%%%%%% %%%% % %%%% %%%% % %%%% %%%% % % % % % %%%% % % %%%%% %%%% ", +" % ", +" ", +"%%%% %%%%%% %%%%%% %%%% % % %%%%% % % % % % % % % %%%% %%%%% %%%% %%%%% %%%% %%%%%%%% % ", +"% % % % % % % % % % % % % %% %% %% % % % % % % % % % % % % % ", +"% % %%%%% %%%%% % %%%%%% % % %%% % % %% % % % % % % % % % % % % %%%% % % % ", +"% % % % % %%% % % % % % % % % % % % % % % % %%%%% % % % %%%%% % % % % ", +"% % % % % % % % % % % % % % % % % %% % % % % % % % % % % % % % ", +"%%%% %%%%%% % %%%% % % %%%%% %%%% % % %%%%%% % % % % %%%% % %%%% % % %%%% % %%%% ", +" ", +" ", +"% % % % % % % %%%%%%% %%% %%% % % % % %% ", +"% % % % % % % % % % % % %%% % %%% % %%% % %%% % %%%%% ", +"% % % % %% % % % % % % % % % % %%%% % %%%% % % %% % % ", +"% % % % %% % % % % % % %%%% % % % % % %%%% % % % ", +" % % % %% % % % % % % % % % % % % % % % % % % %%%%% ", +" %% % % % % % %%%%%% %%% % %%% % %%%% %%%% %%% %%%% %%%% % % ", +" %%%%%%% %%%% ", +" ", +"% % % % % % ", +"% % % % %% % %%%% %%% %%%% %%%% %%% %%% %%% % % % % % % % % % % ", +"%%%% %% % %% % % % % % % % % % % % % % % % % % % % % % % % % % % ", +"% % % % %% % % % % % % % % % % % % % %%% % % % % % % % % % % % ", +"% % % % % % % % % % % % % % %%%% %%%% % % % % % % % % % % % % %%%% ", +"% % %%% % % % % %% % % % % % %%% % % % %%%% %% %%% % % % % % % ", +" %% % %% %%% ", +" ", +" %%% % %%% % % ", +"%%%%% % % % % % ", +" % %% % %% ", +" % % % % ", +" % % % % ", +"%%%%% %%% % %%% ", +" ", +" ", +}; diff --git a/wmdocklib/pywmhelpers.py b/wmdocklib/pywmhelpers.py index 80dc581..8ab6eb8 100644 --- a/wmdocklib/pywmhelpers.py +++ b/wmdocklib/pywmhelpers.py @@ -208,17 +208,21 @@ def initPixmap(xpm_background=None, tile_width = width tile_height = height - def charsize_from_fontname(font_name): - import re + def readFont(font_name): + # read xpm, skip header and color definitions, fill/trim to 48 lines. + fontdef = readXPM(__file__[:__file__.rfind(os.sep) + 1] + font_name + '.xpm') + fontdef = fontdef[1 + int(fontdef[0].split(' ')[2]):] + fontdef = (fontdef + [' '*128]*48)[:48] - d = re.compile(r'.*([0-9]+)x([0-9]+).*') - m = d.match(font_name) + import re + m = re.match(r'.*([0-9]+)x([0-9]+).*', font_name) if not m: - raise ValueError("can't infer font size from name") - return [int(item) for item in m.groups()] + raise ValueError("can't infer font size from name (does not contain wxh)") + width, height = [int(item) for item in m.groups()] + return width, height, fontdef global char_width, char_height - char_width, char_height = charsize_from_fontname(font_name) + char_width, char_height, fontdef = readFont(font_name) xpm = [ '128 112 %d 1' % (1+len(palette)), @@ -235,7 +239,7 @@ def initPixmap(xpm_background=None, ' '*width + item[:128-width] for item in xpm_background[-margin-1:] ] + [ line.replace('%', fg).replace(' ', bg) - for line in char_defs[font_name] + for line in fontdef ] if 0: print '/* XPM */\nstatic char *_x_[] = {'