TTF font support

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: TTF font support

Re: TTF font support

by Talon1024 » Thu Oct 11, 2018 1:21 pm

special text layout or text with mixed scripts
Pango

It seems to be part of GTK2+, and the Linux version of GZDoom already uses GTK for the IWAD selection dialog IIRC.

Re: TTF font support

by Graf Zahl » Thu Oct 11, 2018 11:59 am

Same problem as always: It only renders glyphs but does not handle any special text layout or text with mixed scripts.

Re: TTF font support

by Talon1024 » Thu Oct 11, 2018 10:59 am

I don't know if this will be useful or not, but another open source project I like keeping tabs on (FS2_Open) recently added TTF font support with NanoVG (IIRC). FTGL was also mentioned in the same thread.

Re: TTF font support

by Graf Zahl » Thu Sep 27, 2018 5:33 am

Marisa Kirisame wrote:Would the use of SDL2_ttf be acceptable?
No.
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.

Re: TTF font support

by Rachael » Thu Sep 27, 2018 4:56 am

My first reaction: Another external library, ugh!

Re: TTF font support

by Marisa the Magician » Thu Sep 27, 2018 4:42 am

I'd like to un-[No] this. Would the use of SDL2_ttf be acceptable?

Re: TTF font support

by Rachael » Mon May 08, 2017 6:12 am

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.

Re: TTF font support

by UsernameAK » Mon May 08, 2017 6:06 am

Okay, what about the font scaling? How to make it to don't scale the font?

Re: TTF font support

by Rachael » Mon May 08, 2017 5:50 am

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.

Re: TTF font support

by UsernameAK » Mon May 08, 2017 5:49 am

Libraries can be used just to parse the fonts and rasterize them (for example, freetype2).

Re: TTF font support

by Graf Zahl » Mon May 08, 2017 5:46 am

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 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.
I have implemented TTF support for hardware accelerated backends on Android and iOS and it has always been a major pain in the ass.

Re: TTF font support

by Rachael » Mon May 08, 2017 5:43 am

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.

Re: TTF font support

by UsernameAK » Mon May 08, 2017 5:34 am

Rachael wrote:It's never too late to learn C++, and here, I will give you a starting point:
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: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
Why not to use libraries?
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.
I use Linux so don't suggest Visual Studio for me.

Re: TTF font support

by Rachael » Sun May 07, 2017 2:12 pm

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.

Re: TTF font support

by UsernameAK » Sun May 07, 2017 1:24 pm

I suggest that for high-quality non-pixelated fonts

Top