Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 1 | <?php |
| 2 | header("Content-type: text/html; charset=UTF-8"); |
| 3 | require_once('common.php'); |
| 4 | /* Set internal character encoding to UTF-8 */ |
| 5 | mb_internal_encoding("UTF-8"); |
| 6 | ?> |
| 7 | <!DOCTYPE html> |
| 8 | <html> |
| 9 | <head> |
| 10 | <meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> |
| 11 | <title>Font coverage of translations</title> |
| 12 | <link rel="stylesheet" href="rockbox.css" /> |
| 13 | <style type="text/css"> |
| 14 | td { |
| 15 | margin: 0px; |
| 16 | padding: 0px; |
| 17 | vertical-align: middle; |
| 18 | } |
| 19 | td img { |
| 20 | border: 0px solid black; |
| 21 | } |
| 22 | td.lang { |
| 23 | white-space: nowrap; |
| 24 | } |
| 25 | td.full { |
| 26 | background-color: green; |
| 27 | } |
| 28 | </style> |
| 29 | </head> |
| 30 | <body> |
| 31 | |
| 32 | <h1>Language coverage of fonts</h1> |
| 33 | |
| 34 | <p>This page lists fonts included with Rockbox and tries to visualise their |
| 35 | coverage of the included translations. The darker the square, the better |
| 36 | coverage. A <span style="color: green">green</span> square indicates full |
| 37 | coverage.</p> |
| 38 | |
| 39 | <table> |
| 40 | <thead> |
| 41 | <tr> |
| 42 | <td></td> |
| 43 | <?php |
| 44 | |
| 45 | function getverticalimg($text) { |
| 46 | $filename = sprintf('headers/%s.png', str_replace("/", "_", $text)); |
| 47 | if (!file_exists($filename) || filemtime(__FILE__) > filemtime($filename)) { |
| 48 | $height = 200; |
| 49 | $width = 11; |
| 50 | $im = imagecreate($width, $height); |
| 51 | $bg = imagecolorallocate($im, 0x9A, 0xBD, 0xDE); |
| 52 | $fg = imagecolorallocate($im, 0, 0, 0); |
| 53 | imagestringup($im, 2, -1, $height - 2, $text, $fg); |
| 54 | imagecolortransparent($im, $bg); |
| 55 | imagepng($im, $filename); |
| 56 | } |
| 57 | return sprintf("<img src='%s' />", $filename); |
| 58 | } |
| 59 | |
| 60 | $fontstats = parse_ini_file('fontcoverage.ini', true); |
| 61 | $langs = languageinfo(); |
| 62 | |
| 63 | /* Output the first row - font names */ |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 64 | if (isset($fontstats['english'])) { |
| 65 | foreach($fontstats['english'] as $font => $coverage) { |
| 66 | printf(" <td>%s</td>\n", getverticalimg($font)); |
| 67 | } |
| 68 | print(" </tr>\n </thead>\n <tbody>\n"); |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 69 | } |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 70 | |
| 71 | foreach($fontstats as $lang => $stats) { |
| 72 | printf(" <tr>\n <td class='lang'><img src='flags/%d/%s.png' /> %s</td>\n",SMALL_FLAGSIZE, urlencode($langs[$lang]['flag']), $langs[$lang]['name']); |
| 73 | foreach($stats as $font => $coverage) { |
| 74 | if ($coverage == 1) { |
| 75 | printf(" <td class='full' title='%s has full coverage of %s'> </td>\n", $font, $lang); |
| 76 | } |
| 77 | else { |
| 78 | $r = 0x9A * (1-$coverage); |
| 79 | $g = 0xBD * (1-$coverage); |
| 80 | $b = 0xDE * (1-$coverage); |
| 81 | printf(" <td style='background-color: #%02X%02X%02X' title='%s has %0.2f%% coverage of %s'> </td>", $r, $g, $b, $font, $coverage*100, $lang); |
| 82 | } |
| 83 | } |
| 84 | print(" </tr>\n"); |
| 85 | } |
| 86 | ?> |
| 87 | </tbody> |
| 88 | </table> |
| 89 | </body> |
| 90 | </html> |