Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - PHP / Javascript text to image generator
  
User name:
Password:
Reply:
 

UserPost
Elric
Posts: 226/687
Sure, optimize away!

Those fonts look nice, by the way. I need to make a good one. Hmm...
Xkeeper
Posts: -4035/-863







Alrighty, I'll show you how I did it soon enough. Just let me try and optimize it some more, kay? ^^
Elric
Posts: 223/687
Originally posted by tz
For the slash thing, try using stripslashes().
I have no idea how to use that right.

As I posted earlier, my stuff is in a for { if() } loop...

This is how it's set up for the \ character:

if($d=="\\") $d=80;

I tried making it the following, all with no luck:

if($d=="\\") $d=stripslashes(80);
if($d=="\\") $d=stripslashes($_GET['80']);
if($d=="\\") $d=stripslashes($_GET['d']);
if($d=="\\") $d=stripslashes($_GET['d']) $d=80;

I even tried just putting it near the top, like this:

for($i=0;$i<$len;$i++){
$d=$n[$i];
$d=stripslashes(%_GET['d]);
if($d=="A") $d=1;

How should I do it?
tz
Posts: 4/4
For the slash thing, try using stripslashes().

Also, I decided that since my FFT script is coded so poorly, cleaning it up will probably not help... so you can see it here.
Elric
Posts: 215/687
Spoiler:

tz
Posts: 3/4




It was sort of a "phase" I went through, making these things for fonts from a lot of games; it definitely passed quickly though :|
Also, it seems that I am doing variable width and character coordinate stuff differently from everybody else...
Actually, instead of having to deal with coordinates in a multiple-character-high image, I first wrote a script to dissect the original font image and output an image that is only one character high, with the characters in ascii order. It might seem like a weird extra step, but it makes writing the invididual text output scripts a lot simpler.

As for variable width, I just have an associative array that contains the widths of certain characters.
I would post the source, but it is incredibly messy; perhaps I will clean it up, and then post it.
Xkeeper
Posts: -4147/-863

And I made my own font. I didn't use one from another game

You know, if you really want me to, I'll show you how I did it.

I can't believe I did something so simple with just the idea from someone else; I coded it, and I know diddily squat about it. I just played with it.

Hell, I even made this:


Which, depending on the two numbers you give it, will generate different sized bars. If one goes over 100, the smaller one will shrink proportonately.

And I did all of my work off of a modified numgfx, hence "numgfxl.php", for "numgfx long" [originally] or "numgfx letters" [just came up with it]

Edit: Even my little Pulse script works off of the same engine, just using expthing.php or whatever it's called [it also uses ?n= hehe]



I just downloaded the origonal Pulse script and had some fun... and if you notice, it ONLY does that with MY ID... any one else's will just return keys and rank
Elric
Posts: 184/687
I did the same thing Weasel did. For me, that puts all the letters into a for(); loop:

for($i=0;$i<$len;$i++){
$d=$n[$i];
if($d=="A") $d=1;
if($d=="B") $d=2;
if($d=="C") $d=3;
[more code here]
if($d=="y") $d=51;
if($d=="z") $d=52;
if($d==" ") $d=0;
ImageCopy($img,$gfx,($i+$ofs)*8,0,$d*8,0,8,8);
}
That's obviously not the whole code, but I think you get the idea.

I know that one of those 8's in the ImageCopy(); at the end is the height, since all the letters in the font are 8x8. Just not sure which.
Weasel
Posts: 396/454
My problem is that I just altered numgfx.php a bit, so I'm not really aware of how to use PHP's image functions.
Yarx
Posts: 75/133
Ahh, I did that in mine. Making them multiple lines. Basically I assume you are tracking the X coordinate in the image correct? To know where the next letter goes? Well all you have to do is track a Y coodinate as well. When you want to jump to the next line, you increment Y by however far down the next line will be (Line Feed), and then set X to 0 so that it goes to the begining of the line (Carriage Return).

As for resizing the base image. In mine, I step through the string and keep track of the height needed. Then after it's itterated through the entire string, I create my base image. Then using almost the exact same piece of code, do it again. Only this time I'm actually rendering the image, not just tracking coordinates for image size.
Elric
Posts: 180/687
OK, that's simple enough.

But how do I tell it to make this:

into this:

?

And I REALLY need to fix the "a" in that font. Probably the e too...
FreeDOS
Posts: 486/1657
Use the traditional backslash (UNIX-style, \) to make special characters.

For example:
\n = New line
\t = Tab
\\ = Backslash \
Elric
Posts: 179/687
It's not hard to make the base image larger. Hell, I did it, so anyone should be able to. XD

Of course, if we could get Acmlm's ass in here, he could tell us, since he has a nifty one. It has all kinds of things in it, and the letters/numbers/etc. are on multiple lines, too. Damn Canadians.

I'm figureing I'll have to do something similar to Xkeeper, and use a special symbol to denote line-breaks. Of course, I still have the problem of making it generate an image with the proper height, alignment, text,

On second thought, I think I'll just stick to using multiple <img src> tags... Probably gonna be easier on me.
Weasel
Posts: 386/454
Bloody good question

Xkeeper's script uses the ~ tilda to detect it. That's fine and all, but I don't know how I would make the image suddenly larger to put that in.

Of course, I didn't spend time bothering to figure it out anyway XD
Elric
Posts: 177/687




Now all I need to get is linebreaks and symbols, and I'll be set. YAY!

How would I detect a linebreak?
Yarx
Posts: 69/133
Well, the only way to do what you're asking is using some kind of server side coding, such as PHP, JSP, ASP, etc....

Weasel and XKeeper used PHP to do it. While I used ASP.NET

If you want, I put up the source to mine on my site a while back and it's still available here
The key difference you'll find in mine is that it has a array that is populated at the begining to keep track of character coordinates, since I am using a variable width font, not all the characters are the same size. Also I have code to dynamically scale the size of the image's height, width, and line wrapping. So there is a bit more code there than most. It should be pretty simple though.
BGenesis
Posts: 32/38
You still haven't actually offerred any wholesome help, guys! Or have you? Anyway, with PHP it can be done pretty easily. This guy made a font previewer that uses a bitmap font and text input to output an image:

http://www.zone38.net/font/preview.php

Here's the source:

http://www.zone38.net/font/preview.php.txt
Weasel
Posts: 378/454

Note my AWESOME Castlevania3 text


I still haven't figured out how to put line breaks
HyperLamer
Posts: 860/8210
Yarx
Posts: 66/133
This is a long thread. Click here to view it.
Acmlm's Board - I2 Archive - Programming - PHP / Javascript text to image generator


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.018 seconds.