Hmmm... dilemma
Python is used more in other programs (Blender, GIMP, Inkscape), maybe I will just stick with Python. Is a better long term investment.

Again, PHP doesnt need anything installed, it works as if it was normal JPG or PNG image.Personally I would prefer to program in Python (cleaner code), but nobody has that on his PC
Java doesnt work right out of the box. I just had to install XP when my HDD crashed, so i didnt have java installed. with PHP its practically the same, you dont have to install anything if you own a server already, they probably have GD library there. you could ask Sektor to use his server, or Vike's server.Nice thing of Java (Processing) is that I don't need to load/add/import anything. It works right out of the box.
Why is there 385 indexes in that array? ascii has 256 characters only o_O im not sure how should i read this array...This is the data array for normal font:
Code: Select all
<?php
// set headers:
header("Content-type: image/png");
if($_GET['text'] == ""){
$text = "usage: ?text=something";
}else{
$text = $_GET['text'];
}
$text = trim($text); // remove extra whitespace like newlines etc from start/end.
$font_height = 25; // normal font height.
$poswidth = array(0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,9, 9,6, 15,11, 0,0, 26,12, 38,11, 0,0,
49,6, 55,9, 64,9, 73,12, 0,0, 85,6, 91,11, 102,6, 108,12, 120,12, 132,9, 141,12, 153,12, 165,13, 178,12, 190,12,
202,12, 214,12, 226,12, 238,6, 244,6, 0,0, 0,0, 0,0, 250,11, 261,6, 267,11, 278,11, 289,11, 300,11, 311,11,
322,11, 333,11, 344,11, 355,8, 363,12, 375,13, 388,11, 399,16, 415,11, 426,11, 437,11, 448,11, 459,11, 470,11,
481,10, 491,11, 502,12, 514,16, 530,11, 541,12, 553,10, 0,0, 0,0, 0,0, 0,0, 563,11, 0,0, 574,11, 585,11, 596,11,
607,11, 618,11, 629,11, 640,11, 651,11, 662,6, 668,8, 676,13, 689,6, 695,16, 711,11, 722,11, 733,11, 744,11,
755,11, 766,11, 777,9, 786,11, 797,12, 809,16, 825,12, 837,11, 848,10, 0,0, 0,0, 0,0, 858,13, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 871,11, 882,11, 893,11,
904,11, 0,0, 915,11, 0,0, 926,16, 942,11, 953,11, 964,11, 975,11, 986,11, 997,9, 1006,9, 1015,11, 1026,10, 0,0,
1036,11, 1047,11, 1058,11, 1069,11, 0,0, 1080,11, 0,0, 0,0, 1091,11, 1102,11, 1113,11, 1124,11, 0,0, 0,0,
1135,12, 1147,11, 1158,11, 1169,11, 0,0, 1180,11, 0,0, 1191,17, 1208,11, 1219,11, 1230,11, 1241,11, 1252,11,
1263,8, 1271,8, 1279,10, 1289,10, 0,0, 1299,11, 1310,11, 1321,11, 1332,11, 0,0, 1343,11, 0,0, 0,0, 1354,11,
1365,11, 1376,11, 1387,11, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1398,12, 1410,12, 1422,12, 1434,12, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1446,12, 1458,12, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1470,12, 1482,7, 1489,12, 1501,12, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 1513,12, 1525,12, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0, 0,0, 1537,11, 1548,11, 1559,11, 1570,11, 0,0, 0,0, 0,0, 0,0);
// calculate resulting image size:
$width = 0; // resulting image sizes will be set to these,
$height = 0;
$xpos = 0; // currently looped chars pixel positions,
$ypos = 0;
$len = strlen($text);
for($p = 0; $p < $len; $p++){
$val = ord($text[$p]); // get char numeric value.
$charwidth = $poswidth[$val*2+1];
// process newlines:
if($text[$p] == "\n"){
$ypos += $font_height;
$xpos = 0;
}
if($charwidth == 0){
continue; // skip chars that cant be rendered.
}
$xpos += $charwidth;
// find max image width (added $charwidth previously):
if($xpos > $width){
$width = $xpos;
}
}
$height = $ypos+$font_height; // add $font_height here because there is no last "\n" char (was trimmed).
// load font:
$font = imagecreatefrompng("gta2font_normal.png");
imagealphablending($font, true);
// render image:
$im = imagecreatetruecolor($width, $height);
imagealphablending($im, false);
imagesavealpha($im, true);
$bgcolor = imagecolorallocatealpha($im, 239,239,239, 127); // 127 = full transparency.
imagefilledrectangle($im, 0, 0, $width, $height, $bgcolor);
$xpos = 0;
$ypos = 0;
for($p = 0; $p < $len; $p++){
$val = ord($text[$p]); // get char numeric value.
$charwidth = $poswidth[$val*2+1];
// process newlines:
if($text[$p] == "\n"){
$ypos += $font_height;
$xpos = 0;
}
if($charwidth == 0){
continue; // skip chars that cant be rendered.
}
$charpos = $poswidth[$val*2];
imagecopy($im, $font, $xpos, $ypos, $charpos, 0, $charwidth, $font_height);
$xpos += $charwidth;
// find max image width (added $charwidth previously):
if($xpos > $width){
$width = $xpos;
}
}
imagepng($im); // output PNG image
// free resources:
imagedestroy($im);
imagedestroy($font);
?>
Code: Select all
<?php
if($_GET['text'] != ""){
$text = $_GET['text'];
}else{
$text = "";
}
print"<form method=\"get\" action=\"\">
<textarea name=\"text\" rows=\"8\" cols=\"70\">".htmlspecialchars($text)."</textarea><br>
<input type=\"submit\" value=\"Textify!\">
</form>";
if($text != ""){
$textraw = rawurlencode($text);
print"<br><img src=\"gta2text.php?text=$textraw\" style=\"background-image:url('background.png'); padding:10px\">";
}
?>
Code: Select all
tags.
How does GTA2 do it? i think its the best way(?)Perhaps the nicest way would be to do it like in my version 3 or like the forums do it: "[2]GTA[16]2" this would generate a white GTA and a (russian) red 2.
Only tell the palet numbers, i can then take the palet from bil.sty and use that image (extracted from stytool) to generate the correct colored fonts myself. Edit: oh wait, i would need the original font sprites from bil.sty as well (not a problem though). how did you generate your font PNG images? did you change their order somehow?I will see if I can give you the 17 "basic" colours used around the gta2 community.
Code: Select all
Color number: 1
60,56,8,
172,145,86,
141,112,52,
Color number: 2
64,53,36,
179,149,100,
140,116,78,
Color number: 3
91,91,91,
255,255,255,
199,199,199,
Color number: 4
58,74,91,
162,208,255,
126,162,199,
Color number: 5
53,68,84,
149,191,234,
116,149,183,
Color number: 6
0,55,91,
0,153,255,
0,119,199,
Color number: 7
91,91,39,
255,255,110,
199,199,86,
Color number: 8
91,58,28,
255,163,79,
199,127,62,
Color number: 9
84,72,91,
236,203,255,
184,158,199,
Color number: 10
91,35,6,
255,99,18,
199,77,14,
Color number: 11
35,91,9,
97,255,24,
76,199,19,
Color number: 12
91,75,39,
255,210,109,
199,164,85,
I only adjusted (fixed reflection bugs) the font cosmetically, as far as I remember I left the height as gta2 original. But you/we are free of course to change it to more centered.T.M. wrote:@Cuban-Pete, how come the normal font has a lot of padding there in y-axis? the multiline looks a bit too "paddy", so i removed some pixels, now its 23 instead of 25 pixels in height. did you guess this padding or is it like that in gta2 too? (i noticed the large font doesnt have ANY padding).