Custom Fonts and Space Lengths

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Setzer
Posts: 124
Joined: Mon Mar 13, 2006 11:12 pm
Location: nowhereville

Custom Fonts and Space Lengths

Post by Setzer »

Once again, I've run myself into a wall here. A simple limitation has prevented me from implementing something, and while seeming rather trivial I have planned to put it to much greater purpose.

Image
Cropped from an in-game screenshot for size. Ignore the missing word.

As you can see, I have translated the Courier New font to ZDoom's font format. However, as I am sure all of you are familiar with, one of Courier's trademarks is how each character takes up the same amount of space. This has been accomplished easily, with the exception of one minor problem. As far as I can tell, the length of the space character is fixed at a lesser amount than I am looking for. In the above screenshot cropping, both lines have the same amount of characters but do not line up properly.

Oddly enough, this simple spacing is essential. I could spoil the purpose for you if necessary, but I would rather not.

Therefore, onward to my question. Is it currently possible to adjust the width of the space through an extra font image, or am I at odds once again? I wanted to ask first before I scrambled off to the feature request thread. Thank you in advance, kind souls.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Post by randi »

Include the space character in your source image. It's ASCII code 32, just before the exclamation mark. If you don't do that, then the length of the space is calculated as half the width of the capital letter N. (And if you don't have one of those, then it's always four pixels wide.)
User avatar
Setzer
Posts: 124
Joined: Mon Mar 13, 2006 11:12 pm
Location: nowhereville

Post by Setzer »

Great thanks to you, Randy! I am unfamiliar with the ASCII codes so I had no way to tell whether the space had an associated lump.

However, it still does not seem to be working correctly. To clarify, I am using FONTDEFS along with the Template keyword. Does this correctly check for spaces, or would it be better and more efficient to transform it to a FON2?

As an additional piece of info, what exactly is the character for ASCII code 96? There is apparently no appropriate STCFN*** lump in the wad so it is currently a blank image. Anything important I am missing?
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Post by Isle »

"`", not to beconfused with "'"
User avatar
X-DOOM
Posts: 541
Joined: Tue Jul 15, 2003 5:16 pm
Location: Charlesbourg, Québec, Canada
Contact:

Re: Custom Fonts and Space Lengths

Post by X-DOOM »

This is driving me nuts for the last 3 hours, i cannot get the space character to work on my FONTDEFS.txt file

Code: Select all

BGFNT1
{
	  stbfn032
	! stbfn034
	" stbfn035
	# stbfn036
	$ stbfn037
	% stbfn038
	' stbfn039
	( stbfn040
	) stbfn041
	* stbfn042
	+ stbfn043
	, stbfn044
	- stbfn045
	. stbfn046
	/ stbfn047
	0 stbfn048
	1 stbfn049
	2 stbfn050
	3 stbfn051
	4 stbfn052
	5 stbfn053
	6 stbfn054
	7 stbfn055
	8 stbfn056
	9 stbfn057
	: stbfn058
	; stbfn059
	< stbfn060
	= stbfn061
	> stbfn062
	? stbfn063
	@ stbfn064
	a stbfn065
	b stbfn066
	c stbfn067
	d stbfn068
	e stbfn069
	f stbfn070
	g stbfn071
	h stbfn072
	i stbfn073
	j stbfn074
	k stbfn075
	l stbfn076
	m stbfn077
	n stbfn078
	o stbfn079
	p stbfn080
	q stbfn081
	r stbfn082
	s stbfn083
	t stbfn084
	u stbfn085
	v stbfn086
	w stbfn087
	x stbfn088
	y stbfn089
	z stbfn090
	( stbfn091
	\ stbfn092
	) stbfn093
	^ stbfn094
	_ stbfn095
	| stbfn121
	A stbfn065
	B stbfn066
	C stbfn067
	D stbfn068
	E stbfn069
	F stbfn070
	G stbfn071
	H stbfn072
	I stbfn073
	J stbfn074
	K stbfn075
	L stbfn076
	M stbfn077
	N stbfn078
	O stbfn079
	P stbfn080
	Q stbfn081
	R stbfn082
	S stbfn083
	T stbfn084
	U stbfn085
	V stbfn086
	W stbfn087
	X stbfn088
	Y stbfn089
	Z stbfn090
}

SMFNT1
{
	  stcfn032
	! stcfn034
	" stcfn035
	# stcfn036
	$ stcfn037
	% stcfn038
	' stcfn039
	( stcfn040
	) stcfn041
	* stcfn042
	+ stcfn043
	, stcfn044
	- stcfn045
	. stcfn046
	/ stcfn047
	0 stcfn048
	1 stcfn049
	2 stcfn050
	3 stcfn051
	4 stcfn052
	5 stcfn053
	6 stcfn054
	7 stcfn055
	8 stcfn056
	9 stcfn057
	: stcfn058
	; stcfn059
	< stcfn060
	= stcfn061
	> stcfn062
	? stcfn063
	@ stcfn064
	a stcfn065
	b stcfn066
	c stcfn067
	d stcfn068
	e stcfn069
	f stcfn070
	g stcfn071
	h stcfn072
	i stcfn073
	j stcfn074
	k stcfn075
	l stcfn076
	m stcfn077
	n stcfn078
	o stcfn079
	p stcfn080
	q stcfn081
	r stcfn082
	s stcfn083
	t stcfn084
	u stcfn085
	v stcfn086
	w stcfn087
	x stcfn088
	y stcfn089
	z stcfn090
	( stcfn091
	\ stcfn092
	) stcfn093
	^ stcfn094
	_ stcfn095
	| stcfn121
	A stcfn065
	B stcfn066
	C stcfn067
	D stcfn068
	E stcfn069
	F stcfn070
	G stcfn071
	H stcfn072
	I stcfn073
	J stcfn074
	K stcfn075
	L stcfn076
	M stcfn077
	N stcfn078
	O stcfn079
	P stcfn080
	Q stcfn081
	R stcfn082
	S stcfn083
	T stcfn084
	U stcfn085
	V stcfn086
	W stcfn087
	X stcfn088
	Y stcfn089
	Z stcfn090
}

Everytime i launch the game i get a zdoom error on the launcher.
i know its sure its from the space from stbfn032 and stcfn032

The error code:

Code: Select all

OS: Windows XP (NT 5.1) Build 2600
    Service Pack 3
M_LoadDefaults: Load system defaults.
W_Init: Init WADfiles.
 adding F:/ZDoom/zdoom.pk3, 558 lumps
 adding F:/ZDoom/DOOM2.WAD, 2919 lumps
 adding F:/ZDoom/zd3k, 7026 lumps
 adding F:/ZDoom/zd3k/maps/titlemap.wad, 13 lumps
 adding C:/Documents and Settings/Jeff2/Local Settings/Temp/kteig023/8zrmx8rl.wad, 13 lumps
I_Init: Setting up machine state.
CPU Speed: 2400 MHz
CPU Vendor ID: GenuineIntel
  Name: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
  Family 6, Model 15, Stepping 11
  Features: MMX SSE SSE2 SSE3 SSSE3
I_InitSound: Initializing FMOD
FMOD Sound System, copyright © Firelight Technologies Pty, Ltd., 1994-2009.
Loaded FMOD version 4.26.36
V_Init: allocate screen.
S_Init: Setting up sound.
ST_Init: Init startup screen.
Checking cmd-line parameters...
G_ParseMapInfo: Load map definitions.
S_InitData: Load sound definitions.
Texman.Init: Init texture manager.
ANIMDEFS: Can't find comp_d1
ParseTeamInfo: Load team definitions.
LoadActors: Load actor definitions.
R_Init: Init Doom refresh subsystem.
Script error, ":FONTDEFS.txt" line 4:
!: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 99:
 stbfn035
	# stbfn036
	$ stbfn037
	% stbfn038
	' stbfn039
	( stbfn040
	) stbfn041
	* stbfn042
	+ stbfn043
	, stbfn044
	- stbfn045
	. stbfn046
	/ stbfn047
	0 stbfn048
	1 stbfn049
	2 stbfn050
	3 stbfn051
	4 stbfn052
	5 stbfn053
	6 stbfn054
	7 stbfn055
	8 stbfn056
	9 stbfn057
	: stbfn058
	; stbfn059
	< stbfn060
	= stbfn061
	> stbfn062
	? stbfn063
	@ stbfn064
	a stbfn065
	b stbfn066
	c stbfn067
	d stbfn068
	e stbfn069
	f stbfn070
	g stbfn071
	h stbfn072
	i stbfn073
	j stbfn074
	k stbfn075
	l stbfn076
	m stbfn077
	n stbfn078
	o stbfn079
	p stbfn080
	q stbfn081
	r stbfn082
	s stbfn083
	t stbfn084
	u stbfn085
	v stbfn086
	w stbfn087
	x stbfn088
	y stbfn089
	z stbfn090
	( stbfn091
	\ stbfn092
	) stbfn093
	^ stbfn094
	_ stbfn095
	| stbfn121
	A stbfn065
	B stbfn066
	C stbfn067
	D stbfn068
	E stbfn069
	F stbfn070
	G stbfn071
	H stbfn072
	I stbfn073
	J stbfn074
	K stbfn075
	L stbfn076
	M stbfn077
	N stbfn078
	O stbfn079
	P stbfn080
	Q stbfn081
	R stbfn082
	S stbfn083
	T stbfn084
	U stbfn085
	V stbfn086
	W stbfn087
	X stbfn088
	Y stbfn089
	Z stbfn090
}

SMFNT1
{
	  stcfn032
	! stcfn034
	: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 100:
#: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 101:
$: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 102:
%: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 103:
': Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 104:
(: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 105:
): Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 106:
*: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 107:
+: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 108:
,: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 110:
.: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 111:
/: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 122:
:: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 124:
<: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 125:
=: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 126:
>: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 127:
?: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 128:
@: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 129:
a: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 130:
b: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 131:
c: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 132:
d: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 133:
e: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 134:
f: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 135:
g: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 136:
h: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 137:
i: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 138:
j: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 139:
k: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 140:
l: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 141:
m: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 142:
n: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 144:
p: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 145:
q: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 146:
r: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 147:
s: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 148:
t: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 149:
u: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 150:
v: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 151:
w: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 152:
x: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 153:
y: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 154:
z: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 155:
(: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 156:
\: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 157:
): Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 158:
^: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 159:
_: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 160:
|: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 161:
A: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 162:
B: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 163:
C: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 164:
D: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 165:
E: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 166:
F: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 167:
G: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 168:
H: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 169:
I: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 170:
J: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 171:
K: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 172:
L: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 173:
M: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 174:
N: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 176:
P: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 177:
Q: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 178:
R: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 179:
S: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 180:
T: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 181:
U: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 182:
V: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 183:
W: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 184:
X: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 185:
Y: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 186:
Z: Unable to find texture in font definition for BGFNT1
Script error, ":FONTDEFS.txt" line 187:
}: Unable to find texture in font definition for BGFNT1

Execution could not continue.

Script error, ":FONTDEFS.txt" line 192:
Missing string (unexpected end of file).

Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Custom Fonts and Space Lengths

Post by Gez »

X-DOOM wrote:This is driving me nuts for the last 3 hours, i cannot get the space character to work on my FONTDEFS.txt file

Code: Select all

BGFNT1
{
	  stbfn032
This is never going to work. The parser ignores whitespace, and here you are trying to get it to parse a space as a character.

You should use a template. See [wiki]FONTDEFS[/wiki] article.

Code: Select all

BGFNT1
{
	  base 32
          first 32
          count 224
          template STBFN%03d
}
You use "first 32" to tell that the first character defined in the font is char 32 (which is the space). You use base 32 to tell that the first character will have 32 in its lump name. You use a count of 224 to let it go from 32 to 255, so the entire ASCII range can be covered. And you use the template to let ZDoom automatically match each lump with the corresponding character code.

The other font is exactly the same code, except you use STCFN%03d in the template line and of course the font name is different.
User avatar
X-DOOM
Posts: 541
Joined: Tue Jul 15, 2003 5:16 pm
Location: Charlesbourg, Québec, Canada
Contact:

Re: Custom Fonts and Space Lengths

Post by X-DOOM »

Well i tried what you said and it still bugs out.

Code: Select all

BGFNT1
{
     base 32
          first 32
          count 224
          template STBFN%03d stbfn032
}
stbfn032 is a single 8x16 pixel file with transparent cyan for making the space character (stbfn032.png)
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Custom Fonts and Space Lengths

Post by Gez »

X-DOOM wrote:Well i tried what you said and it still bugs out.
No, you didn't; and of course it does.

I said:

Code: Select all

BGFNT1
{
          base 32
          first 32
          count 224
          template STBFN%03d
}
You write:

Code: Select all

BGFNT1
{
     base 32
          first 32
          count 224
          template STBFN%03d stbfn032
}
Which is not the same thing.
X-DOOM wrote:transparent cyan
Please do not get me started on the transparency of cyan.


Anyway: the only way to explicitly define a space character in a font is to do exactly as I said. Adding or removing random strings isn't going to make it work.

However, if your space is entirely transparent, why bother defining it at all? You don't need that character. You can use the spacewidth keyword instead if the automatically-computed space width (half the width of the letter N) does not suit you.
User avatar
X-DOOM
Posts: 541
Joined: Tue Jul 15, 2003 5:16 pm
Location: Charlesbourg, Québec, Canada
Contact:

Re: Custom Fonts and Space Lengths

Post by X-DOOM »

Gez wrote: Please do not get me started on the transparency of cyan.
Im sorry, i tend to explain myself a bit too much... Very often :mrgreen:



Gez, the problem is everytime i try to use my font, it always replace the space by a # which i dont understand since i did not added any space image.
I should post you a screenshot.

Gez, thanks for helping me btw :)
Locked

Return to “Editing (Archive)”