blob: 21dd60525eccefd15b564c18d12f7da18d120e48 [file] [log] [blame]
Jonas Häggqvist45f3dfb2011-04-18 21:32:14 +00001<?php
2header("Content-type: text/html; charset=UTF-8");
3require_once('common.php');
4/* Set internal character encoding to UTF-8 */
5mb_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">
14td {
15 margin: 0px;
16 padding: 0px;
17 vertical-align: middle;
18}
19td img {
20 border: 0px solid black;
21}
22td.lang {
23 white-space: nowrap;
24}
25td.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
35coverage of the included translations. The darker the square, the better
36coverage. A <span style="color: green">green</span> square indicates full
37coverage.</p>
38
39<table>
40 <thead>
41 <tr>
42 <td></td>
43<?php
44
45function 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 Gevaertsf6a9d682012-04-04 21:26:38 +020064if (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äggqvist45f3dfb2011-04-18 21:32:14 +000069}
Jonas Häggqvist45f3dfb2011-04-18 21:32:14 +000070
71foreach($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'>&nbsp;</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'>&nbsp;</td>", $r, $g, $b, $font, $coverage*100, $lang);
82 }
83 }
84 print(" </tr>\n");
85}
86?>
87</tbody>
88</table>
89</body>
90</html>