loaded font and setPixelSizes tied together?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

loaded font and setPixelSizes tied together?

Post by liquid8d »

I am trying to use multiple font sizes, but it seems that if you try to set more than one variable to the same font, and just change it's pixelsize, it doesn't work. They all end up being the same size as the last setPixelSizes provided. Maybe this is the way it should be by design, or maybe a bug,?

For instance:

Code: Select all


myFont = font.load("font.ttf")

smallFont = myFont
smallFont:setPixelSizes(0, 10)

mediumFont = myFont
mediumFont:setPixelSizes(0, 12)

largeFont = myFont
largeFont:setPixelSizes(0, 14)

The only way I can get it to work is to load each font seperately...

Code: Select all


smallFont = font.load("font.ttf")
smallFont:setPixelSizes(0, 10)

mediumFont = font.load("font.ttf")
mediumFont:setPixelSizes(0, 12)

largeFont = font.load("font.ttf")
largeFont:setPixelSizes(0, 14)

So question is, a) is this an error, and b) is loading the same font multiple times going to eat memory or cause any kind of performance hit?


This is on .16 luaplayer.


Thanks,

liquid8d
modsyn
Posts: 28
Joined: Tue Sep 27, 2005 6:02 am

Post by modsyn »

i don't think it's a bug. saying
mediumFont = myFont is really just saying that mediumFont and myFont
both point to the same thing. so, if you have 3 or 4 variables all pointing
at the same Font object then using any of them will affect the same thing.
someone correct me if i'm wrong, but i think that's how it works.

i noticed that truetype printing is soooo slow. it was the reason my downloads
were dragging. i went on a whim one day and replaced all of the fontPrints
with regular prints and the speed was more than twice as fast.
liquid8d
Posts: 66
Joined: Thu Jun 30, 2005 6:29 am

Post by liquid8d »

that's what I am assuming. To me it just seemed that setting another variable to the same loaded font would use the same font, but have it's own settings... apparently not. Seems odd to have to load the same font multiple times to have different pixel settings... Thanks anyways.

Truetype is pretty slow, hopefully it can be sped up soon? :)
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

liquid8d wrote:Truetype is pretty slow, hopefully it can be sped up soon? :)
Yes, it's slow because the curves of the fonts are rendered to an byte array again and again for each blit, which then is used for plotting the font. The byte array should be cached and the cache should be invalidated when setting a new font size, then it will be nearly as fast as image blitting.
Post Reply