Generating JK2 font from .ttf

Discussions about modding, questions, mod requests or just show off what you're working on.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Generating JK2 font from .ttf

Post by fau »

Are there any tools for this out there?
JK2's fontgen is not available, I got fontgen.exe from EF2 SDK, but it uses different format and there is no source. Currently I'm trying to make ioq3 generate images+data and then convert the data to jk2 format. I think this is the fastest approach (in opposite to figuring out jk2 glyph format/printing details and writing a generator using freetype).

I just thought I'd better ask first here, in case there are tools/guides I missed.
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Perfect, you stopped me from writing it myself :-)
There is also 0.0.2 version with Cyrilic support: http://jkhub.org/files/file/2250-jafont/

I was thinking of including higher res fonts, especially the medium font (ergoec - Ergoe Black Condensed 14pt) gets often upscaled in a very ugly fashion (following message, warmup, map restart etc.)

I'm trying to figure out if it's legal to upload them to github and ship with my mod.

If I understand correctly glyphs and typefaces aren't patentable in US and in most countries, and even if they get a design patent it expires after max 25 years in EU (Ergoe was first published in 92 or earlier). What is actually protected by law is a computer program in ttf, otf and other formats. Source: https://en.wikipedia.org/wiki/Intellect ... _typefaces

Actually I strongly suspect that id software didn't pay a dime for their quake fonts:

Code: Select all

// As of Q3A 1.25+ and Team Arena, we are shipping the game with the font rendering code
// disabled. This removes any potential patent issues and it keeps us from having to 
// distribute an actual TrueTrype font which is 1. expensive to do and 2. seems to require
// an act of god to accomplish.
PS: By the way, using freetype lib in C/C++ is super fast and simple and if you ever need to render some high quality glyphs manually - don't hestitate.
Attachments
shot0000.jpg
shot0000.jpg (92.55 KiB) Viewed 99111 times
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

Nice, one of my mod features is the fix of 2D hud streched rendering, so i need take a look on fonts too, i tried some fonts, actually is easy to generate ttf fonts, or convert fonts from otf, woff or eot. Most of fonts are free to use nowadays, and there is a lot of alternatives for paid fonts too, i work alot with these stuff in web development.

Image
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Yes, hud stretch is another thing to fix. Fonts get stretched on different resolutions - this is bad. You really don't want to stretch anti-aliased fonts I'm gonna give it a thought soon. First thing that comes to my mind is generating a palette of font textures in various sizes and using the closest match. On second thought, the engine limits us to 6 fonts total so it's a no go. Another solution is rendering ttf fonts in the engine as needed (it's really simple with freetype), but it would be a copyright violation I guess. Lets see:

* ocr-a - OCR-A is a standard and there are free scalable "implementations" available.
* ergoec - Ergoe Extrabold Condensed by Weatherly Systems, Inc. (doesn't exist anymore) was released in 92 or earlier and ttf fonts are being distributed freely nowadays. Dunno about their legal status. Probably not free to redistribute.
* newhope - New Hope by Greg Kegel (c) 1998 - ttf font is available but dunno about it's leagal status - at least we could mail him.

Or maybe we can just use these ttf fonts available online? No idea.
Last edited by fau on 05 Jan 2016, 01:15, edited 1 time in total.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

actually is easy to generate ttf fonts, or convert fonts from otf, woff or eot.
No need to. JAfont uses freetype which supports otf and many other formats.
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

fau wrote: No need to. JAfont uses freetype which supports otf and many other formats.
yeah :P i hope JAfont can help you
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
Boothand
Administrator
Posts: 986
Joined: 24 Feb 2015, 08:21
Contact:

Re: Generating JK2 font from .ttf

Post by Boothand »

I didn't know you could do this :D Interesting.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Nope, this jafont program doesn't work well for jk2 on second glimpse. Gonna see into it.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Fixed the issue with JAfont program. I'm gonna ping the original author or post a patch in a day or two, when I'm sure everything is ok.
User avatar
Boothand
Administrator
Posts: 986
Joined: 24 Feb 2015, 08:21
Contact:

Re: Generating JK2 font from .ttf

Post by Boothand »

More screenshots plzz! More crazy fonts.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

I'm done for today. I'm not sure about the direction it's going. Super-crisp fonts look misplaced on top of low res textures (although q3 engine doesn't look blury at all, I know for a fact that my intel gfx makes things a little bit worse). I think I'm going to balance things out, use lower res glyphs and only when old font would need to be scaled by the factor of 2 or more. What do you think?

edit: I forgot that what you can see on following screenshot is actually upscaled lower res font (1.5 of original) tested with this idea in mind. It can look even crisper, too crisp for my liking. Gonna upload screenshot tomorrow or later.

I had quite a struggle with this jafont utility, I think it would have been faster had I written it from scratch :/

I haven't touched charsgrid_med font, looks pretty generic but I'm afraid it may be hand-crafted by ef2 devs. I'm probably just gonna replace it or not use at all.

Work in progress on screenshot below. Just generated anewhope font, gonna work on it another day.

Image

PS It was Ergoe Extrabold Condensed rather than Ergoe Black Condensed, my fault :-( Although "following Desann" message from ss from the first post in this topic looks fresh, I liked it better.
User avatar
ouned
Administrator
Posts: 596
Joined: 23 Feb 2015, 13:03
Location: Gliese581c

Re: Generating JK2 font from .ttf

Post by ouned »

still looks nice @fau
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

i preffer the ergoe extrabold condensed instead the black condensed :P so... do u want replace all fonts? im really interested on this work.

PS: i cant see the screenshot :/
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Ok, I've prepared a beta version of my patch + prerendered fonts, so please don't use it in your mods yet. Just download, rename to .pk3 put into a new mod-folder and test in game (1.04). I'm going to replace few fonts for sure, review and refactor the code. Feel free to report any issues though.

Notes for testers/users:
  • It won't work in jk2mv's main menu.
  • Bind "ui_fontSharpness !" to easily compare with original fonts in-game.
  • I haven't tested it with jk2mp.exe, please do it for me.
Notes for devs:

There is a patch you can review here: https://github.com/aufau/jk2sdk-gpl/com ... c5fa9?ts=4
It reads a whole font face rather than a single file - eg when you register "ergoec" it actually tries to load ergoec, ergoec1, ..., ergoec5 and picks the best match when printing text. I define best match as the largest font that doesn't get downscaled, as vertical downscalling produces some ugly artifacts here (especially on ergoec font, with glyphs that don't stick to the baseline).

You can affect the picking process with ui_fontSharpness cvar, or even disable it completely by setting it to 0. If you've got a better name for the cvar let me know but ui_fontQuality won't do - I believe setting it to 1 gives you the best quality.

I haven't touched the charsgrid_med font yet. Can you recognize it perhaps? It's in assets gfx/2d/charsgrid_med.tga and there are no clues to it's origin.

I'm going to release all tools/patches I wrote for creating your own jk2 bitmap fonts later.
Attachments
better-fonts.zip
(970.22 KiB) Downloaded 1541 times
Last edited by fau on 14 Jan 2016, 13:43, edited 1 time in total.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Few thoughts on implementation:
I see 3 ways to improve font quality and each has it's own issues
  1. Freetype support in jk2mv - jk2 original ttf fonts are not free and you wouldn't be able to distribute them legaly. Also it would be harder to code properly.
  2. What I did here - only works if you use a patched cgame/ui and we can't patch some popular and wide-spread cgame mods. Doesn't work in jk2mv main menu (this could be fixed eventually though).
  3. What I did here, implemented in jk2mv client - Won't work with jk2mp.exe, it's very chocolate and I feel jk2mv is more on a vanilla side. Maybe this is the way to go? Let's hear what daggo/ouned have to say about it.
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

nice,i will try today :P

i know is a beta, so i will try with the basejk

I 'll be commenting
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Tr!Force wrote:nice,i will try today :P

i know is a beta, so i will try with the basejk

I 'll be commenting
.zip archive I attached contains patched cgame.qvm and ui.qvm so don't put it in base, put it in a new mod-directory.
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

fau wrote:
Tr!Force wrote:nice,i will try today :P

i know is a beta, so i will try with the basejk

I 'll be commenting
.zip archive I attached contains patched cgame.qvm and ui.qvm so don't put it in base, put it in a new mod-directory.
ya, i mean with basejk = without another mods :D

in another topic, about this:
What I did here, implemented in jk2mv client - Won't work with jk2mp.exe, it's very chocolate and I feel jk2mv is more on a vanilla side. Maybe this is the way to go? Let's hear what daggo/ouned have to say about it.
i think if we will use jk2mv, and, if we are trying to let people use jk2mv, we should make mods which requires jk2mv.
also we have jk2mv API too, is a good adition to improve our mods, and we need try to get people to stop using the normal jk2
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
Kevin
Administrator
Posts: 393
Joined: 07 Jun 2015, 08:36

Re: Generating JK2 font from .ttf

Post by Kevin »

Tr!Force wrote: i think if we will use jk2mv, and, if we are trying to let people use jk2mv, we should make mods which requires jk2mv.
also we have jk2mv API too, is a good adition to improve our mods, and we need try to get people to stop using the normal jk2
Why not just mods that work with any jk2 exe, but which is enhanced / have more features, for those who use JK2MV? :D Some people refuse to make the jump to JK2MV, so making it a requirement would be a bad idea :)
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

I recently tested, is very impressive how looks now :shock: :P +1, but i have some notes:

first:
Image
some numbers are not themselves from fonts, i think need to be remade from the currents .tga files, these are:

Code: Select all

qhandle_t	numberShaders[11];
qhandle_t	smallnumberShaders[11];
qhandle_t	chunkyNumberShaders[11];
and readed from:

Code: Select all

static char		*sb_t_nums[11] = {
"gfx/2d/numbers/t_zero",
"gfx/2d/numbers/t_one",
"gfx/2d/numbers/t_two",
...
second:

about this, i think u not applied the changes yet, because i think these font are from ergoec fonts (FONT_MEDIUM / qhMediumFont) but idk if is ur same ergoec (i see this more lighter), or maybe the current isnt working on these. (idk if works automatically, or u need to apply over the paint function)

Image

Image
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

Tr!Force wrote:I recently tested, is very impressive how looks now :shock: :P +1, but i have some notes:

first:
some numbers are not themselves from fonts, i think need to be remade from the currents .tga files, these are:

Code: Select all

qhandle_t	numberShaders[11];
qhandle_t	smallnumberShaders[11];
qhandle_t	chunkyNumberShaders[11];
and readed from:

Code: Select all

static char		*sb_t_nums[11] = {
"gfx/2d/numbers/t_zero",
"gfx/2d/numbers/t_one",
"gfx/2d/numbers/t_two",
...
These are used only for health, armor and ammo and I'd argue that they are so tightly integrated with underlying texture that it's better to leave them alone
second:

about this, i think u not applied the changes yet, because i think these font are from ergoec fonts (FONT_MEDIUM / qhMediumFont) but idk if is ur same ergoec (i see this more lighter), or maybe the current isnt working on these. (idk if works automatically, or u need to apply over the paint function)
This is a monospace font which can be found in assets0 gfx/2d/charsgrind_med.tga
I was always suprised why these few messages looked so bad - here is the answer. It's also used in few other places like team overlay, timer, fps counter etc. Not sure why.
As I wrote earlier, I can't identify the font for now. Certainly this is something that needs to be fixed.

PS Tell me how you like non-ascii characters. unfortunatelly A New Hope font doesn't contain them so I borrowed missing glyphs from helvetica.
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

charsgrid_med.tga is some sort of badly monospaced, condensed helvetica clone with terrible non-ascii glyphs. Maybe I should just replace it with a proper sans-serif monospace font, or with ocr_a and ergoec.
User avatar
Tr!Force
Posts: 433
Joined: 26 Feb 2015, 12:25
Location: Chile
Contact:

Re: Generating JK2 font from .ttf

Post by Tr!Force »

but actually these fonts (the "server changing maps..." or the "jk2mv-version" message) are from FONT_MEDIUM cgDC.Assets.qhMediumFont = trap_R_RegisterFont("ergoec");

is related with the charsgrind_med.tga???
Image
"The dark side? I've been there. Do your worst." - Kyle Katarn
  • JK2 & JK3 Code-Mod Developer
  • Jedi Knight Plus Mod Project: Click Here
  • E-Mail: triforce@gznetwork.com
  • Discord: TriForce#8785
User avatar
fau
Staff
Posts: 433
Joined: 16 Aug 2015, 01:01
Location: Warsaw / Poland
Contact:

Re: Generating JK2 font from .ttf

Post by fau »

No, they are not:

Code: Select all

		s = CG_GetStripEdString("INGAMETEXT", "SERVER_CHANGING_MAPS");	// s = "Server Changing Maps";
		w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
		CG_DrawBigString( 320 - w/2, 100, s, 1.0F);
CG_DrawBigString, CG_DrawStringExt, CG_DrawChar and Co are left-over from q3arena without TA expansion, where printing text was handled exclusively by cgame/ui code (there wasn't renderer/tr_font.cpp). Aparently q3 and jk2 devs didn't care enough to replace them with CG_Text_Paint in more obscure places. I'm going to do this in next patch, just need to decide what font/fonts to use.
Post Reply
Created by Matti from StylesFactory.pl and Warlords of Draenor (modified by jk2.info)
Powered by phpBB® Forum Software © phpBB Limited