Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 1 | <?php |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 2 | /************************************************************************ |
| 3 | * __________ __ ___. |
| 4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | * \/ \/ \/ \/ \/ |
| 9 | * Copyright (C) 2010 Jonas Häggqvist |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License |
| 13 | * as published by the Free Software Foundation; either version 2 |
| 14 | * of the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 17 | * KIND, either express or implied. |
| 18 | * |
| 19 | **************************************************************************/ |
| 20 | |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 21 | header("Content-type: text/html; charset=UTF-8"); |
| 22 | require_once('common.php'); |
| 23 | /* Set internal character encoding to UTF-8 */ |
| 24 | mb_internal_encoding("UTF-8"); |
| 25 | ?> |
| 26 | <!DOCTYPE html> |
| 27 | <html> |
| 28 | <head> |
| 29 | <meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> |
| 30 | <title>Font coverage of translations</title> |
| 31 | <link rel="stylesheet" href="rockbox.css" /> |
| 32 | <style type="text/css"> |
| 33 | td { |
| 34 | margin: 0px; |
| 35 | padding: 0px; |
| 36 | vertical-align: middle; |
| 37 | } |
| 38 | td img { |
| 39 | border: 0px solid black; |
| 40 | } |
| 41 | td.lang { |
| 42 | white-space: nowrap; |
| 43 | } |
| 44 | td.full { |
| 45 | background-color: green; |
| 46 | } |
| 47 | </style> |
| 48 | </head> |
| 49 | <body> |
| 50 | |
| 51 | <h1>Language coverage of fonts</h1> |
| 52 | |
| 53 | <p>This page lists fonts included with Rockbox and tries to visualise their |
| 54 | coverage of the included translations. The darker the square, the better |
| 55 | coverage. A <span style="color: green">green</span> square indicates full |
| 56 | coverage.</p> |
| 57 | |
| 58 | <table> |
| 59 | <thead> |
| 60 | <tr> |
| 61 | <td></td> |
| 62 | <?php |
| 63 | |
| 64 | function getverticalimg($text) { |
| 65 | $filename = sprintf('headers/%s.png', str_replace("/", "_", $text)); |
| 66 | if (!file_exists($filename) || filemtime(__FILE__) > filemtime($filename)) { |
| 67 | $height = 200; |
| 68 | $width = 11; |
| 69 | $im = imagecreate($width, $height); |
| 70 | $bg = imagecolorallocate($im, 0x9A, 0xBD, 0xDE); |
| 71 | $fg = imagecolorallocate($im, 0, 0, 0); |
| 72 | imagestringup($im, 2, -1, $height - 2, $text, $fg); |
| 73 | imagecolortransparent($im, $bg); |
| 74 | imagepng($im, $filename); |
| 75 | } |
| 76 | return sprintf("<img src='%s' />", $filename); |
| 77 | } |
| 78 | |
Solomon Peachy | 817a336 | 2020-07-27 13:27:53 -0400 | [diff] [blame] | 79 | $fontstats = parse_ini_file('scratch/fontcoverage.ini', true); |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 80 | $langs = languageinfo(); |
| 81 | |
| 82 | /* Output the first row - font names */ |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 83 | if (isset($fontstats['english'])) { |
| 84 | foreach($fontstats['english'] as $font => $coverage) { |
| 85 | printf(" <td>%s</td>\n", getverticalimg($font)); |
| 86 | } |
| 87 | print(" </tr>\n </thead>\n <tbody>\n"); |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 88 | } |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 89 | |
| 90 | foreach($fontstats as $lang => $stats) { |
| 91 | printf(" <tr>\n <td class='lang'><img src='flags/%d/%s.png' /> %s</td>\n",SMALL_FLAGSIZE, urlencode($langs[$lang]['flag']), $langs[$lang]['name']); |
| 92 | foreach($stats as $font => $coverage) { |
| 93 | if ($coverage == 1) { |
| 94 | printf(" <td class='full' title='%s has full coverage of %s'> </td>\n", $font, $lang); |
| 95 | } |
| 96 | else { |
| 97 | $r = 0x9A * (1-$coverage); |
| 98 | $g = 0xBD * (1-$coverage); |
| 99 | $b = 0xDE * (1-$coverage); |
| 100 | printf(" <td style='background-color: #%02X%02X%02X' title='%s has %0.2f%% coverage of %s'> </td>", $r, $g, $b, $font, $coverage*100, $lang); |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 101 | } |
Jonas Häggqvist | 45f3dfb | 2011-04-18 21:32:14 +0000 | [diff] [blame] | 102 | } |
| 103 | print(" </tr>\n"); |
| 104 | } |
| 105 | ?> |
| 106 | </tbody> |
| 107 | </table> |
| 108 | </body> |
| 109 | </html> |