Changing the font size of a set of text.

I know you can do contents.font.size = x which will change the font size for the whole window. But what if I want to, change the font size for a set of text, example:

def draw_title    draw_text(0, 0, 150, 25, "Sample Content")end
Should draw the text: Sample Content in a window. now that text is what ever your default size is, is there a way to say Sudo Code change the text size of: draw_title, so maybe:

Code:
def change_text_size(size, text)    #what would I do here?end
You couldn't do it the way you're explaining, with the example.

You either want to have a method that will draw the title in a particular font size, or to draw variable text in a particular font size. They would be done as follows:

Code:
def draw_sized_title(size)  contents.font.size = size  draw_titleend
Code:
def draw_sized_text(x, y, width, height, text, size)  contents.font.size = size  draw_text(x, y, width, height, text)end
I was under the impression contents.font.size = x will change the font size for the whole window.
yep - you're right. You can use oldfont = self.contents.font.dup to save the font settings first, and self.contents.font = oldfont to restore them afterwards. So just put those at the start or end of the method and it'll ONLY change it for that bit of text.
Interesting. thanks. What about contents.font.color? passing it say 0-31 doesn't seem to work. ideas on that?
contents.font.color.set(text_color(#))


color is an RGB value, not a number, so color.set requires either 3 or 4 parameters (R, G, B, Alpha), or a Color object, which is what text_color(#) gives you.
Window_Base provides the functionality of looking at the windowskin for the text color, so if you're making a window that inherits from it, you need to look at how it does that, or use Color.new.

Original thread: https://forums.rpgmakerweb.com/threads/changing-the-font-size-of-a-set-of-text.15512/