Author Topic: TrueType font rendering  (Read 14989 times)

0 Members and 2 Guests are viewing this topic.

Offline Yarn

  • 210
Re: TrueType font rendering
I can't seem to get your build to work. The opening cutscene plays fine, but immediately after that, I get the attached error message. (An fs2_open.log file is also attached.)

I'm hoping to have this fixed because I want to see how well the build handles German, French, and Polish.

[attachment kidnapped by pirates]
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
I kind of expected that as the build probably don't handle the the other characters well. What data do I need to reproduce this?

 

Offline Yarn

  • 210
Re: TrueType font rendering
I was using your Font Test mod with the English version--nothing from the international versions was used. In fact, I didn't realize that the language was still set to German. (I'm currently testing the SVN version of FSPort in German.) Setting it back to English or playing without your mod "fixed" the problem.

If you want the data from the German and Polish versions of the game (a true French version apparently doesn't exist), I have links to it at the end of this post:
http://www.hard-light.net/forums/index.php?topic=85492.msg1709621#msg1709621

And if you want to see exactly what is in each font file, I've got dumps of them here:
https://dl.dropboxusercontent.com/u/89353583/FreeSpace/fs_font_chars.zip

I haven't looked through your code yet, so I don't know what might be causing the problem.

I should say this, though: For all languages other than Polish, FreeSpace expects mission, campaign, and table files to be encoded in Windows-1252; while loading those files, the game converts them to CP437 to match the fonts. (Technically, fiction viewer files should be in that list, but last I checked, no remapping took place there.) If the language is set to Polish, however, the files are supposed to be encoded in Windows-1250, and no code-page conversion occurs. In all cases, though, the letter ß is converted to ss.

(And yes, Ż looks like Ƶ in the Polish font; from what I can tell, this is just a glyph variant in that language.)

If you have any further questions about FreeSpace localization or character sets in general, just ask me; I know quite a bit about those things, so I should be able to answer your questions.
« Last Edit: August 20, 2014, 05:19:39 pm by Yarn »
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline Yarn

  • 210
Re: TrueType font rendering
Can you look into syncing your TrueType branch with the current trunk? Lots of changes to the localization code have been made since you last did so.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
I will sync the branch as soon as possible.
Please be aware that I will change the rendering backend at some point as the library I am currently using only supports OpenGL 1 which may change how some things work.

EDIT: Branch has been updated.
« Last Edit: May 02, 2015, 06:04:54 am by m!m »

 

Offline Yarn

  • 210
Re: TrueType font rendering
I tried compiling your branch using Microsoft Visual Studio Community 2013. However, I seem to be unable to do so sucessfully. The project files for the libjpeg, liblua, libpng, and zlib libraries are all missing, and nothing in the Fred2 and Freespace2 folders can be opened (probably because you moved those folders out of the code folder). I'm also getting 339 errors, most of which are caused by a file called "compiler.h" being missing. These issues are preventing me from compiling your branch.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
:banghead: Those project files aren't supposed to be there. You'll need to use CMake to generate the project files.

 

Offline Yarn

  • 210
Re: TrueType font rendering
I had a feeling I'd need CMake, considering the descriptions of some recent commits. Using it allowed me to compile.

I found a serious bug, though. If black bars are added to the menus to preserve the 4:3 ratio, then TrueType (but not VF) fonts are horribly smeared. I've attached a screenshot of what this looks like at 1034x768 resolution, just ten pixels wider than the standard 1024x768. At wider resolutions, the problem is even worse, making text totally unreadable. This problem doesn't occur at 4:3 resolutions or when the -stretch_menu flag is enabled.

[attachment deleted by nobody]
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
I kind of expected such issues as the current TTF rendering doesn't account for the menu resizing. I'll try to fix this ASAP.

 

Offline Yarn

  • 210
Re: TrueType font rendering
I found the problem already, actually: in line 596 of opengldraw.cpp, the pointers to scale_x and scale_y need to be passed as the 3rd and 4th arguments to prevent the offsets from being added.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
Thanks for your help. The current version should work again (there was also an issue where text would be drawn with the old font rendering system).

 

Offline m!m

  • 210
Re: TrueType font rendering
New builds have been uploaded, now the OpenGL backend uses nanovg to render text which results in much improved font rendering but it doesn't support as many features as FTGL.

 

Offline Yarn

  • 210
Re: TrueType font rendering
I seem to be unable to compile your new branch. Whenever I try to do so, I get 19 compiler errors like this:

Code: [Select]
Description: Attempt to include auto-generated header after including gl.h (C:\Games\FreeSpace2\fs2_open_ttf-nvg\code\cutscene\mveplayer.cpp)
File: C:\Games\FreeSpace2\fs2_open_ttf-nvg\code\graphics\gl\gl_2_1.h
Line: 8

The CPP file in the description is different in each error, but other other than that, almost all the errors are the same.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
Try building the "clean_cotire" target. If that doesn't work disable the CMake option COTIRE_ENABLE, configure and generate the project files again and try building.

 

Offline Yarn

  • 210
Re: TrueType font rendering
Building "clean_cotire" first didn't help, so I disabled COTIRE_ENABLE. That worked.

When I tried the resulting build, however, I noticed a serious problem that doesn't happen in your test build: At certain areas, certain graphics would just be rendered as solid blocks. Exactly when and where it happens seems to be random in a weird way (it's a bit hard to explain), but it seems to mostly affect special characters within TrueType text, briefing icons, and HUD graphics. An example image of the HUD is attached.

I also noticed a number of new bugs that do occur in your test build in conjunction with your new test mod:
  • Lowercase letters are displayed a few pixels too high.
  • There's some graphical weirdness going on whenever a pop-up dialog is displayed. To see what I mean, go to the mission simulator in the Tech Room and notice how the screen looks while the missions are being scanned.
  • In the first command briefing stage of "Surrender, Belisarius!", just below the "This is Admiral Petrarch" line, there are two blank lines instead of just one. That particular line has a trailing space character, and I think it's being placed on its own line. It looks like you'll have to strip trailing whitespace when rendering each line of text to prevent this problem.
  • VF font rendering is completely broken when TrueType fonts are not in use, with each line being rendered with a single square. (This seems to happen only in your build.)

[attachment deleted by nobody]
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
I forgot to push the latest changes to the Github branch, pulling the changes and recompiling should fix a few of your reported issues.

  • Lowercase letters are displayed a few pixels too high.
I don't encounter this issue, can you post a screenshot?

  • There's some graphical weirdness going on whenever a pop-up dialog is displayed. To see what I mean, go to the mission simulator in the Tech Room and notice how the screen looks while the missions are being scanned.
I have encountered this before but I have no idea why it happens.

  • In the first command briefing stage of "Surrender, Belisarius!", just below the "This is Admiral Petrarch" line, there are two blank lines instead of just one. That particular line has a trailing space character, and I think it's being placed on its own line. It looks like you'll have to strip trailing whitespace when rendering each line of text to prevent this problem.
This is an issue with the mission assets that should not be fixed by the code. The font size would need to be adjusted to make sure the text wraps correctly.

  • VF font rendering is completely broken when TrueType fonts are not in use, with each line being rendered with a single square. (This seems to happen only in your build.)
Should be fixed with the newest changes.

I'll compile and upload new builds.

EDIT: Link in first post updated.
« Last Edit: May 09, 2015, 03:54:55 pm by m!m »

 

Offline Yarn

  • 210
Re: TrueType font rendering
Compiling with the new changes appears to have fixed my problem with images not rendering.

  • Lowercase letters are displayed a few pixels too high.
I don't encounter this issue, can you post a screenshot?
Yes--screenshot is attached.

EDIT: This appears to be caused by a rounding error. If I increase the font size, lowercase letters are no longer aligned with the top of capital letters, but they're still usually rendered one pixel too high.

  • In the first command briefing stage of "Surrender, Belisarius!", just below the "This is Admiral Petrarch" line, there are two blank lines instead of just one. That particular line has a trailing space character, and I think it's being placed on its own line. It looks like you'll have to strip trailing whitespace when rendering each line of text to prevent this problem.
This is an issue with the mission assets that should not be fixed by the code. The font size would need to be adjusted to make sure the text wraps correctly.
I added an "a" to the beginning of that line, tried the mission in retail and 3.7.2, and got the same effect. So, it looks like this isn't something that you need to worry about in your code.

  • VF font rendering is completely broken when TrueType fonts are not in use, with each line being rendered with a single square. (This seems to happen only in your build.)
Should be fixed with the newest changes.
Yep, your newest build fixed this!

[attachment deleted by nobody]
« Last Edit: May 09, 2015, 05:10:24 pm by Yarn »
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline Yarn

  • 210
Re: TrueType font rendering
I found a typo: In line 305 of font.cpp:
Code: [Select]
Error(LOCATION, "At least three fonts have to be loaded by only %d valid entries were found!", FontManager::numberOfFonts());..."by" should be "but".
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline m!m

  • 210
Re: TrueType font rendering
I don't encounter this issue, can you post a screenshot?
Yes--screenshot is attached.

EDIT: This appears to be caused by a rounding error. If I increase the font size, lowercase letters are no longer aligned with the top of capital letters, but they're still usually rendered one pixel too high.
I can reproduce your issue now and I'll look into it. Rendering should be done using floating point numbers so I don't know why it snaps to the next pixel.

EDIT: The bug should be fixed now.

I found a typo: In line 305 of font.cpp:
Code: [Select]
Error(LOCATION, "At least three fonts have to be loaded by only %d valid entries were found!", FontManager::numberOfFonts());..."by" should be "but".
Thanks, I fixed the typo.
« Last Edit: May 10, 2015, 06:19:10 am by m!m »

 

Offline Yarn

  • 210
Re: TrueType font rendering
It looks like your code is introducing artifacts to VF (but not TrueType) font scaling. Example image at 1200x900 resolution is attached.

[attachment deleted by nobody]
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178