blob: 5e8c6255a5692f1243584e553b0e9767db268d34 [file] [log] [blame]
Jonas Häggqvist45f3dfb2011-04-18 21:32:14 +00001<?php
Solomon Peachya0eef362020-04-02 10:05:23 -04002/************************************************************************
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äggqvist45f3dfb2011-04-18 21:32:14 +000021header("Content-type: text/html; charset=UTF-8");
22require_once('common.php');
23/* Set internal character encoding to UTF-8 */
24mb_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">
33td {
34 margin: 0px;
35 padding: 0px;
36 vertical-align: middle;
37}
38td img {
39 border: 0px solid black;
40}
41td.lang {
42 white-space: nowrap;
43}
44td.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
54coverage of the included translations. The darker the square, the better
55coverage. A <span style="color: green">green</span> square indicates full
56coverage.</p>
57
58<table>
59 <thead>
60 <tr>
61 <td></td>
62<?php
63
64function 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 Peachy817a3362020-07-27 13:27:53 -040079$fontstats = parse_ini_file('scratch/fontcoverage.ini', true);
Jonas Häggqvist45f3dfb2011-04-18 21:32:14 +000080$langs = languageinfo();
81
82/* Output the first row - font names */
Frank Gevaertsf6a9d682012-04-04 21:26:38 +020083if (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äggqvist45f3dfb2011-04-18 21:32:14 +000088}
Jonas Häggqvist45f3dfb2011-04-18 21:32:14 +000089
90foreach($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'>&nbsp;</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'>&nbsp;</td>", $r, $g, $b, $font, $coverage*100, $lang);
Solomon Peachya0eef362020-04-02 10:05:23 -0400101 }
Jonas Häggqvist45f3dfb2011-04-18 21:32:14 +0000102 }
103 print(" </tr>\n");
104}
105?>
106</tbody>
107</table>
108</body>
109</html>