Hello
I'm loading a .tff file and using a size of 120, How to put a second text with the same font but with a size of 50, basically I want 2 texts with the same font but with 2 different sizes ??
https://www.dropbox.com/s/nwkjaetppb99b ... 1.zip?dl=0
Thank you Bernard
I want 2 texts with the same font but with 2 different sizes??
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: I want 2 texts with the same font but with 2 different sizes??
create another font with the same ttf file, but with a size of 50; assuming you assigned both of them to separate variables, you can setFont them whenever you want to switch fonts.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: I want 2 texts with the same font but with 2 different sizes??
thank you
I have to reload the same file twice with a different size?
I have to reload the same file twice with a different size?
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: I want 2 texts with the same font but with 2 different sizes??
It seems to be that way, though i'm not sure whether there are any optimizations under the hood or not;
I wanted to say that you could cheat a bit by creating a Rasterizer instead, and then creating two differently sized fonts using that instead of the font file, but apparently the rasterizers themselves require the font size to be defined, so even if love.graphics.newFont coult take a Rasterizer object, we would not have moved forward too much.
Then again, love.graphics.newFont might accept a FileData object, so you could load the file itself into RAM only once, and use that to create two fonts with different sizes; that may be a viable solution...
I wanted to say that you could cheat a bit by creating a Rasterizer instead, and then creating two differently sized fonts using that instead of the font file, but apparently the rasterizers themselves require the font size to be defined, so even if love.graphics.newFont coult take a Rasterizer object, we would not have moved forward too much.
Then again, love.graphics.newFont might accept a FileData object, so you could load the file itself into RAM only once, and use that to create two fonts with different sizes; that may be a viable solution...
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: I want 2 texts with the same font but with 2 different sizes??
thank you
do you have a tutorial on fileData?
do you have a tutorial on fileData?
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: I want 2 texts with the same font but with 2 different sizes??
Apart from clicking the link in my previous post that takes you to its wiki article, here's a quick code you can look at:
Then again, i'm making an assumption here that love.graphics.newFont being able to take a FileData as its parameter, since a lot of functions can that aren't necessarily notated on the wiki as such. If it doesn't support it, then we're back to the original solution, creating the two sizes of the same font twice from disk.
Code: Select all
myFontFileData = love.filesystem.newFileData('relative.path.to.your.font.ttf')
myFont120pt = love.graphics.newFont(myFontFileData, 120)
myFont50pt = love.graphics.newFont(myFontFileData, 50)
-- of course, you could also have just one table called myFont, and have the 50th and 120th index be the Font objects you create; it's a matter of preference only, though.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: I want 2 texts with the same font but with 2 different sizes??
Thank you very much
Re: I want 2 texts with the same font but with 2 different sizes??
Just some additional info ... if you use lots of different characters in a pretty big size your area of interest might be the required resources for the cached bitmaps/textures of the font instead of the loaded ttf-file. The bitmaps for the characters will be created and cached by love automatically (only those you actually used, so it highly depends on what you print and how many different fonts and sizes you use).
Re: I want 2 texts with the same font but with 2 different sizes??
Thank you very much
Re: I want 2 texts with the same font but with 2 different sizes??
"All variants which accept a filename can also accept a Data object instead." - love.graphics.newFont
A FileData object is a Data object. It's documented to work.
A FileData object is a Data object. It's documented to work.
Who is online
Users browsing this forum: Google [Bot] and 2 guests