Font Change Query [Solved]

I've updated an old (2007) game which used the Comic Sans font. I personally think it is perfect for the game but I know some have a problem with Comic Sans. Taking that into account, the game (http://textadventures.co.uk/games/view/m4a7-u7kyukbtvhaqtxq-g/sir-loin-and-the-coming-of-age) offers a different font and provides a FONT command to allow switching between the two.

In making that switch I thought it was sufficient to use SetFontName but I also found I had to use SetWebFontName when switching back. Can someone explain the relationship here?

This is the code I'm using:

if (game.font_old) {
  game.font_old = false
  SetFontName ("'Arial, Helvetica, sans-serif")
  SetWebFontName ("Della Respira")
}
else {
  game.font_old = true
  SetFontName ("'Comic Sans MS', cursive, sans-serif")
}
msg ("Font has changed. Revert by typing FONT again.")

Happy to take views on the use of Comic Sans as well!


K.V.

Hello.

SetWebFontName only works when Quest is connected to the internet. It downloads the listed font(s) from http://www.google.com/webfonts. The first font listed will be the font which is set, unless that font is unavailable for any reason. In those cases, Quest will attempt to set the next font on the list.

SetFontName sets a Windows system font if the internet is not available. If the system font is not installed on the player's machine, the display will switch to the next font listed. Presumably, all the system fonts which are listed in the editor should exist, as Quest is Windows only, and Windows is pretty good at keeping the same fonts across all versions of Windows.

It seems like the issue with Comic Sans MS not loading ended up being a problem with the Quest player settings, not the Windows environment. I can't find the old thread, but it seems like the OP had "Use default game font" unchecked in the options.


So, in a nutshell, if you use SetWebFontName to use a Google font, this will override the SetFontName settings when there is an internet connection and the Google font is available. With no internet connection, SetFontName is the backup and sets the current font to a Windows system font.


ADVANCED USERS: If you include the custom font with the game, you can use SetFontName and point to that font, as the font is included and does not need to be downloaded via the internet. (This is complicated to do. It seems like you have to convert your font to Base64 and all sorts of other things, but it can be done.)


The best practice when changing from the default font is to find Google fonts and system fonts you like and set up safety catches. Plan for the Google font to be used by most players. Only the players with no internet connection during play (which should be a very small percentage of players) will see the Windows system font to which SetFontName point.

Here's some info concerning fonts and how they are loaded when fallbacks are listed:
https://www.w3schools.com/cssref/css_websafe_fonts.asp


K.V.

Here's what the game looks like when playing in Firefox and Chrome (and in the desktop version of Quest, of course) on a Windows 10 machine:

image


K.V.

Here's what the game looks like in Firefox and Chromium on a Linux machine:
image


K.V.

Here's what it looks like in Chrome on my phone:


K.V.

Custom fonts, audio, and video are the biggest pains when designing something cross-platform.


Thanks (as always) K.V.! You were very helpful when I last had a problem in this area (https://textadventures.co.uk/forum/quest/topic/a_emp658v06eal16x4stqw/a-weird-font-problem) but I'm ashamed to admit that I didn't take the time to fully understand the problem or its solution at the time. What I'd also forgotten was that the main argument for not using Comic Sans is that it is not a Google font and so can't be used consistently across all environments. I'll leave the switch to Comic Sans as an option, with responsibility for it working falling on the player.

I also need to check that other games in which I switch fonts (when reading notes, etc.) work in all circumstances.

I'll not close the thread until I properly understand this time...


My understanding is that SetWebFontName tells Quest to download the font ready for use, so only needs to be done once per font, even if you are switching between fonts every two minutes.

The thing about SetFontName (and indeed fonts in HTML/CSS) is that there is a built-in mechanism for falling back on another font, if one is not available. I think this will work:

SetWebFontName ("Della Respira")
SetFontName ("'Comic Sans MS', 'Della Respira', cursive, sans-serif")

So the first lines will download "Della Respira". The second tells Quest to use "Comic Sans MS", and if that is not available, use "Della Respira", and if not that, use the cursive font, and failing that, sans serif.


K.V.

Ah!

That makes sense.


Excellent! Thread closed!!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums