forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help: "Verdana" Font... TTF or Bitmap?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
SnowyDisposition



Joined: 27 Sep 2006
Posts: 4

PostPosted: Wed Sep 27, 2006 11:50 am    Post subject: Help: "Verdana" Font... TTF or Bitmap? Reply with quote

Hey, everyone. Thank's for checking out my post; I really need some help right now.

I've got a game going (if you help me I'll let you know what it is ^_^) and I really, really need to use the font "Verdana" in this game. It's a common TTF font that is on just about every computer in the universe, but there are two problems with TTFs:

1.) They take a full second to load each time a page has text on it. Built-in monospaced and bitmap fonts don't seem to take any time at all.

2.) They're anti-aliased. In other words, they look too pretty and glowy. I really need a pixelated font (similar to the monospaced) as strange as it sounds. It looks a lot better.

So what I need is a sample code of how to make a Bitmap font take upper- and lower-case letters into consideration. My font function right now blits everything in upper-case because my code is too simple. All I have is like,

~Based on the letter I inputted, go [x] pixels into font.png, take out that letter, and blit it.~

And it does blit it, but always in upper case :(. Like I said, any help would be REALLY useful, like if you know of any check commands such as string.case to make sure it blits the correct case! Thanks again!!!
Back to top
View user's profile Send private message
SnowyDisposition



Joined: 27 Sep 2006
Posts: 4

PostPosted: Sat Sep 30, 2006 9:59 am    Post subject: Reply with quote

No one knows?
Back to top
View user's profile Send private message
razorrifh



Joined: 04 Jun 2005
Posts: 23
Location: Penn State

PostPosted: Sat Sep 30, 2006 12:03 pm    Post subject: Reply with quote

why not just test each character to see its case and blit the appropriate character?

i dont know the api/fuction to edit strings off the top of my head (i never did like string manipulation :-\) but i'd assume its something like:
Code:
myString = "ThIs Is My TeXt"
tempString = ""

tempString = myString.char(1) -- this variable now contains the string "T"
if tempString == "t" then
   -- add code to draw the font bitmap to an offscreen image (with alpha on)
   -- and then increment a variable with the width of the characters so you
   -- know where to place the next one
elseif tempString == "T"

end


personally thats how i'd do it, of course adding 25 more if statements for the other letters, and some more for numbers and others. you could even get a variable width font if you did that and just incremented the value dynamically on the image's width property.

ive no idea how many cpu cycles an if statement would be, especially in an interpreted language like lua, but ive programmed a small fighter (like super gem fighter) and have at least 100 (not including the if's for the enemy ai) if statements to see what frame of animation the characters are at and if they need to be incremented and theres no slow-down at all.

dunno if thats the easiest way, but that's how i'd get it done. hope it helps.
Back to top
View user's profile Send private message Visit poster's website
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sat Sep 30, 2006 4:04 pm    Post subject: Reply with quote

LOL Thats a waste of time and effort, if you are looking to pixelate your fonts, then find a font thats pixelated using the TTF library.

Another thing is that if you load the FONT into a variable first its stored into memory first. Which means each time it is called it doesnt load from the memory stick and loads the character of the font. That often frees up alot of cycle time however it will never be as fast as drawing the system characters that are done through the SDK.

Also if you are dead set on using a .png system. I would use

if (string.upper(string.char(MyChar)) == string.char(MyChar)) then
-- I get a char offset! what?!

end
Back to top
View user's profile Send private message
razorrifh



Joined: 04 Jun 2005
Posts: 23
Location: Penn State

PostPosted: Sat Sep 30, 2006 4:10 pm    Post subject: Reply with quote

heh, i said i didnt like string processing :-p

romero126 wrote:
if (string.upper(string.char(MyChar)) == string.char(MyChar)) then
-- I get a char offset! what?!

end


doesnt that just check to see if MyChar is uppercase? if it is it ignores the comment, if it doesnt, it doesnt go in the if-then code block?
Back to top
View user's profile Send private message Visit poster's website
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sat Sep 30, 2006 5:06 pm    Post subject: Reply with quote

Yes, it checks to see if the string is uppercase, If so offset the blit by x- which is the position of A of the Uppercase Letterblocks. If its not Uppercase then it uses the offset of a lowercase letter.

Generally it would be Uppercase and Lowercase should be based on the YAxis so the offset can be blit differently.

Makes things a little easier.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group