mirror of
https://github.com/freedoom/freedoom.git
synced 2025-09-04 04:25:46 -04:00
textgen: Reduce height of lowercase graphics.
If a text string contains all lower-case characters, then generate it at a reduced height. This is necessary for certain graphics, like the WIF graphic ("FINISHED") on the intermission screen, otherwise it ends up in the wrong location (#49). Adjust the offsets for some graphics in the build config to compensate, and fix up the vertical offsets for WICOLON/WIMINUS while we're at it.
This commit is contained in:
parent
0820d14925
commit
eb7d4fb280
2 changed files with 18 additions and 8 deletions
12
buildcfg.txt
12
buildcfg.txt
|
@ -799,8 +799,8 @@ M_THERML -2 0
|
||||||
M_ENDGAM 0 1
|
M_ENDGAM 0 1
|
||||||
M_PAUSE 0 0
|
M_PAUSE 0 0
|
||||||
M_MESSG 0 1
|
M_MESSG 0 1
|
||||||
M_MSGON 0 1
|
M_MSGON 0 -3
|
||||||
M_MSGOFF 0 1
|
M_MSGOFF 0 -3
|
||||||
M_HURT 0 0
|
M_HURT 0 0
|
||||||
M_JKILL 0 0
|
M_JKILL 0 0
|
||||||
M_ROUGH 0 0
|
M_ROUGH 0 0
|
||||||
|
@ -814,8 +814,8 @@ M_SAVEG 0 0
|
||||||
M_LOADG 0 0
|
M_LOADG 0 0
|
||||||
M_DISP 0 0
|
M_DISP 0 0
|
||||||
M_MSENS 0 1
|
M_MSENS 0 1
|
||||||
M_GDHIGH -20 1
|
M_GDHIGH -20 -3
|
||||||
M_GDLOW -20 1
|
M_GDLOW -20 -3
|
||||||
M_DETAIL 0 1
|
M_DETAIL 0 1
|
||||||
M_DISOPT 0 0
|
M_DISOPT 0 0
|
||||||
M_SCRNSZ 0 1
|
M_SCRNSZ 0 1
|
||||||
|
@ -881,7 +881,7 @@ WIOSTF 0 0
|
||||||
WITIME 0 0
|
WITIME 0 0
|
||||||
WIPAR 0 0
|
WIPAR 0 0
|
||||||
WIMSTAR 0 0
|
WIMSTAR 0 0
|
||||||
WIMINUS 0 -5
|
WIMINUS 0 0
|
||||||
WIPCNT 0 0
|
WIPCNT 0 0
|
||||||
WINUM0 0 0
|
WINUM0 0 0
|
||||||
WINUM1 0 0
|
WINUM1 0 0
|
||||||
|
@ -893,7 +893,7 @@ WINUM6 0 0
|
||||||
WINUM7 0 0
|
WINUM7 0 0
|
||||||
WINUM8 0 0
|
WINUM8 0 0
|
||||||
WINUM9 0 0
|
WINUM9 0 0
|
||||||
WICOLON 0 -1
|
WICOLON 0 0
|
||||||
WISUCKS 0 0
|
WISUCKS 0 0
|
||||||
WIFRGS 0 0
|
WIFRGS 0 0
|
||||||
WIP1 0 0
|
WIP1 0 0
|
||||||
|
|
|
@ -55,6 +55,7 @@ BACKGROUND_COLOR = '#00ffff'
|
||||||
|
|
||||||
# Height of font in pixels.
|
# Height of font in pixels.
|
||||||
FONT_HEIGHT = 16
|
FONT_HEIGHT = 16
|
||||||
|
FONT_LC_HEIGHT = 12
|
||||||
|
|
||||||
# Width of a space character in pixels.
|
# Width of a space character in pixels.
|
||||||
SPACE_WIDTH = 10
|
SPACE_WIDTH = 10
|
||||||
|
@ -63,6 +64,9 @@ SPACE_WIDTH = 10
|
||||||
# fontchars/font033.gif GIF 9x16 9x16+0+0 8-bit sRGB 32c 194B 0.000u 0:00.000
|
# fontchars/font033.gif GIF 9x16 9x16+0+0 8-bit sRGB 32c 194B 0.000u 0:00.000
|
||||||
IDENTIFY_OUTPUT_RE = re.compile(r'(\S+)\s(\S+)\s(\d+)x(\d+)\s')
|
IDENTIFY_OUTPUT_RE = re.compile(r'(\S+)\s(\S+)\s(\d+)x(\d+)\s')
|
||||||
|
|
||||||
|
# Regexp to identify strings that are all lowercase (can use shorter height)
|
||||||
|
LOWERCASE_RE = re.compile(r'^[a-z\!\. ]*$')
|
||||||
|
|
||||||
def get_image_dimensions(filename):
|
def get_image_dimensions(filename):
|
||||||
proc = subprocess.Popen([IDENTIFY_COMMAND, filename],
|
proc = subprocess.Popen([IDENTIFY_COMMAND, filename],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
|
@ -173,9 +177,14 @@ class Font(object):
|
||||||
"""Command line construction helper, used in render functions"""
|
"""Command line construction helper, used in render functions"""
|
||||||
width = self.text_width(text)
|
width = self.text_width(text)
|
||||||
|
|
||||||
|
if LOWERCASE_RE.match(text):
|
||||||
|
height = FONT_LC_HEIGHT
|
||||||
|
else:
|
||||||
|
height = FONT_HEIGHT
|
||||||
|
|
||||||
command_line = [
|
command_line = [
|
||||||
CONVERT_COMMAND,
|
CONVERT_COMMAND,
|
||||||
'-size', '%ix%i' % (width, FONT_HEIGHT),
|
'-size', '%ix%i' % (width, height),
|
||||||
'xc:none',
|
'xc:none',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -186,7 +195,8 @@ class Font(object):
|
||||||
filename = self.char_filename(c)
|
filename = self.char_filename(c)
|
||||||
command_line.extend([
|
command_line.extend([
|
||||||
'-draw',
|
'-draw',
|
||||||
'image over %i,0 0,0 %s' % (x, filename)
|
'image over %i,%i 0,0 %s' %
|
||||||
|
(x, height - FONT_HEIGHT, filename)
|
||||||
])
|
])
|
||||||
|
|
||||||
command_line.extend([
|
command_line.extend([
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue