1
0
mirror of https://github.com/gryf/wmdocklib.git synced 2025-12-19 04:20:17 +01:00

1577063: fonts are hard coded

cleaning up and preparing the field.
This commit is contained in:
mfrasca
2006-10-14 20:55:00 +00:00
parent 9d1bae6ae6
commit 70f3fdf6a2
4 changed files with 79 additions and 34 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.3 #!/usr/bin/env python
"""pywmhdmon.py """pywmhdmon.py

View File

@@ -31,11 +31,11 @@ static char *square_[] = {
" ", " ",
" % % % %% % % %% ", " % % % %% % % %% ",
" % % % % % % % % % ", " % % % % % % % % % ",
" % %% % % %% % % % % % %%% ", " % %% % % %% % % % % % %% ",
" % % %%% % % % % %%% % % % % %%%% %%%% %%% %%%% %%%% %%%% % ", " % % %%% % % % % %%% % % % % %%%% %%%% %%% %%%% %%%% %%%% % ",
" %%%% %%%% % %%%% %%%% %%%% % %% %%%% %% %% %%% % % % % % % % % % % % % % %%% ", " %%%% %%%% % %%%% %%%% %%%% % %% %%%% %% %% %%% % % % % % % % % % % % % % %%% ",
" % % % % % % % % % % %% % % % % % % % % % % % % % % % %%%%% %%%% % % ", " % % % % % % % % % % %% % % % % % % % % % % % % % % % %%%%% %%%% % % ",
"%%%%%% %%%%% %%%%% %%%%% %%%%% %%%% % % % % %% % % % %% % % % % % %%%% % % % %%%%% ", "%%%%%% %%%%% %%%%% %%%%% %%%%% %%%% % % % % %% % % % %% % % % % % %%%% % % % %%% ",
" %% %%%% % % ", " %% %%%% % % ",
" % %%% % %% %%%%%% ", " % %%% % %% %%%%%% ",
" % % % % % % % ", " % % % % % % % ",

57
wmdocklib/8x8zx.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

@@ -184,7 +184,6 @@ def initPixmap(xpm_background=None,
palette['%x'%index] = getColorCode(name) palette['%x'%index] = getColorCode(name)
# palette = {'0':..., '1':..., ..., 'f':...} # palette = {'0':..., '1':..., ..., 'f':...}
# named_colours = {'black':'0', 'green': '1', ..., 'white':'f'}
if alter_palette is not None: if alter_palette is not None:
# alter_palette contains 0..15/chr -> 'name'/'#hex' # alter_palette contains 0..15/chr -> 'name'/'#hex'
@@ -197,29 +196,30 @@ def initPixmap(xpm_background=None,
v = getColorCode(v) v = getColorCode(v)
palette[k] = v palette[k] = v
if isinstance(bg, str) and len(bg)>1:
bg = named_colours.get(bg, 0)
if isinstance(fg, str) and len(fg)>1:
fg = named_colours.get(fg, 7)
if isinstance(bg, int): if isinstance(bg, int):
bg = '%x' % bg bg = '%x' % bg
if isinstance(fg, int): if isinstance(fg, int):
fg = '%x' % fg fg = '%x' % fg
if xpm_background is None: if xpm_background is None:
#xpm_background = ['0'*width]*4 + ['0000'+bg*(width-8)+'0000']*(height-8) + ['0'*width]*4
xpm_background = [bg*width]*height xpm_background = [bg*width]*height
global char_width, char_height, char_map
global tile_width, tile_height global tile_width, tile_height
char_width = char_defs[font_name]['width']
char_height = char_defs[font_name]['height']
char_map = char_defs[font_name]['map']
tile_width = width tile_width = width
tile_height = height tile_height = height
def charsize_from_fontname(font_name):
import re
d = re.compile(r'.*([0-9]+)x([0-9]+).*')
m = d.match(font_name)
if not m:
raise ValueError("can't infer font size from name")
return [int(item) for item in m.groups()]
global char_width, char_height
char_width, char_height = charsize_from_fontname(font_name)
xpm = [ xpm = [
'128 112 %d 1' % (1+len(palette)), '128 112 %d 1' % (1+len(palette)),
] + [ ] + [
@@ -235,7 +235,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_map for line in char_defs[font_name]
] ]
if 0: if 0:
print '/* XPM */\nstatic char *_x_[] = {' print '/* XPM */\nstatic char *_x_[] = {'
@@ -326,10 +326,7 @@ def getColorCode(colorName, rgbFileName=None):
return None return None
char_defs = { char_defs = {
'5x7': { '5x7': [
'width': 5,
'height': 7,
'map': [
" % % % % % % % % % %% %%%% % %%%% %% %%%% %% ", " % % % % % % % % % %% %%%% % %%%% %% %%%% %% ",
" % % % % % %%% % % % % % % % % % % % % %% % % % %% % % % % % ", " % % % % % %%% % % % % % % % % % % % % %% % % % %% % % % % % ",
" % % % %%%%%% % % % % % % % % % % % % % % %% % % %%% %%% % %% ", " % % % %%%%%% % % % % % % % % % % % % % % %% % % %%% %%% % %% ",
@@ -378,12 +375,8 @@ char_defs = {
" ", " ",
" ", " ",
" ", " ",
] ],
}, '6x8': [
'6x8': {
'width': 6,
'height': 8,
'map': [
" % % % % % % % % %% % % % %%% % %%% %%% % ", " % % % % % % % % %% % % % %%% % %%% %%% % ",
" % % % % % %%%% % % % % % % % % % % % % %% % % % % %% ", " % % % % % %%%% % % % % % % % % % % % % %% % % % % %% ",
" % % % %%%%% % % %% % % % % % % % % %% % % % % % ", " % % % %%%%% % % %% % % % % % % % % %% % % % % % ",
@@ -432,12 +425,8 @@ char_defs = {
" ", " ",
" ", " ",
" ", " ",
] ],
}, '8x8': [
'8x8': {
'width': 8,
'height': 8,
'map': [
" %% %% %% %% %% %% %% % %%%% %% %% %% ", " %% %% %% %% %% %% %% % %%%% %% %% %% ",
" %% %% %% %% %% %%%%% %% %% %% %% %% %% %% %% %% %% %%", " %% %% %% %% %% %%%%% %% %% %% %% %% %% %% %% %% %% %%",
" %% %% %% %%%%%%%% %% %% %%%% %% %% %% %%%% %% %% ", " %% %% %% %%%%%%%% %% %% %%%% %% %% %% %%%% %% %% ",
@@ -486,7 +475,6 @@ char_defs = {
" %%%%% %%%%% %% %% %% %% %% %%%% %%%%% %%%% %%%%% %% %% %% %% ", " %%%%% %%%%% %% %% %% %% %% %%%% %%%%% %%%% %%%%% %% %% %% %% ",
" %% %% %% %%%%% %%% %%%%% %% %% %% %% %% %% %%%%%% %%%% %% %%%% %%%%%%%%", " %% %% %% %%%%% %%% %%%%% %% %% %% %% %% %% %%%%%% %%%% %% %%%% %%%%%%%%",
" %% %% %%%% ", " %% %% %%%% ",
] ],
},
} }