TTF font support
Moderator: GZDoom Developers
- UsernameAK
- Posts: 83
- Joined: Wed Jul 15, 2015 5:26 am
- Location: Ukraine
TTF font support
Add the TrueType font support. This will be helpful for graphical mods (TTF is good for menus).
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: TTF font support
If it wasn't just such a shitload of work to get that into the engine...
Find someone who might help out and we're good to go. But on realistic terms: Not going to happen...
Find someone who might help out and we're good to go. But on realistic terms: Not going to happen...
Re: TTF font support
@UsernameAK, Given that's a pretty clear "no", you might be interested in bagheadspidey's Doom Crap.
http://baghead.drdteam.org/tools.xml
It can make ZDoom fonts out of system fonts. The quality of the results can vary but you might find something that works for you.
http://baghead.drdteam.org/tools.xml
It can make ZDoom fonts out of system fonts. The quality of the results can vary but you might find something that works for you.
- UsernameAK
- Posts: 83
- Joined: Wed Jul 15, 2015 5:26 am
- Location: Ukraine
Re: TTF font support
I suggest that for high-quality non-pixelated fonts
Re: TTF font support
UsernameAK - since a lot of your suggestions appear to be right off the cuff, I am going to help you out a bit, here. Since you seem to want so many crazy features in GZDoom, and these mean old devs don't seem to want to listen to you - you should be able to implement them yourself. It's never too late to learn C++, and here, I will give you a starting point:
http://www.learncpp.com/ - This has a series of tutorials to start. If your school/college/tech school/whatever offers any C++ courses, I would highly recommend registering for them if possible. Talk to your adviser about it and see what's available.
https://support.microsoft.com/en-us/hel ... -downloads - Of course, in order to actually use C++, you need a compiler. This should help you get started.
I hope this is helpful for you!
Of course, for this particular suggestion you will obviously need to learn how to actually read the font's format. http://scripts.sil.org/cms/scripts/page ... -chapter08
These resources, along with plenty of Googling, should help put you in the right direction for getting the features you want in the engine.
http://www.learncpp.com/ - This has a series of tutorials to start. If your school/college/tech school/whatever offers any C++ courses, I would highly recommend registering for them if possible. Talk to your adviser about it and see what's available.
https://support.microsoft.com/en-us/hel ... -downloads - Of course, in order to actually use C++, you need a compiler. This should help you get started.
I hope this is helpful for you!
Of course, for this particular suggestion you will obviously need to learn how to actually read the font's format. http://scripts.sil.org/cms/scripts/page ... -chapter08
These resources, along with plenty of Googling, should help put you in the right direction for getting the features you want in the engine.
- UsernameAK
- Posts: 83
- Joined: Wed Jul 15, 2015 5:26 am
- Location: Ukraine
Re: TTF font support
I know C++. But GZDoom code is very complicated. It takes about 10-30 minutes to find out how the feature is implemented. I have tried to implement something: viewtopic.php?f=18&t=55233 , but I didn't have enough knowledge of OpenGL and it was shitty.Rachael wrote:It's never too late to learn C++, and here, I will give you a starting point:
Why not to use libraries?Rachael wrote:Of course, for this particular suggestion you will obviously need to learn how to actually read the font's format. http://scripts.sil.org/cms/scripts/page ... -chapter08
I use Linux so don't suggest Visual Studio for me.Rachael wrote:https://support.microsoft.com/en-us/hel ... -downloads - Of course, in order to actually use C++, you need a compiler. This should help you get started.
Re: TTF font support
GZDoom code is not that complicated. If you find it complicated, start with simple stuff first - tweak the monster AI or something, and then work your way into it. I think the most complicated part about it is coaxing the renderers to either draw your fonts directly, or draw them through a raster. For 2D, there's 2 hardware renderers and one direct-to-buffer renderer that it will have to be done with.
As for using libraries - that is a good idea - as long as you can coax the libraries to render to those buffers I mentioned.
As for using libraries - that is a good idea - as long as you can coax the libraries to render to those buffers I mentioned.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: TTF font support
I think the only way to implement this without code explosion is to render entire texts into a texture and then use the existing drawing code to render these textures.Rachael wrote:GZDoom code is not that complicated. If you find it complicated, start with simple stuff first - tweak the monster AI or something, and then work your way into it. I think the most complicated part about it is coaxing the renderers to either draw your fonts directly, or draw them through a raster. There's 2 hardware renderers and one direct-to-buffer renderer that it will have to be done with.
As for using libraries - that is a good idea - as long as you can coax the libraries to render directly to those buffers I mentioned.
I have implemented TTF support for hardware accelerated backends on Android and iOS and it has always been a major pain in the ass.
- UsernameAK
- Posts: 83
- Joined: Wed Jul 15, 2015 5:26 am
- Location: Ukraine
Re: TTF font support
Libraries can be used just to parse the fonts and rasterize them (for example, freetype2).
Re: TTF font support
In that case, the entire code can be simplified just by drawing to a texture of appropriate size first, then, and then passing that texture into the existing 2D drawers for each of the renderer types. It'll be easier to deal with the OpenGL and Direct3D renderers than it will be for the direct renderer (the vid_hw2d==false one) but it should be doable.
Since you use Linux, don't worry about the Direct3D renderer - if you can get the OpenGL one working, we can get the D3D one working ourselves, as long as you use the texture method.
Since you use Linux, don't worry about the Direct3D renderer - if you can get the OpenGL one working, we can get the D3D one working ourselves, as long as you use the texture method.
- UsernameAK
- Posts: 83
- Joined: Wed Jul 15, 2015 5:26 am
- Location: Ukraine
Re: TTF font support
Okay, what about the font scaling? How to make it to don't scale the font?
Re: TTF font support
It depends on the size of the texture. As long as you pass a texture in of the right size, it shouldn't try to scale it. You'll have to look at it and see how it deals with the existing pre-rastered fonts. I know for that GZDoom the texture coordinates are simply 0.0 to 1.0, which makes it much easier to deal with because then all you have to figure out is the number of pixels between start and end. I am not sure how the non-hardware renderer deals with it, though, but I think most of the relevant code for that is either in v_video.cpp or called by it.
- Marisa the Magician
- Posts: 3886
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
- Contact:
Re: TTF font support
I'd like to un-[No] this. Would the use of SDL2_ttf be acceptable?
Re: TTF font support
My first reaction: Another external library, ugh!
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: TTF font support
No.Marisa Kirisame wrote:Would the use of SDL2_ttf be acceptable?
To be clear: If there was a WORKING and FULLY FEATURED text rendering functionality here, it'd fill the last gap that's needed, i.e. Linux support.
But unfortubnately this is just a wrapper around FreeType. And FreeType is merely a glyph renderer, which is not sufficient to render text correctly. For that you need a real font layout engine that can substitute missing characters from other fonts and handle ligatures and other special cases.
On Windows and Mac that part is not a problem - the native font rendering of the OS can do all of it automatically. But on Linux it all depends on third party libraries which are mostly poorly documented.
I find it somewhat fitting that SDL again went the cheapest and least complete route possible.
So even if this was sufficient I'd go right to the source (i.e. FreeType) than to depend on some shitty wrapper library.
To summarize: If you can provide a drop-in Linux handler that gets a string, a font and some basic font properties and returns a properly rendered text from it (by that I mean that even Chinese or more exotic characters show up correctly if the system has a font for them), we are in business. But I feel that without Linux support it won't be really useful.