Remove autonym font and its usage
I no longer maintain the Autonym font. Also remove the tofu detection. Bug: T135464 Bug: T135465 Change-Id: I103aab40ea5f5fc403a7ee5b23d1b634cc9c6ee1
This commit is contained in:
committed by
Nikerabbit
parent
679e58758b
commit
4f3461a9aa
@@ -188,7 +188,7 @@ class UniversalLanguageSelectorHooks {
|
|||||||
'uls' => [
|
'uls' => [
|
||||||
'text' => Language::fetchLanguageName( $langCode ),
|
'text' => Language::fetchLanguageName( $langCode ),
|
||||||
'href' => '#',
|
'href' => '#',
|
||||||
'class' => 'uls-trigger autonym',
|
'class' => 'uls-trigger',
|
||||||
'active' => true
|
'active' => true
|
||||||
]
|
]
|
||||||
] + $personal_urls;
|
] + $personal_urls;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
[Autonym]
|
|
||||||
languages=mul
|
|
||||||
version=20131205
|
|
||||||
license=OFL-1.1
|
|
||||||
licensefile=OFL.txt
|
|
||||||
url=https://github.com/santhoshtr/AutonymFont/
|
|
||||||
@@ -257,7 +257,6 @@
|
|||||||
"ext.uls.webfonts.fonts": {
|
"ext.uls.webfonts.fonts": {
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"jquery.webfonts",
|
"jquery.webfonts",
|
||||||
"jquery.uls.data",
|
|
||||||
"ext.uls.webfonts.repository"
|
"ext.uls.webfonts.repository"
|
||||||
],
|
],
|
||||||
"localBasePath": "resources",
|
"localBasePath": "resources",
|
||||||
|
|||||||
@@ -20,11 +20,7 @@
|
|||||||
( function ( $, mw ) {
|
( function ( $, mw ) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ulsPreferences,
|
var ulsPreferences;
|
||||||
// Text to prepend the sample text. 0D00 is an unassigned unicode point.
|
|
||||||
tofuSalt = '\u0D00',
|
|
||||||
// cache languages with tofu.
|
|
||||||
tofuLanguages = {};
|
|
||||||
|
|
||||||
mw.webfonts = mw.webfonts || {};
|
mw.webfonts = mw.webfonts || {};
|
||||||
ulsPreferences = mw.uls.preferences();
|
ulsPreferences = mw.uls.preferences();
|
||||||
@@ -67,62 +63,6 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect tofu
|
|
||||||
*
|
|
||||||
* Create a temporary span in the page with fontsize 72px and font-family
|
|
||||||
* sans-serif for each letter of the text.
|
|
||||||
* For each of these spans, calculate the width and height. If they are same
|
|
||||||
* for all spans, we can understand that each of the letter is rendered using
|
|
||||||
* same glyph - it must be a tofu.
|
|
||||||
*
|
|
||||||
* @param {string} text
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
function detectTofu( text ) {
|
|
||||||
var index,
|
|
||||||
$fixture,
|
|
||||||
width = {},
|
|
||||||
height = {},
|
|
||||||
length = Math.min( 4, text.length ),
|
|
||||||
detected = false;
|
|
||||||
|
|
||||||
if ( $.client.test( {
|
|
||||||
msie: false
|
|
||||||
} ) ) {
|
|
||||||
// IE shows a different tofu for unassigned code points!
|
|
||||||
text = tofuSalt + text;
|
|
||||||
}
|
|
||||||
$fixture = $( '<span>' )
|
|
||||||
.css( {
|
|
||||||
fontSize: '72px',
|
|
||||||
fontFamily: 'sans-serif'
|
|
||||||
} )
|
|
||||||
.appendTo( 'body' );
|
|
||||||
|
|
||||||
for ( index = 0; index < length; index++ ) {
|
|
||||||
$fixture.text( text[ index ] );
|
|
||||||
width[ index ] = $fixture.width() || width[ index - 1 ];
|
|
||||||
height[ index ] = $fixture.height();
|
|
||||||
|
|
||||||
if ( index > 0 &&
|
|
||||||
( width[ index ] !== width[ index - 1 ] ||
|
|
||||||
height[ index ] !== height[ index - 1 ] )
|
|
||||||
) {
|
|
||||||
detected = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$fixture.remove();
|
|
||||||
|
|
||||||
if ( index === length ) {
|
|
||||||
detected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return detected;
|
|
||||||
}
|
|
||||||
|
|
||||||
mw.webfonts.setup = function () {
|
mw.webfonts.setup = function () {
|
||||||
// Initialize webfonts
|
// Initialize webfonts
|
||||||
var mediawikiFontRepository = $.webfonts.repository;
|
var mediawikiFontRepository = $.webfonts.repository;
|
||||||
@@ -143,7 +83,7 @@
|
|||||||
* @return {string|null}
|
* @return {string|null}
|
||||||
*/
|
*/
|
||||||
fontSelector: function ( repository, language, classes ) {
|
fontSelector: function ( repository, language, classes ) {
|
||||||
var font, autonym, defaultFont;
|
var font, defaultFont;
|
||||||
|
|
||||||
if ( !language ) {
|
if ( !language ) {
|
||||||
return null;
|
return null;
|
||||||
@@ -152,40 +92,15 @@
|
|||||||
defaultFont = repository.defaultFont( language );
|
defaultFont = repository.defaultFont( language );
|
||||||
|
|
||||||
if ( classes && $.inArray( 'autonym', classes ) >= 0 ) {
|
if ( classes && $.inArray( 'autonym', classes ) >= 0 ) {
|
||||||
autonym = true;
|
// Do not load font for showing autonym.
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user has a font preference, apply it always.
|
// If the user has a font preference, apply it always.
|
||||||
font = mw.webfonts.preferences.getFont( language );
|
font = mw.webfonts.preferences.getFont( language ) || defaultFont;
|
||||||
if ( !font || autonym ) {
|
if ( !font || font === 'system' ) {
|
||||||
// Is there any default font for this language?
|
|
||||||
if ( ( !defaultFont || defaultFont === 'system' ) && !autonym ) {
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is a default font for this language,
|
|
||||||
// but check whether the user sees tofu for it.
|
|
||||||
if ( tofuLanguages[ language ] === undefined ) {
|
|
||||||
tofuLanguages[ language ] = detectTofu( $.uls.data.getAutonym( language ) );
|
|
||||||
|
|
||||||
// Log the tofu detection only once per page per language
|
|
||||||
if ( tofuLanguages[ language ] ) {
|
|
||||||
mw.log( 'tofu detected for ' + language );
|
|
||||||
mw.hook( 'mw.uls.webfonts.tofudetected' ).fire( language );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( tofuLanguages[ language ] ) {
|
|
||||||
font = autonym ? 'Autonym' : defaultFont;
|
|
||||||
} else {
|
|
||||||
// No tofu and no font preference. Use system font.
|
|
||||||
font = 'system';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( font === 'system' ) {
|
|
||||||
// Avoid setting 'system' as a font in css
|
// Avoid setting 'system' as a font in css
|
||||||
font = null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
@@ -213,14 +128,6 @@
|
|||||||
// property values set by stylesheets.
|
// property values set by stylesheets.
|
||||||
setTimeout( function () {
|
setTimeout( function () {
|
||||||
$( 'body' ).webfonts();
|
$( 'body' ).webfonts();
|
||||||
|
|
||||||
// Load the CSS required for the Autonym font. Note that this won't download the font.
|
|
||||||
// Browsers are smart enough to delay it till some element with this font-family
|
|
||||||
// becomes visible. For example: If there is a popup div with an element with class
|
|
||||||
// 'autonym', without explicitly calling .webfonts() on it, Autonym font will not
|
|
||||||
// be applied in general. But we ensure that the CSS is ready so that the font
|
|
||||||
// will be applied automatically to such future elements.
|
|
||||||
$( 'body' ).data( 'webfonts' ).load( 'Autonym' );
|
|
||||||
}, 0 );
|
}, 0 );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Do not edit! This file is generated from data/fontrepo by data/fontrepo/scripts/compile.php
|
// Do not edit! This file is generated from data/fontrepo by scripts/compile-font-repo.php
|
||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
$.webfonts = $.webfonts || {};
|
$.webfonts = $.webfonts || {};
|
||||||
$.webfonts.repository = {
|
$.webfonts.repository = {
|
||||||
@@ -306,10 +306,6 @@
|
|||||||
"muk": [
|
"muk": [
|
||||||
"Jomolhari"
|
"Jomolhari"
|
||||||
],
|
],
|
||||||
"mul": [
|
|
||||||
"system",
|
|
||||||
"Autonym"
|
|
||||||
],
|
|
||||||
"my": [
|
"my": [
|
||||||
"TharLon",
|
"TharLon",
|
||||||
"Myanmar3",
|
"Myanmar3",
|
||||||
@@ -522,11 +518,6 @@
|
|||||||
"woff": "Artaxerxes/Artaxerxes.woff?c1ed7",
|
"woff": "Artaxerxes/Artaxerxes.woff?c1ed7",
|
||||||
"woff2": "Artaxerxes/Artaxerxes.woff2?7a96e"
|
"woff2": "Artaxerxes/Artaxerxes.woff2?7a96e"
|
||||||
},
|
},
|
||||||
"Autonym": {
|
|
||||||
"ttf": "Autonym/Autonym.ttf?d41f5",
|
|
||||||
"woff": "Autonym/Autonym.woff?235d8",
|
|
||||||
"woff2": "Autonym/Autonym.woff2?280d0"
|
|
||||||
},
|
|
||||||
"CharisSIL": {
|
"CharisSIL": {
|
||||||
"ttf": "CharisSIL/CharisSIL-R.ttf?20bec",
|
"ttf": "CharisSIL/CharisSIL-R.ttf?20bec",
|
||||||
"woff": "CharisSIL/CharisSIL-R.woff?3a622",
|
"woff": "CharisSIL/CharisSIL-R.woff?3a622",
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>Autonym font Example</title>
|
|
||||||
<meta name="description" content="A test page for the Autonym font" />
|
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
|
|
||||||
<script src="../lib/jquery.uls/src/jquery.uls.data.js"></script>
|
|
||||||
<script src="../lib/jquery.uls/src/jquery.uls.data.utils.js"></script>
|
|
||||||
<style>
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Autonym';
|
|
||||||
src: url('../data/fontrepo/fonts/Autonym/Autonym.eot');
|
|
||||||
src: local('Autonym'),
|
|
||||||
url('../data/fontrepo/fonts/Autonym/Autonym.woff') format('woff'),
|
|
||||||
url('../data/fontrepo/fonts/Autonym/Autonym.ttf') format('truetype');
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
table, th, td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-collapse:collapse;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.lang,
|
|
||||||
td.index {
|
|
||||||
background-color: #ccc;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Autonym Font</h1>
|
|
||||||
<p>The following table in this page uses the <a href="https://github.com/santhoshtr/AutonymFont">Autonym</a>
|
|
||||||
font for displaying language names without font issues.</p>
|
|
||||||
<p>Version: 20131118</p>
|
|
||||||
<hr/>
|
|
||||||
<div>
|
|
||||||
<label for="font-selector">Select a font:</label>
|
|
||||||
<select id="font-selector">
|
|
||||||
<option value="Autonym">Autonym</option>
|
|
||||||
<option value="sans-serif">sans-serif</option>
|
|
||||||
<option value="Autonym, sans-serif">Autonym, sans-serif</option>
|
|
||||||
<option value="sans-serif, Autonym">sans-serif, Autonym</option>
|
|
||||||
<option value="Verdana, Arial, Helvetica, Autonym, sans-serif">Verdana, Arial, Helvetica, Autonym, sans-serif</option>
|
|
||||||
</select>
|
|
||||||
<select id="size-selector">
|
|
||||||
<option value="8">Select size (px)</option>
|
|
||||||
<option value="8">8</option>
|
|
||||||
<option value="9">9</option>
|
|
||||||
<option value="10">10</option>
|
|
||||||
<option value="11">11</option>
|
|
||||||
<option value="12">12</option>
|
|
||||||
<option value="13">13</option>
|
|
||||||
<option value="14">14</option>
|
|
||||||
<option value="16">16</option>
|
|
||||||
<option value="20">20</option>
|
|
||||||
<option value="24">24</option>
|
|
||||||
<option value="30">30</option>
|
|
||||||
<option value="36">36</option>
|
|
||||||
<option value="48">48</option>
|
|
||||||
</select>
|
|
||||||
<table><tr></tr></table>
|
|
||||||
<div>A dropdown example:
|
|
||||||
<select class="dropdown autonym">
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
var index = 1,
|
|
||||||
$fontSelector = $( '#font-selector' ),
|
|
||||||
$sizeSelector = $( '#size-selector' );
|
|
||||||
|
|
||||||
$fontSelector.change( function () {
|
|
||||||
$( '.autonym' ).css( 'font-family', $( this ).val() );
|
|
||||||
});
|
|
||||||
|
|
||||||
$sizeSelector.change( function () {
|
|
||||||
$( '.autonym' ).css( 'font-size', $( this ).val() + 'px' );
|
|
||||||
});
|
|
||||||
|
|
||||||
$.each( $.uls.data.languages, function( langCode ) {
|
|
||||||
var autonym = $.uls.data.getAutonym( langCode ),
|
|
||||||
dir = $.uls.data.getDir( langCode );
|
|
||||||
|
|
||||||
$( '.dropdown' ).append(
|
|
||||||
$( '<option>')
|
|
||||||
.attr( {
|
|
||||||
lang: langCode,
|
|
||||||
dir: dir
|
|
||||||
} )
|
|
||||||
.text( autonym )
|
|
||||||
);
|
|
||||||
|
|
||||||
$( 'table' ).append(
|
|
||||||
$( '<tr>' ).append(
|
|
||||||
$( '<td>' )
|
|
||||||
.addClass( 'index' )
|
|
||||||
.text( index++ ),
|
|
||||||
$( '<td>' )
|
|
||||||
.addClass( 'lang' )
|
|
||||||
.text( langCode ),
|
|
||||||
$( '<td>' )
|
|
||||||
.addClass( 'name autonym' )
|
|
||||||
.attr( {
|
|
||||||
lang: langCode,
|
|
||||||
dir: dir
|
|
||||||
} )
|
|
||||||
.text( autonym )
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} );
|
|
||||||
|
|
||||||
// Apply the initial font
|
|
||||||
$( '.autonym' ).css( 'font-family', $fontSelector.val() );
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
Reference in New Issue
Block a user