diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index 70135b41..3dc19ad9 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -188,7 +188,7 @@ class UniversalLanguageSelectorHooks { 'uls' => [ 'text' => Language::fetchLanguageName( $langCode ), 'href' => '#', - 'class' => 'uls-trigger autonym', + 'class' => 'uls-trigger', 'active' => true ] ] + $personal_urls; diff --git a/data/fontrepo/fonts/Autonym/Autonym.ttf b/data/fontrepo/fonts/Autonym/Autonym.ttf deleted file mode 100644 index 0565206d..00000000 Binary files a/data/fontrepo/fonts/Autonym/Autonym.ttf and /dev/null differ diff --git a/data/fontrepo/fonts/Autonym/Autonym.woff b/data/fontrepo/fonts/Autonym/Autonym.woff deleted file mode 100644 index 13b55d32..00000000 Binary files a/data/fontrepo/fonts/Autonym/Autonym.woff and /dev/null differ diff --git a/data/fontrepo/fonts/Autonym/Autonym.woff2 b/data/fontrepo/fonts/Autonym/Autonym.woff2 deleted file mode 100644 index 32b38ce5..00000000 Binary files a/data/fontrepo/fonts/Autonym/Autonym.woff2 and /dev/null differ diff --git a/data/fontrepo/fonts/Autonym/font.ini b/data/fontrepo/fonts/Autonym/font.ini deleted file mode 100644 index 14e9ee48..00000000 --- a/data/fontrepo/fonts/Autonym/font.ini +++ /dev/null @@ -1,6 +0,0 @@ -[Autonym] -languages=mul -version=20131205 -license=OFL-1.1 -licensefile=OFL.txt -url=https://github.com/santhoshtr/AutonymFont/ diff --git a/extension.json b/extension.json index d7afde55..4bdae52b 100644 --- a/extension.json +++ b/extension.json @@ -257,7 +257,6 @@ "ext.uls.webfonts.fonts": { "dependencies": [ "jquery.webfonts", - "jquery.uls.data", "ext.uls.webfonts.repository" ], "localBasePath": "resources", diff --git a/resources/js/ext.uls.webfonts.js b/resources/js/ext.uls.webfonts.js index 0bf41b9c..b536ee80 100644 --- a/resources/js/ext.uls.webfonts.js +++ b/resources/js/ext.uls.webfonts.js @@ -20,11 +20,7 @@ ( function ( $, mw ) { 'use strict'; - var ulsPreferences, - // Text to prepend the sample text. 0D00 is an unassigned unicode point. - tofuSalt = '\u0D00', - // cache languages with tofu. - tofuLanguages = {}; + var ulsPreferences; mw.webfonts = mw.webfonts || {}; 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 = $( '' ) - .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 () { // Initialize webfonts var mediawikiFontRepository = $.webfonts.repository; @@ -143,7 +83,7 @@ * @return {string|null} */ fontSelector: function ( repository, language, classes ) { - var font, autonym, defaultFont; + var font, defaultFont; if ( !language ) { return null; @@ -152,40 +92,15 @@ defaultFont = repository.defaultFont( language ); 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. - font = mw.webfonts.preferences.getFont( language ); - if ( !font || autonym ) { - // 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' ) { + font = mw.webfonts.preferences.getFont( language ) || defaultFont; + if ( !font || font === 'system' ) { // Avoid setting 'system' as a font in css - font = null; + return null; } return font; @@ -213,14 +128,6 @@ // property values set by stylesheets. setTimeout( function () { $( '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 ); }; diff --git a/resources/js/ext.uls.webfonts.repository.js b/resources/js/ext.uls.webfonts.repository.js index ea5141c0..b5fb37bd 100644 --- a/resources/js/ext.uls.webfonts.repository.js +++ b/resources/js/ext.uls.webfonts.repository.js @@ -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 ( $ ) { $.webfonts = $.webfonts || {}; $.webfonts.repository = { @@ -306,10 +306,6 @@ "muk": [ "Jomolhari" ], - "mul": [ - "system", - "Autonym" - ], "my": [ "TharLon", "Myanmar3", @@ -522,11 +518,6 @@ "woff": "Artaxerxes/Artaxerxes.woff?c1ed7", "woff2": "Artaxerxes/Artaxerxes.woff2?7a96e" }, - "Autonym": { - "ttf": "Autonym/Autonym.ttf?d41f5", - "woff": "Autonym/Autonym.woff?235d8", - "woff2": "Autonym/Autonym.woff2?280d0" - }, "CharisSIL": { "ttf": "CharisSIL/CharisSIL-R.ttf?20bec", "woff": "CharisSIL/CharisSIL-R.woff?3a622", diff --git a/tests/autonym.html b/tests/autonym.html deleted file mode 100644 index 48626b77..00000000 --- a/tests/autonym.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - -Autonym font Example - - - - - - - -

Autonym Font

-

The following table in this page uses the Autonym - font for displaying language names without font issues.

-

Version: 20131118

-
-
- - - -
-
A dropdown example: - -
- -
-