Author Topic: TrueType font rendering  (Read 15005 times)

0 Members and 1 Guest are viewing this topic.

Offline AndrewofDoom

  • In A.D. 2366 war was beginning
  • 29
  • Permanent yuri goggles.
    • Skype
    • Steam
    • Twitter
Re: TrueType font rendering
I think it was a corruption in the new pilot code, since it works now after playing a mission that I hadn't last played, so it's all good now.
My Efforts:
SF Knight

20:08:19   AndrewofDoom: Though I find it mildly disturbing that a loli is giggling to mass destruction.
20:10:01   Spoon: I find it mildly arrousing
20:10:07   AndrewofDoom: Woah
20:10:15   Spoon: sound like my kind of loli
20:10:21   Spoon: and im not even a lolicon

 

Offline m!m

  • 210
Re: TrueType font rendering
Updated patch to apply cleanly to the latest Antipodes revision and to fix some issues which made FSO crash when an illegal font was specified and an issue which drew text wrongly when it was overlapping the lower boundary of the screen.

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
Re: TrueType font rendering
Quote from: SCP IRC Channel
Feb 03 [04:20:33] <ni1s>  little note on the truetype patch, GCC barfs on quilified class functions(foo::bar) inside the class declaration
Feb 03 [04:20:37] <ni1s>  http://paste.pocoo.org/raw/545122/
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the FSU on #SCP-FSU Talk with the SCP on #SCP
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline m!m

  • 210
Re: TrueType font rendering
Ahrg, sorry that must have slipped in. Patch updated.

 

Offline The E

  • He's Ebeneezer Goode
  • Global Moderator
  • 213
  • Nothing personal, just tech support.
    • Skype
    • Steam
    • Twitter
Re: TrueType font rendering
Slight oversight: In hudparse.cpp, parse_hud_gauges_tbl(), line 202, you need to call
Code: [Select]
parse_font(Hud_font, "$Font:");instead of the simple parse_font().
**** every cause that ends in murder and children crying. ― Iain Banks
Join the fun at the HLP IRC channel. Get the latest spam and gossip as long as it's fresh!

 

Offline m!m

  • 210
Re: TrueType font rendering
Links updated for new test builds and a new patch which applies cleanly against latest Antipodes again. I also added some Doxygen documentation to the functions in font.h and the FTGLFont class.

 

Offline m!m

  • 210
Re: TrueType font rendering
Patch updated again to fix bug where "1" would get converted to "€" on the hud.

 

Offline Echelon9

  • Moderator
  • 210
Re: TrueType font rendering
.....I also added some Doxygen documentation to the functions in font.h and the FTGLFont class.
That gets a big tick from me! Great to see more coders writing docs when touching a section of the codebase.

 

Offline m!m

  • 210
Re: TrueType font rendering
New patch along with a test build is in the first post. The changes include finished documentation on all classes and functions in font.h and further bug hunting. The parse system also uses the newly added SCP_string variants of stuff_string so no more fixed sized char arrays!

 

Offline niffiwan

  • 211
  • Eluder Class
Re: TrueType font rendering
I wanted to test out the TTF rendering to see if it would fix mantis 2417 - no luck unfortunately but as a side effect here's a patch to update configure.ac for Linux, as well as let it compile on Ubuntu 10.04, 11.10 & Fedora 16.

Please note - the required versions of freetype & ftgl are just what are installed by default in Ubuntu 10.04, it compiled and ran OK so I'm *assuming* that these versions are OK.

Code: [Select]
Index: code/graphics/font.cpp
===================================================================
--- code/graphics/font.cpp    (revision 8645)
+++ code/graphics/font.cpp    (working copy)
@@ -276,7 +276,7 @@ FTGLFont *FontManager::loadFTGLFont(SCP_string fileName, int fontSize, FTGLFontT
 
  if (fontFile == NULL)
  {
- mprintf(("Couldn't open font file \"%s\"", fileName));
+ mprintf(("Couldn't open font file \"%s\"", fileName.c_str()));
  return NULL;
  }
  ubyte *fontData = NULL;
@@ -286,13 +286,13 @@ FTGLFont *FontManager::loadFTGLFont(SCP_string fileName, int fontSize, FTGLFontT
 
  if (!fontData)
  {
- mprintf(("Couldn't allocate %d bytes for reading font file \"%s\"!", size, fileName));
+ mprintf(("Couldn't allocate %d bytes for reading font file \"%s\"!", size, fileName.c_str()));
  return NULL;
  }
 
  if (!cfread(fontData, size, 1, fontFile))
  {
- mprintf(("Error while reading font data from \"%s\"", fileName));
+ mprintf(("Error while reading font data from \"%s\"", fileName.c_str()));
  delete[] fontData;
  return NULL;
  }
@@ -329,20 +329,20 @@ FTGLFont *FontManager::loadFTGLFont(SCP_string fileName, int fontSize, FTGLFontT
 
  if (fnt == NULL)
  {
- mprintf(("Couldn't allocated memory for font object for file \"%s\"", fileName));
+ mprintf(("Couldn't allocated memory for font object for file \"%s\"", fileName.c_str()));
  return NULL;
  }
 
  if (fnt->Error())
  {
- mprintf(("Font loading of font \"%s\" ended with errors! Error code is %d.", fileName, fnt->Error()));
+ mprintf(("Font loading of font \"%s\" ended with errors! Error code is %d.", fileName.c_str(), fnt->Error()));
  delete fnt;
  return NULL;
  }
 
  if (!fnt->FaceSize(fontSize))
  {
- mprintf(("Couldn't set face size of font \"%s\" to %d!", fileName, fontSize));
+ mprintf(("Couldn't set face size of font \"%s\" to %d!", fileName.c_str(), fontSize));
  delete fnt;
  return NULL;
  }
@@ -1131,7 +1131,7 @@ void parse_ftgl_font(SCP_string fontFilename)
 
  if (font == NULL)
  {
- Warning(LOCATION, "Couldn't load font \"%s\".", fontFilename);
+ Warning(LOCATION, "Couldn't load font \"%s\".", fontFilename.c_str());
  return;
  }
 
Index: configure.ac
===================================================================
--- configure.ac    (revision 8645)
+++ configure.ac    (working copy)
@@ -358,6 +358,16 @@ PKG_CHECK_MODULES([PNG], [libpng >= 1.2.20])
 D_CFLAGS=$D_CFLAGS" $PNG_CFLAGS"
 FS2_LIBS=$FS2_LIBS" $PNG_LIBS"
 
+dnl freetype2
+PKG_CHECK_MODULES([FREETYPE2], [freetype2 >= 9.22.3])
+D_CFLAGS=$D_CFLAGS" $FREETYPE2_CFLAGS"
+FS2_LIBS=$FS2_LIBS" $FREETYPE2_LIBS"
+
+dnl ftgl
+PKG_CHECK_MODULES([FTGL], [ftgl >= 2.1.2])
+D_CFLAGS=$D_CFLAGS" $FTGL_CFLAGS"
+FS2_LIBS=$FS2_LIBS" $FTGL_LIBS"
+
 dnl LUA
 ## Checking for lua.pc and if that fails lua5.1.pc
 PKG_CHECK_MODULES(


[attachment deleted by a ninja]
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Linux OBS Packages: FSO 3.7.0 | FSO BP Build | wxLauncher (?) | PCS2 (?) | wxVPView (?)
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline m!m

  • 210
Re: TrueType font rendering
Thank you very much, I updated the link to the patch in the first post with your changes and it also includes updated Visual Studio 2011 project files.

 

Offline Axem

  • Administrator
  • 211
Re: TrueType font rendering
The E put this patch into the experimental BP builds we use, and I spotted some odd behavior with some of the hud gauges.



It looks like something is happening to hud gauges that are part of the "middle" of larger ones. Any idea whats going on?

 

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
Re: TrueType font rendering
The true type rendering library isn't properly resetting it's OpenGL states. It's is making the quads that are being rendered after text have no textures and/or the proper color.

 

Offline m!m

  • 210
Re: TrueType font rendering
I can't reproduce this on my end but Swiftys explanation would explain the effect pretty well but I really can't see what the library or my integration could do wrong but after all I don't know much about how OpenGL works... :nervous:

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Anims: 418, Cutscenes: 8, Mainhalls: 7, Logos: 52
    • Steam
    • Twitter
    • Mix-Hai Productions
Re: TrueType font rendering
we can haz another serious look at this now that 3.7 is out?
Cutscene Upgrade Project - Mainhall Remakes - MixaelANITools - Between the Ashes - MjnMixael's Render Boutique - Mix-Hai Productions
Youtube Channel - P3D Model Box - Photobucket Albums - Model Releases - Downloads
Between the Ashes is looking for committed testers, PM me for details.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!

 

Offline m!m

  • 210
Re: TrueType font rendering
:sigh: Merging a patch this old is going to be a pain...
Oh well, it needs to be done...

 

Offline m!m

  • 210
Re: TrueType font rendering
Ok, first version of the patch is available here: https://github.com/asarium/fs2open.github.com/tree/trueType
Still has some issues but I think it should work more or less.

 

Offline m!m

  • 210
Re: TrueType font rendering
I finally got the special characters to work reasonably well and also fixed some more drawing issues, test builds can be downloaded here: http://www.mediafire.com/download/xas57w7i6347ys1/FSO%203.7.1%20TTF.7z
Please note that the wingman status is not drawn correctly at this moment but I wanted to release these builds so people can test if the special characters are drawn correctly for them.

 

Offline m!m

  • 210
Re: TrueType font rendering
The link in the first post has been updated. This fixes the wingman status not drawn correctly bug.
I have also added a link to a small example mod showing how to get your fonts into the game.

 

Offline m!m

  • 210
Re: TrueType font rendering
New builds are available: http://www.mediafire.com/download/5t4h394nva3uk97/TTFBuilds.7z
This build contains a very important feature which is the ability to use UTF-8 encoded strings to render text (it allows to render characters like ä or ß which wasn't possible before).
As FreeSpace uses the old fonts for more than just drawing text I needed to fix those cases to use other sources. It worked for all but one instance which was weapon selection indicator.
I added a graphic for that which is currently not included in the binary but I will find a way to do that (I'd also appreciate if someone could come up with a better image as my image editing skills are non-existant). This also allows to customize that graphic for your weapons gauge which is also nice.