1
0
mirror of https://github.com/gryf/wmdocklib.git synced 2025-12-30 18:32:30 +01:00

1577063: fonts are hard coded

added one more font (derived from 8x8zx, but without so much horizontal spacing).

modified the initPixmap so that it reads installed fonts.  they MUST be in
the same directory as the library itself.

the examples still have hard-coded fonts, but that's an other problem.
This commit is contained in:
mfrasca
2006-10-15 07:13:16 +00:00
parent 4d4b252dc0
commit 69c384e594
3 changed files with 71 additions and 8 deletions

View File

@@ -13,7 +13,9 @@ examples/sample.pywmsetirc
wmdocklib/5x7.xpm wmdocklib/5x7.xpm
wmdocklib/6x8.xpm wmdocklib/6x8.xpm
wmdocklib/6x8slant.xpm wmdocklib/6x8slant.xpm
wmdocklib/7x8zx.xpm
wmdocklib/8x8.xpm wmdocklib/8x8.xpm
wmdocklib/8x8zx.xpm
wmdocklib/README wmdocklib/README
wmdocklib/__init__.py wmdocklib/__init__.py
wmdocklib/pywmgeneral.c wmdocklib/pywmgeneral.c

57
wmdocklib/7x8zx.xpm Normal file
View File

@@ -0,0 +1,57 @@
/* XPM */
static char *_x_zx[] = {
/* columns rows colors chars-per-pixel */
"128 48 2 1",
"% c black",
" c gray100",
/* pixels */
" ",
" % % % %%% % %% % % % % % %%%% %% ",
" % % % % % %%%%% %% % % % % % % % % % % % %% % % ",
" % %%%% % % % % % % % % % % % % % ",
" % % %%%%% % % % % % % %%%%% %%%%% %%%%% % % % % % ",
" % % % % %% % % % % % % % %% % %% % % ",
" % %%%%%% %%%%% % %% %%% % % % % % % % %% % %%%% %%%%% ",
" % % ",
" ",
" %%%% %%%% % %%%%%% %%%% %%%%%% %%%% %%%% %%%% %%%% %%%% %%%%% %%%% ",
"% % % % %% % % % % % % % % % % % % % % % % % % % % % ",
" % %% % % %%%%% %%%%% % %%%% % % % % %%%%% % % % % %% % % %%%%% % ",
" %%%% % % % % % % % % % %%%%% % % % % %%%% %%%%%% % % % ",
"% % % %%%%%% % % % % % % % % % % %%%%% % % % % % % % % ",
"%%%%%% %%%% % %%%% %%%% % %%%% %%%% % % % % % %%%% % % %%%%% %%%% ",
" % ",
" ",
"%%%% %%%%%% %%%%%% %%%% % % %%%%% % % % % % % % % %%%% %%%%% %%%% %%%%% %%%% %%%%%%%% % ",
"% % % % % % % % % % % % % %% %% %% % % % % % % % % % % % % % ",
"% % %%%%% %%%%% % %%%%%% % % %%% % % %% % % % % % % % % % % % % %%%% % % % ",
"% % % % % %%% % % % % % % % % % % % % % % % %%%%% % % % %%%%% % % % % ",
"% % % % % % % % % % % % % % % % % %% % % % % % % % % % % % % % ",
"%%%% %%%%%% % %%%% % % %%%%% %%%% % % %%%%%% % % % % %%%% % %%%% % % %%%% % %%%% ",
" ",
" ",
"% % % % % % % %%%%%%% %%% %%% % % % % %% ",
"% % % % % % % % % % % % %%% % %%% % %%% % %%% % %%%%% ",
"% % % % %% % % % % % % % % % % %%%% % %%%% % % %% % % ",
"% % % % %% % % % % % % %%%% % % % % % %%%% % % % ",
" % % % %% % % % % % % % % % % % % % % % % % % %%%%% ",
" %% % % % % % %%%%%% %%% % %%% % %%%% %%%% %%% %%%% %%%% % % ",
" %%%%%%% %%%% ",
" ",
"% % % % % % ",
"% % % % %% % %%%% %%% %%%% %%%% %%% %%% %%% % % % % % % % % % % ",
"%%%% %% % %% % % % % % % % % % % % % % % % % % % % % % % % % % % ",
"% % % % %% % % % % % % % % % % % % % %%% % % % % % % % % % % % ",
"% % % % % % % % % % % % % % %%%% %%%% % % % % % % % % % % % % %%%% ",
"% % %%% % % % % %% % % % % % %%% % % % %%%% %% %%% % % % % % % ",
" %% % %% %%% ",
" ",
" %%% % %%% % % ",
"%%%%% % % % % % ",
" % %% % %% ",
" % % % % ",
" % % % % ",
"%%%%% %%% % %%% ",
" ",
" ",
};

View File

@@ -208,17 +208,21 @@ def initPixmap(xpm_background=None,
tile_width = width tile_width = width
tile_height = height tile_height = height
def charsize_from_fontname(font_name): def readFont(font_name):
import re # 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]+).*') import re
m = d.match(font_name) m = re.match(r'.*([0-9]+)x([0-9]+).*', font_name)
if not m: if not m:
raise ValueError("can't infer font size from name") raise ValueError("can't infer font size from name (does not contain wxh)")
return [int(item) for item in m.groups()] width, height = [int(item) for item in m.groups()]
return width, height, fontdef
global char_width, char_height global char_width, char_height
char_width, char_height = charsize_from_fontname(font_name) char_width, char_height, fontdef = readFont(font_name)
xpm = [ xpm = [
'128 112 %d 1' % (1+len(palette)), '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:] ' '*width + item[:128-width] for item in xpm_background[-margin-1:]
] + [ ] + [
line.replace('%', fg).replace(' ', bg) line.replace('%', fg).replace(' ', bg)
for line in char_defs[font_name] for line in fontdef
] ]
if 0: if 0:
print '/* XPM */\nstatic char *_x_[] = {' print '/* XPM */\nstatic char *_x_[] = {'