Changing Fonts when someone is speaking
DropTheChair
08 Mar 2016, 14:32I am sure this has been asked before but I cannot find any information on the subject. (Or at least none that is working for me)
Consider two people are having a conversation.
'Hello" Guy 1 says.
"Sup bro" Guy 2 says.
Lets say I want Guy 1 to be British. How would I change his font so it is noticeable? (I am using Google Fonts through out the game so put that in mind)
Every other word is in the sentence is in Roboto but I want to change Guy 1's font into Slabo 27px? How would I go about doing this? I would like this to be in as little code as possible. For example I can change the font from normal to bold by writing "<b>" before it and "</b>" after. Is there way I can change the font like this?
I would like this to be answered as soon as possible.
Thanks in advanced!
PS: I do have the latest version.
Consider two people are having a conversation.
'Hello" Guy 1 says.
"Sup bro" Guy 2 says.
Lets say I want Guy 1 to be British. How would I change his font so it is noticeable? (I am using Google Fonts through out the game so put that in mind)
Every other word is in the sentence is in Roboto but I want to change Guy 1's font into Slabo 27px? How would I go about doing this? I would like this to be in as little code as possible. For example I can change the font from normal to bold by writing "<b>" before it and "</b>" after. Is there way I can change the font like this?
I would like this to be answered as soon as possible.
Thanks in advanced!
PS: I do have the latest version.

XanMag
08 Mar 2016, 17:08Trying to speak from memory here, but isn't there an option when you add a script to change font? Look at that. It should be helpful, right? If you need it "on the fly" you can always view the changed font script in code view and translate that code wherever you need it in your paragraph.

jaynabonne
08 Mar 2016, 21:34You can always do:
to set a font. You can also use:
and then define "british-guy" in some CSS. That way if you decide to change the font later, you can just change it in one place instead of ten zillion.
<span style="font-family:MyFont">The text I care about</span>
to set a font. You can also use:
<span class="british-guy>The text I care about</span>
and then define "british-guy" in some CSS. That way if you decide to change the font later, you can just change it in one place instead of ten zillion.
Marzipan
08 Mar 2016, 23:30If you can get this working please paste the code, this was something I desperately wanted to do in my game, but I finally had to give up.
I don't think I ever had any luck with this, for instance, unless it's a matter of only a few fonts being recognized.
<span style="font-family:MyFont">The text I care about</span>
I don't think I ever had any luck with this, for instance, unless it's a matter of only a few fonts being recognized.

jaynabonne
09 Mar 2016, 07:40This works for me:
Note that you don't need the css stuff unless you go the "class" approach. You can use the inline styles without it.

<!--Saved by Quest 5.6.5783.24153-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="fontstyle">
<gameid>e54b175d-ce44-4462-972d-4a7f68c993e0</gameid>
<version>1.0</version>
<firstpublished>2016</firstpublished>
<start type="script"><![CDATA[
JS.addExternalStylesheet("http://fonts.googleapis.com/css?family=Nothing+You+Could+Do")
JS.addExternalStylesheet("http://fonts.googleapis.com/css?family=Coming+Soon")
OutputTextNoBr(game.css)
msg ("<span style=\"font-family:courier\">This is Courier</span>")
msg ("<span style=\"font-family:courier; color:red\">This is Courier in red</span>")
msg ("<span style=\"font-family:courier; font-weight:bold\">This is Courier bold</span>")
msg ("<span style=\"font-family:'Nothing You Could Do'\">This is Nothing You Could Do</span>")
msg ("<span style=\"font-family:'Coming Soon'\">This is Coming Soon</span>")
msg("")
msg("<span class=\"speaker1\">What's on second</span>")
msg("<span class=\"speaker2\">I didn't ask you who's on second</span>")
msg("<span class=\"speaker1\">No, Who's on first</span>")
msg("<span class=\"speaker2\">I don't know</span>")
msg("<span class=\"speaker1\">Third base</span>")
msg("<span class=\"speaker2\">Third base</span>")
]]></start>
<css>
<![CDATA[
<style type="text/css">
.speaker1 {
font-family: 'Nothing You Could Do';
color: green;
}
.speaker2 {
font-family: 'Coming Soon';
color: blue;
}
</style>
]]>
</css>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>
Note that you don't need the css stuff unless you go the "class" approach. You can use the inline styles without it.
Marzipan
09 Mar 2016, 14:59Hmm. So that does work for the examples you gave. I guess the question I should be asking then is if there's any way to load in a new google font that isn't one of the ones Quest recognizes by default?
Google shows how to use it on a website, including code to use for javascript, but I'm not sure how to apply it to a Quest game.
Google shows how to use it on a website, including code to use for javascript, but I'm not sure how to apply it to a Quest game.

jaynabonne
09 Mar 2016, 17:16I'm fairly certain this line in the example does it:
Just substitute the font you wish. It's all CSS (unless I'm totally wrong).
JS.addExternalStylesheet("http://fonts.googleapis.com/css?family=Nothing+You+Could+Do")
Just substitute the font you wish. It's all CSS (unless I'm totally wrong).
Watcher55
10 Mar 2016, 11:39Any reason you're not doing it the easy way via SetWebFontName? The choices there are immense. See here for instructions:
http://docs.textadventures.co.uk/quest/ ... tname.html
http://docs.textadventures.co.uk/quest/ ... tname.html

jaynabonne
10 Mar 2016, 12:43That sets the current font to a web font. Certainly, if you want to change the font between each msg or for a large block (or all) of your text, you can do that. But sometimes it's clearer (and the OP asked it that way) to be able to apply styles without having to make an explicit font set request, especially if you had in-stream changes like this:
I would find it a bit of pain to have to do:
It's good to know that that function exists (so thanks for that), and it might be useful in a large number of cases, but there will almost certainly be cases where it's prohibitive to use. It's the old "markup vs function call approach" choice.
msg("The donkey said, \"<span class=\"speaker1\">Shrek!</span>\" before collapsing in a heap.")
I would find it a bit of pain to have to do:
OutputTextNoBr("The donkey said, ")
SetWebFont(something)
OutputTextNoBr("\"Shrek!\"")
SetWebFont(back to default font)
OutputTextNoBr(" before collapsing in a heap.")
It's good to know that that function exists (so thanks for that), and it might be useful in a large number of cases, but there will almost certainly be cases where it's prohibitive to use. It's the old "markup vs function call approach" choice.
