Jibble

Author Topic: Multiple fonts on the same line of speech(?)  (Read 1074 times)

Stupot

  • Posts: 6,546
    • I can help with play testing
    • I can help with proof reading
    • I can help with story design
    • I can help with voice acting
Multiple fonts on the same line of speech(?)
« on: 10 May 2016, 01:11 »
I have a feeling the answer is no, but some clever clogs might know a workaround. Is it at all possible to use different fonts within a single line of speech.

We normally change the fonts outside of the speech commands so you can change the font from one time to the next, but how about within the same line?, much like we do all the time in any basic word processing (including this  forum)?

Any ideas?

Snarky

  • Global Moderator
  • Posts: 6,706
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Multiple fonts on the same line of speech(?)
« Reply #1 on: 10 May 2016, 01:49 »
Render it yourself with DrawString() on an Overlay. You might be able to use the HyperText module as a template: http://www.adventuregamestudio.co.uk/forums/index.php?topic=29358.0

Stupot

  • Posts: 6,546
    • I can help with play testing
    • I can help with proof reading
    • I can help with story design
    • I can help with voice acting
Re: Multiple fonts on the same line of speech(?)
« Reply #2 on: 10 May 2016, 05:25 »
Thanks Snarky. I'll look into it.

Danvzare

  • Posts: 2,725
  • The Man with No Name
    • I can help with AGS tutoring
    • I can help with proof reading
    • I can help with scripting
    • I can help with voice acting
Re: Multiple fonts on the same line of speech(?)
« Reply #3 on: 10 May 2016, 15:22 »
You could (and I honestly don't know if this could work) make a custom font, with the unused characters in one font replaced with the letters from another font. And then just use that font for whenever you need to have multiple fonts on a single line of text.

It's just an idea though. There's probably all sorts of problems I'm not considering here.

Monsieur OUXX

  • Posts: 3,538
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
Re: Multiple fonts on the same line of speech(?)
« Reply #4 on: 10 May 2016, 22:46 »
You could (and I honestly don't know if this could work) make a custom font, with the unused characters in one font replaced with the letters from another font. And then just use that font for whenever you need to have multiple fonts on a single line of text.

It's just an idea though. There's probably all sorts of problems I'm not considering here.
That would work, but why make things complicated when you can just use a module ten times more simple and powerful?
 

Stupot

  • Posts: 6,546
    • I can help with play testing
    • I can help with proof reading
    • I can help with story design
    • I can help with voice acting
Re: Multiple fonts on the same line of speech(?)
« Reply #5 on: 11 May 2016, 04:05 »
The hypertext module links are all broken. Does anyone have a mirror?

@Dan, that's not a terrible idea but it wouldn't quite work for what I'm hoping to achieve, for various reasons.

Snarky

  • Global Moderator
  • Posts: 6,706
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Multiple fonts on the same line of speech(?)
« Reply #6 on: 11 May 2016, 17:33 »
I think I have it on some other drive, and will try to dig it up. However, it is a bit of an overkill for what you describe, and what you need shouldn't be terribly hard to write yourself (I'm assuming that you want to render the text across multiple lines in a bottom-expanding box of predefined width):

-Divide up the text into segments, one for each time you switch font (probably easiest to just pass a string array in the first place, and a corresponding array of FontTypes; alternatively you could write some text parsing functions that would allow you to put formatting tags into the string, but that would be a lot more work)
-Figure out how to render each string segment inside the defined rendering area (i.e. the given width). For each string segment:
--calculate its size when rendered in the appropriate font, using GetTextHeight()/GetTextWidth(). Keep track of these values.
--work line by line. Calculate and keep track of the starting x-position of each segment (by adding the widths of the preceding segments together), and the max text height seen on this line so far.
--given the starting x-position of the rendering and the width of the rendering area, determine if you need to line-break (doing line-breaking internally within a segment is probably the most complicated part, so avoid it if you can)
--once you've reached the end of the line, use the max text height (for line spacing) and the various x-positions to position and draw each string segment, and move on to the next line.

I don't remember how AGS DrawString() positions text vertically, but I suspect it's by the upper edge. So you may need to define a vertical displacement for each font so that they'll all have the same baseline.