generate-buttons.php
3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
function getButtons() {
return array(
"add.png" => _("Add"),
"cancel.png" => _("Cancel"),
"next.png" => _("Next"),
"previous.png" => _("Previous"),
"back.png" => _("Back"),
"addcomment.png" => _("Add Comment"),
"subscribe.png" => _("Subscribe"),
"unsubscribe.png" => _("Unsubscribe"),
"reject.png" => _("Reject"),
"updatePassword.png" => _("Update Password"),
"delete.png" => _("Delete"),
"select.png" => _("Select"),
"update.png" => _("Update"),
"assign.png" => _("Assign"),
"search.png" => _("Search"),
"edit.png" => _("Edit"),
"approve.png" => _("Approve"),
"done.png" => _("Done"),
"publish.png" => _("Publish"),
"move.png" => _("Move"),
"remove.png" => _("Remove"),
"restore.png" => _("Restore"),
"submit.png" => _("Submit"),
"expunge.png" => _("Expunge"),
"restorehere.png" => _("Restore Here"),
"reply.png" => _("Reply"),
"new.png" => _("New"),
"reset.png" => _("Reset"),
"archive.png" => _("Archive"),
"browse.png" => _("Browse"),
"checkin.png" => _("Check In"),
"checkout.png" => _("Check Out"),
"download.png" => _("Download"),
"email.png" => _("Email"),
"movehere.png" => _("Move Here"),
"begin.png" => _("Begin"),
"login.png" => _("Login"),
"checkall.png" => _("Check All"),
"clearall.png" => _("Clear All"),
);
}
function generate_button($fn, $text, $height) {
global $font, $fontsize;
$text = strtoupper($text);
$size = imagettfbbox($fontsize,0, $font,$text);
$dx = abs($size[2]-$size[0]);
#$dy = abs($size[5]-$size[3]);
$dy = $height;
$xpad=9;
$ypad=9;
$im = ImageCreateTrueColor($dx+$xpad,$dy+$ypad);
$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0,0,0);
imagefill($im, 0, 0, $white);
//ImageRectangle($im, 0, 0, $dx + $xpad - 1, $dy + $ypad - 1, $black);
ImageRectangle($im, 2, 2, $dx + $xpad - 3, $dy + $ypad - 3, $black);
ImageTTFText($im, $fontsize, 0, (int)($xpad/2), $dy+(int)($ypad/2), $black, $font, $text);
ImagePng($im, $fn);
ImageDestroy($im);
}
function get_height($buttons) {
global $font, $fontsize;
$maxHeight = 0;
foreach ($buttons as $fn => $text) {
$text = strtoupper($text);
$size = imagettfbbox($fontsize,0, $font,$text);
$dy = abs($size[5]-$size[3]);
if ($dy > $maxHeight) {
$maxHeight = $dy;
}
}
return $maxHeight;
}
$argv = $_SERVER['argv'];
$sLocale = $argv[1];
error_reporting(E_ALL);
putenv('LANG=' . $sLocale);
setlocale(LC_ALL, $sLocale);
// Set the text domain
$sDomain = 'knowledgeTree';
$btd = bindtextdomain($sDomain, "/home/nbm/cvs/knowledgeTree/i18n");
textdomain($sDomain);
$font = "/usr/share/fonts/bitstream-vera/Vera.ttf";
$fontsize = 8;
$buttons = getButtons();
$path = "/tmp/";
$height = get_height($buttons);
foreach ($buttons as $fn => $text) {
generate_button($path . $fn, $text, $height);
}
?>