Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dave Gilbert on Thu 13/04/2017 01:10:22

Title: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 13/04/2017 01:10:22
I am encountering a bizarre problem and hopefully someone can help!

I am using the font "Cambria Bold" at size 16. When I set "anti-alias TTF fonts" to TRUE, The letter "S" goes magically missing:

(http://www.wadjeteyegames.com/temp/unavowed-nos.png)

But, when I set it to FALSE, the S displays just fine, but slightly smaller than it should be:

(http://www.wadjeteyegames.com/temp/unavowed-yess.png)

-Dave

I experimented with this font at various other sizes, and other letters go missing (or are shrunk). Specifically, the letter "H" at size 15.

Any light shedding is appreciated!
Title: Re: Certain letters not appearing on screen
Post by: Gilbert on Thu 13/04/2017 03:20:36
Does the S appear if you add a space before it?
Title: Re: Certain letters not appearing on screen
Post by: dayowlron on Thu 13/04/2017 03:23:18
When you pass in the string is the "S" capital and the other letters lower case?
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 13/04/2017 15:13:16
@Dayowlron: Yes, it's the capital S that disappears. Should have been more specific.  The example I showed you IS all capital letters, but the letter does not appear regardless of what combinations of capital/lowercase letters there are.

@Gilbot: No, the S does not appear if I add a space before it.

Appreciate the help!

edit: Also, this problem occurs in every situation where text is displayed. On a GUI, on dialog options, display messages, text speech, you name it. That capital S does not appear. I loaded the font up in an editor, and it seems to look perfectly normal? So I am at a loss.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Thu 13/04/2017 15:17:40
EDIT
Quote from: Dave Gilbert on Thu 13/04/2017 15:13:16I loaded the font up in an editor, and it seems to look perfectly normal?

Oh, so it does look properly in the editor? Hmm... that is puzzling, because editor uses same fonts library as engine.

What will happen if you display a single "S" in game?

To clarify, you are speaking of Microsoft font "Cambria Bold" that comes with Windows?
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 13/04/2017 15:21:33
The AGS editor, as well as font editors like Font Forge.

And yes, that is the correct font.

A single S is still invisible!

Thanks for the help, CW!
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Thu 13/04/2017 15:24:36
IDK, I would think that this is again because AGS uses outdated fonts library, but then how does it work in the Editor, where it uses same library?

I could not find out, if the font is free or has to be purchased? If it's free, I would ask to upload it somewhere so that I could check this out under debugger.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 13/04/2017 15:28:00
The font came with Windows, but your post made me wonder if the font got corrupted somehow. So I redownloaded it and... it works now.

Should have tried that AGES ago. I am an idiot. "Advanced" forum indeed.
Title: Re: Certain letters not appearing on screen - solved!
Post by: Crimson Wizard on Thu 13/04/2017 15:32:07
Wow.... that's a relief :)

BTW, regarding my question, I forgot that Windows hides individual fonts in Fonts folder, and shows only families. Indeed, Cambria Bold is also there.

PS. Still, it was weird that it worked in editor but not engine...
Title: Re: Certain letters not appearing on screen - solved!
Post by: Dave Gilbert on Thu 13/04/2017 15:32:29
Aaand spoke too soon. Now the "G" is invisible. :) Sigh.

Here's a link to the font. (https://dl.dropboxusercontent.com/u/99776311/cambriab.ttf). If you can find anything, I'd appreciate any help as I really dig the font.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Thu 13/04/2017 15:40:49
I still think this is most certainly because of outdated font renderer in AGS.

There was this engine's build I made a while ago, it features updated fonts library: http://www.mediafire.com/download/j2w18bxw1yzh7o0/acwin_3.4.0.6--alfont-new.zip
It is AGS 3.4.0.6, but if you make a test game in AGS 3.2.1, for instance, it will be able to run it.

I can check out myself too, but only when I get spare time.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 13/04/2017 15:46:10
I'll give it a test.

I am using the most recent beta (3.4.1.3). Is the build compatible with that?

Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Thu 13/04/2017 15:48:18
Quote from: Dave Gilbert on Thu 13/04/2017 15:46:10
I am using the most recent beta (3.4.1.3). Is the build compatible with that?
No, it is 3.4.0.6, that's more than a year old. That's why I suggested using older AGS for this test.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 13/04/2017 15:50:32
Ah OK. I'll have to redownload that version of AGS and give it a test. Thanks.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Mon 17/04/2017 15:40:54
Sorry for the double post. I feel like an idiot here (not an uncommon occurrence, I know) but I can't seem to find the specific version of the engine that this acwin file will work with. The ones I download seem to be either too early or too recent. I hate to impose, but could you link me to the proper version? I'll give it a quick test and see what I find.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Tue 18/04/2017 09:16:15
Is not it work with 3.2.1?

I would update that build to latest version, but I do not have much free time right now.

BTW, this is one of the examples when I suspended an update because of backwards compatibility. I could upgrade this library about a year ago, but I did not manage to make it render some of the previously used AGS fonts properly (like the Lucas arts classic font used in all Maniac Mansion Mania games).
Title: Re: Certain letters not appearing on screen
Post by: Danvzare on Tue 18/04/2017 10:56:35
Quote from: Crimson Wizard on Tue 18/04/2017 09:16:15
I could upgrade this library about a year ago, but I did not manage to make it render some of the previously used AGS fonts properly (like the Lucas arts classic font used in all Maniac Mansion Mania games).
I remember that. I thought the way you managed to get it to render those fonts was rather acceptable considering the age of the games.
Personally though, I think that if it would fix problems like this, you should forgo the backwards compatibility. If anyone wants to play Maniac Mansion Mania on a newer computer, they could just use an older version of the engine which does have the backwards compatibility.
Title: Re: Certain letters not appearing on screen
Post by: abstauber on Tue 18/04/2017 11:00:16
Quotebut I did not manage to make it render some of the previously used AGS fonts properly (like the Lucas arts classic font used in all Maniac Mansion Mania games
If I recall correctly, that font was broken/corrupted anyway. That's why I replaced it with the one we have in the template.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Tue 18/04/2017 11:12:34
Quote from: abstauber on Tue 18/04/2017 11:00:16
Quotebut I did not manage to make it render some of the previously used AGS fonts properly (like the Lucas arts classic font used in all Maniac Mansion Mania games
If I recall correctly, that font was broken/corrupted anyway. That's why I replaced it with the one we have in the template.

I wasn't aware of that. And MMM games are released in recent years, so I thought they are still using it.

Well, I guess I can push a library update after 3.4.1 if I'll have time. The changes are not too big.

There are still other solutions, like suggest override the font with another one, which works if you put it in the game folder.
Title: Re: Certain letters not appearing on screen
Post by: Snarky on Tue 18/04/2017 11:20:41
(Oh, sniped...)

Quote from: Danvzare on Tue 18/04/2017 10:56:35
I remember that. I thought the way you managed to get it to render those fonts was rather acceptable considering the age of the games.
Personally though, I think that if it would fix problems like this, you should forgo the backwards compatibility. If anyone wants to play Maniac Mansion Mania on a newer computer, they could just use an older version of the engine which does have the backwards compatibility.

Of course, those games are built with and run on an older version of the engine by default. The goal of running already-built old games with a newer version of the engine is, IMO, the lowest-priority form of backwards compatibility.

So the issue would be more that if the updated library can't display some fonts that used to work, is it broken? And if so, is there any benefit to updating from one buggy version to another buggy version? If the reason is not a library bug but that the font is actually corrupt, and if it is possible to fix/replace it, and if there aren't a ton of fonts out there with the same problem that should still be supported, then it seems worth doing.

Quote from: Crimson Wizard on Tue 18/04/2017 11:12:34
There are still other solutions, like suggest override the font with another one, which works if you put it in the game folder.

Oh, that's cool! I didn't know you could do that.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Tue 18/04/2017 11:33:28
Quote from: Snarky on Tue 18/04/2017 11:20:41
Of course, those games are built with and run on an older version of the engine by default. The goal of running already-built old games with a newer version of the engine is, IMO, the lowest-priority form of backwards compatibility.

This kind of compatibility was primarily needed for the ports, that cannot run old games with their original executable.

From the beginning of this project it was struggling between two tasks: making ports run all games, both old and new, and continue developing new versions.


Quote from: Snarky on Tue 18/04/2017 11:20:41
Oh, that's cool! I didn't know you could do that.
You can replace almost every resource in game that way, because AGS gives files on disk higher priority than to ones in package.
People were doing "unofficial" translations for decade like that, by placing both TRA and font files in the game folder to override ones in game.
Title: Re: Certain letters not appearing on screen
Post by: abstauber on Tue 18/04/2017 13:06:49
QuoteI wasn't aware of that. And MMM games are released in recent years, so I thought they are still using it.
They are still using the Lucasfan Font and at in the AGS source I found this:
https://github.com/adventuregamestudio/ags/blob/master/Common/font/ttffontrenderer.cpp

Quote
#if !defined(WINDOWS_VERSION)
  // FIXME: (!!!) this fix should be done differently:
  // 1. Find out which OUTLINE font was causing troubles;
  // 2. Replace outline method ONLY if that troublesome font is used as outline.
  // 3. Move this fix somewhere else!! (right after game load routine?)
  //
  // Check for the LucasFan font since it comes with an outline font that
  // is drawn incorrectly with Freetype versions > 2.1.3.
  // A simple workaround is to disable outline fonts for it and use
  // automatic outline drawing.
  if (get_font_outline(fontNumber) >=0 &&
      strcmp(alfont_get_name(alfptr), "LucasFan-Font") == 0)
      set_font_outline(fontNumber, FONT_OUTLINE_AUTO);
#endif

The outline found is the same as in the 9Verb template, so that should not cause any problems
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Tue 18/04/2017 13:17:20
Quote from: abstauber on Tue 18/04/2017 13:06:49in the AGS source I found this:
https://github.com/adventuregamestudio/ags/blob/master/Common/font/ttffontrenderer.cpp

Quote
#if !defined(WINDOWS_VERSION)
  // FIXME: (!!!) this fix should be done differently:
  // 1. Find out which OUTLINE font was causing troubles;
  // 2. Replace outline method ONLY if that troublesome font is used as outline.
  // 3. Move this fix somewhere else!! (right after game load routine?)
  //
  // Check for the LucasFan font since it comes with an outline font that
  // is drawn incorrectly with Freetype versions > 2.1.3.
  // A simple workaround is to disable outline fonts for it and use
  // automatic outline drawing.
  if (get_font_outline(fontNumber) >=0 &&
      strcmp(alfont_get_name(alfptr), "LucasFan-Font") == 0)
      set_font_outline(fontNumber, FONT_OUTLINE_AUTO);
#endif

That is a hack for other ports made by JJS. The thing is that OTHER ports already use updated library, but without much compatibility fixes, which causes some of these fonts render incorrectly (hence this crude hack).

I recall there were other affected fonts, like in Primordia: https://github.com/adventuregamestudio/ags/issues/126
Title: Re: Certain letters not appearing on screen
Post by: abstauber on Tue 18/04/2017 13:23:24
So if the fonts in the included 9verb template are rendered correctly even with the new library, then I'd say update it is safe to update it.

The MMM guys would just need to upgrade a single .ttf file. And for older games without the sources they would just need to provide the ttf file outside of the ags resource file.
Title: Re: Certain letters not appearing on screen
Post by: Danvzare on Wed 19/04/2017 12:20:47
Quote from: Snarky on Tue 18/04/2017 11:20:41
Quote from: Crimson Wizard on Tue 18/04/2017 11:12:34
There are still other solutions, like suggest override the font with another one, which works if you put it in the game folder.

Oh, that's cool! I didn't know you could do that.
Me neither. This changes everything! 8-0
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Wed 19/04/2017 18:44:44
So I just... put the font in the game's folder and viola? I am going to try this now!

edit: aaand now the "M" disappears. :) This is just weird.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Wed 19/04/2017 19:07:15
Quote from: Dave Gilbert on Wed 19/04/2017 18:44:44
So I just... put the font in the game's folder and viola? I am going to try this now!

edit: aaand now the "M" disappears. :) This is just weird.

Dave, I think you misunderstood something. That was not a solution for your problem, I just mentioned that this may be done, for example, to replace some font with different font.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Wed 19/04/2017 19:15:10
Yes I misunderstand that completely. Although why it made an entirely different letter disappear is a different mystery entirely. Either way, I'm just going to disable anti-aliasing and go with the pixelly version of the font. It looks fine!
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Wed 19/04/2017 19:18:26
Quote from: Dave Gilbert on Wed 19/04/2017 19:15:10
Yes I misunderstand that completely. Although why it made an entirely different letter disappear is a different mystery entirely. Either way, I'm just going to disable anti-aliasing and go with the pixelly version of the font. It looks fine!
Have you managed to try out the version I gave you? I will probably try it out myself now, because I've got some time.
That would be interesting to know, at least for future reference, if upgrading to latest fonts library will fix this problem.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Wed 19/04/2017 19:32:13
Aaand there was a whole slew of posts on the first page that I didn't see. I am batting a hundred today. I am AFK at the moment so if you've got the time - great!
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Thu 20/04/2017 09:33:12
I tested and this build does not display any text with this font at all. Something might have been done wrong in there.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 20/04/2017 14:19:54
Does it displays OK with anti-aliasing disabled? All problems go away for me, but it's obviously very pixelly.
Title: Re: Certain letters not appearing on screen
Post by: Crimson Wizard on Thu 20/04/2017 14:23:20
Quote from: Dave Gilbert on Thu 20/04/2017 14:19:54
Does it displays OK with anti-aliasing disabled? All problems go away for me, but it's obviously very pixelly.

Yes, it does. So there is something special in how anti-aliasing is implemented, which needs research.
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Thu 20/04/2017 14:25:24
There could be something broken with the font itself. Every other font I try doesn't have this problem. Although I have yet to find a similar font that I like just as much.
Title: Re: Certain letters not appearing on screen
Post by: Mandle on Fri 21/04/2017 04:16:32
Quote from: Dave Gilbert on Thu 20/04/2017 14:25:24
There could be something broken with the font itself. Every other font I try doesn't have this problem. Although I have yet to find a similar font that I like just as much.

Can't you just rip the font characters and create a new font from them? Or is that a no-no?
Title: Re: Certain letters not appearing on screen
Post by: Snarky on Fri 21/04/2017 11:31:06
I tried opening the font in a font editor and just regenerating it, to see if that would help. It crashed FontLab Studio 5 (quite possibly a sign that there's something weird with the font), but I was able to do it in FontForge. When you generate the font it produces warnings about a bunch of errors (notably one about a kerning value being out of normal range and possibly not supported by some applications), which I ignored, but it might be worth trying to fix them to see if that takes care of it.

Here's the rebuilt file:

https://www.dropbox.com/s/516qz925vjnwej5/Cambria-Bold.ttf?dl=0
Title: Re: Certain letters not appearing on screen
Post by: Dave Gilbert on Fri 21/04/2017 14:38:56
Oof. Okay, so the problem is obviously the font. Sorry to waste everyone's time with this.

I tried using that file you uploaded, Snarky, and it works! ...half of the time. The capitol "S" seems to disappear at arbitrary times (usually at the beginning of a sentance). I suppose that's better than when it disappeared all of the time, but still.

I guess it's time to find a font that looks somewhat similar. The issue is that since the game is 640 x 360, when blown up to full screen in anti-aliasing mode most fonts look AWFUL. Cambria was one of the few that didn't. :)

edit: And now the "M" disappears every time! haha. OK. I think it's time to retire Cambria.

(http://www.wadjeteyegames.com/temp/unavowed-m.png)
Title: Re: Certain letters not appearing on screen
Post by: Danvzare on Sat 22/04/2017 10:46:30
"You are HU AN. RE E BER!"
Sounds like he's drunk. (laugh)
Title: Re: Certain letters not appearing on screen
Post by: selmiak on Sat 22/04/2017 10:47:02
Just a guess, I bet W disappears too, just because the letter is 1px too wide like the capital M. Try changing the M in the font and make it as wide as the other characters that are displayed, I bet my ass it displays then. If not, you won my ass :D
Title: Re: Certain letters not appearing on screen
Post by: Mandle on Wed 26/04/2017 13:50:16
A bit OT but I just thought I'd mention that Mostly Walking, a fairly famous youtube show that does weekly episodes blind-playing adventure games, just mentioned that they are playing a Wadjet Eye game starting from next week.

Previously they have played Gemini Rue and were very impressed with it. They have just finished The 7th Guest and said they need to "treat themselves" with a good game after that and decided on another Wadjet Eye game.