Refactor font repo compiler so it can be reused
Includes changes to the generated repository file because the script had not been run for last update. Change-Id: I6b5d1ce980c6e5b42e36c0044729536b6b0ae4dc
This commit is contained in:
1 parent
4c5263e3f0
commit
651f8bc1c3
5 files changed
+198
-119
No files matched your search
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
||||
exit( "compile.php should be run from the command line\n" );
|
||||
}
|
||||
|
||||
if ( !is_dir( '../fonts/' ) ) {
|
||||
exit( "compile.php should be run from the data/fontrepo/scripts directory\n" );
|
||||
}
|
||||
|
||||
$list = array();
|
||||
$list['base'] = '../data/fontrepo/fonts/';
|
||||
|
||||
foreach ( glob( '../fonts/*/font.ini' ) as $inifile ) {
|
||||
$conf = parse_ini_file( $inifile, true );
|
||||
$languages = array();
|
||||
$version = null;
|
||||
|
||||
$dir = dirname( $inifile );
|
||||
|
||||
foreach ( $conf as $fontname => $font ) {
|
||||
if ( isset( $font['languages'] ) ) {
|
||||
$languages = explode( ',', $font['languages'] );
|
||||
foreach ( $languages as $rcode ) {
|
||||
$rcode = trim( $rcode );
|
||||
$code = str_replace( '*', '', $rcode );
|
||||
|
||||
if ( !isset( $list['languages'][$code] ) ) {
|
||||
$list['languages'][$code] = array( 'system' );
|
||||
}
|
||||
|
||||
if ( strpos( $rcode, '*' ) !== false ) {
|
||||
unset( $list['languages'][$code][0] );
|
||||
array_unshift( $list['languages'][$code], $fontname );
|
||||
} else {
|
||||
$list['languages'][$code][] = $fontname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $font['version'] ) ) {
|
||||
$version = $font['version'];
|
||||
}
|
||||
|
||||
$list['fonts'][$fontname] = array(
|
||||
'version' => $version,
|
||||
);
|
||||
|
||||
if ( isset( $font['fontweight'] ) ) {
|
||||
$list['fonts'][$fontname]['fontweight'] = $font['fontweight'];
|
||||
}
|
||||
|
||||
if ( isset( $font['fontstyle'] ) ) {
|
||||
$list['fonts'][$fontname]['fontstyle'] = $font['fontstyle'];
|
||||
}
|
||||
|
||||
if ( isset( $font['ttf'] ) ) {
|
||||
$list['fonts'][$fontname]['ttf'] = basename( $dir ) . '/' . $font['ttf'];
|
||||
}
|
||||
|
||||
if ( isset( $font['svg'] ) ) {
|
||||
$list['fonts'][$fontname]['svg'] = basename( $dir ) . '/' . $font['svg'];
|
||||
}
|
||||
|
||||
if ( isset( $font['eot'] ) ) {
|
||||
$list['fonts'][$fontname]['eot'] = basename( $dir ) . '/' . $font['eot'];
|
||||
}
|
||||
|
||||
if ( isset( $font['woff'] ) ) {
|
||||
$list['fonts'][$fontname]['woff'] = basename( $dir ) . '/' . $font['woff'];
|
||||
}
|
||||
|
||||
if ( isset( $font['woff2'] ) ) {
|
||||
$list['fonts'][$fontname]['woff2'] = basename( $dir ) . '/' . $font['woff2'];
|
||||
}
|
||||
|
||||
// If font formats are not explicitly defined, scan the directory.
|
||||
if ( !isset( $list['fonts'][$fontname]['ttf'] ) ) {
|
||||
foreach ( glob( "$dir/*.{eot,ttf,woff,woff2,svg}", GLOB_BRACE ) as $fontfile ) {
|
||||
$type = substr( $fontfile, strrpos( $fontfile, '.' ) + 1 );
|
||||
$list['fonts'][$fontname][$type] = str_replace( dirname( $dir ) . '/', '', $fontfile );
|
||||
}
|
||||
}
|
||||
|
||||
// Font variants
|
||||
if ( isset( $font['bold'] ) ) {
|
||||
$list['fonts'][$fontname]['variants']['bold'] = $font['bold'];
|
||||
}
|
||||
|
||||
if ( isset( $font['bolditalic'] ) ) {
|
||||
$list['fonts'][$fontname]['variants']['bolditalic'] = $font['bolditalic'];
|
||||
}
|
||||
|
||||
if ( isset( $font['italic'] ) ) {
|
||||
$list['fonts'][$fontname]['variants']['italic'] = $font['italic'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $list['languages'] );
|
||||
ksort( $list['fonts'] );
|
||||
|
||||
$json = json_encode( $list );
|
||||
$js = <<<JAVASCRIPT
|
||||
// Do not edit! This file is generated from data/fontrepo by data/fontrepo/scripts/compile.php
|
||||
( function ( $ ) {
|
||||
$.webfonts = $.webfonts || {};
|
||||
$.webfonts.repository = $json;
|
||||
}( jQuery ) );
|
||||
|
||||
JAVASCRIPT;
|
||||
file_put_contents( '../../../resources/js/ext.uls.webfonts.repository.js', $js );
|
||||
|
||||
echo "Done.\n";
|
||||
+5
-4
@@ -38,13 +38,14 @@
|
||||
]
|
||||
},
|
||||
"AutoloadClasses": {
|
||||
"UniversalLanguageSelectorHooks": "UniversalLanguageSelector.hooks.php",
|
||||
"ResourceLoaderULSModule": "includes/ResourceLoaderULSModule.php",
|
||||
"ResourceLoaderULSJsonMessageModule": "includes/ResourceLoaderULSJsonMessageModule.php",
|
||||
"ApiLanguageSearch": "api/ApiLanguageSearch.php",
|
||||
"ApiULSLocalization": "api/ApiULSLocalization.php",
|
||||
"FontRepoCompiler": "includes/FontRepoCompiler.php",
|
||||
"LanguageNameSearch": "data/LanguageNameSearch.php",
|
||||
"ResourceLoaderULSJsonMessageModule": "includes/ResourceLoaderULSJsonMessageModule.php",
|
||||
"ResourceLoaderULSModule": "includes/ResourceLoaderULSModule.php",
|
||||
"ULSJsonMessageLoader": "includes/ULSJsonMessageLoader.php",
|
||||
"LanguageNameSearch": "data/LanguageNameSearch.php"
|
||||
"UniversalLanguageSelectorHooks": "UniversalLanguageSelector.hooks.php"
|
||||
},
|
||||
"DefaultUserOptions": {
|
||||
"uls-preferences": ""
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This class parses font specification ini files to a central list.
|
||||
* @author Niklas Laxström
|
||||
* @since 2016.04
|
||||
*/
|
||||
class FontRepoCompiler {
|
||||
protected $fsPath;
|
||||
protected $webPath;
|
||||
|
||||
public function __construct( $fsPath, $webPath ) {
|
||||
$this->fsPath = $fsPath;
|
||||
$this->webPath = $webPath;
|
||||
}
|
||||
|
||||
public function getRepository() {
|
||||
$files = $this->getFilesFromPath( $this->fsPath );
|
||||
|
||||
$fonts = array();
|
||||
$languages = array();
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
$conf = $this->parseFile( $file );
|
||||
$fontPath = dirname( $file );
|
||||
|
||||
// Ugly hack to populate version to all fonts in a set
|
||||
$version = null;
|
||||
foreach ( $conf as $fontname => $font ) {
|
||||
$fontLanguages = $this->getLanguages( $font );
|
||||
$this->appendLanguages( $languages, $fontLanguages, $fontname );
|
||||
$fonts[$fontname] = $this->getFontInfo( $font, $fontPath, $version );
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $languages );
|
||||
ksort( $fonts );
|
||||
|
||||
return array(
|
||||
'base' => $this->webPath,
|
||||
'languages' => $languages,
|
||||
'fonts' => $fonts
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getFilesFromPath( $fspath ) {
|
||||
return glob( "$fspath/*/font.ini" );
|
||||
}
|
||||
|
||||
public function parseFile( $filepath ) {
|
||||
return parse_ini_file( $filepath, true );
|
||||
}
|
||||
|
||||
public function getLanguages( array $font ) {
|
||||
if ( !isset( $font['languages'] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$languages = explode( ',', $font['languages'] );
|
||||
$languages = array_map( 'trim', $languages );
|
||||
|
||||
return $languages;
|
||||
}
|
||||
|
||||
public function appendLanguages( &$languages, $fontLanguages, $fontname ) {
|
||||
foreach ( $fontLanguages as $rcode ) {
|
||||
$code = str_replace( '*', '', $rcode );
|
||||
|
||||
if ( !isset( $languages[$code] ) ) {
|
||||
$languages[$code] = array( 'system' );
|
||||
}
|
||||
|
||||
if ( strpos( $rcode, '*' ) !== false ) {
|
||||
if ( $languages[$code][0] === 'system' ) {
|
||||
unset( $languages[$code][0] );
|
||||
}
|
||||
array_unshift( $languages[$code], $fontname );
|
||||
} else {
|
||||
$languages[$code][] = $fontname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getFontInfo( $font, $fontpath, &$version ) {
|
||||
$info = array();
|
||||
$fontdir = basename( $fontpath );
|
||||
|
||||
$version = $info['version'] = isset( $font['version'] ) ? $font['version'] : $version;
|
||||
|
||||
if ( isset( $font['fontweight'] ) ) {
|
||||
$info['fontweight'] = $font['fontweight'];
|
||||
}
|
||||
|
||||
if ( isset( $font['fontstyle'] ) ) {
|
||||
$info['fontstyle'] = $font['fontstyle'];
|
||||
}
|
||||
|
||||
if ( isset( $font['ttf'] ) ) {
|
||||
$info['ttf'] = $fontdir . '/' . $font['ttf'];
|
||||
}
|
||||
|
||||
if ( isset( $font['svg'] ) ) {
|
||||
$info['svg'] = $fontdir . '/' . $font['svg'];
|
||||
}
|
||||
|
||||
if ( isset( $font['eot'] ) ) {
|
||||
$info['eot'] = $fontdir . '/' . $font['eot'];
|
||||
}
|
||||
|
||||
if ( isset( $font['woff'] ) ) {
|
||||
$info['woff'] = $fontdir . '/' . $font['woff'];
|
||||
}
|
||||
|
||||
if ( isset( $font['woff2'] ) ) {
|
||||
$info['woff2'] = $fontdir . '/' . $font['woff2'];
|
||||
}
|
||||
|
||||
// If font formats are not explicitly defined, scan the directory.
|
||||
if ( !isset( $info['ttf'] ) ) {
|
||||
foreach ( glob( "$fontpath/*.{eot,ttf,woff,woff2,svg}", GLOB_BRACE ) as $fontfile ) {
|
||||
$type = substr( $fontfile, strrpos( $fontfile, '.' ) + 1 );
|
||||
$info[$type] = $fontdir . '/' . basename( $fontfile );
|
||||
}
|
||||
}
|
||||
|
||||
// Font variants
|
||||
if ( isset( $font['bold'] ) ) {
|
||||
$info['variants']['bold'] = $font['bold'];
|
||||
}
|
||||
|
||||
if ( isset( $font['bolditalic'] ) ) {
|
||||
$info['variants']['bolditalic'] = $font['bolditalic'];
|
||||
}
|
||||
|
||||
if ( isset( $font['italic'] ) ) {
|
||||
$info['variants']['italic'] = $font['italic'];
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Do not edit! This file is generated from data/fontrepo by data/fontrepo/scripts/compile.php
|
||||
( function ( $ ) {
|
||||
$.webfonts = $.webfonts || {};
|
||||
$.webfonts.repository = {"base":"..\/data\/fontrepo\/fonts\/","languages":{"adx":["Jomolhari"],"af":["system","OpenDyslexic"],"ahr":["Lohit Marathi"],"akk":["Akkadian"],"am":["AbyssinicaSIL"],"ang":["system","Junicode"],"ar":["system","Amiri"],"arb":["system","Amiri"],"arc":["Estrangelo Edessa","East Syriac Adiabene","SertoUrhoy"],"as":["system","Lohit Assamese"],"bbc":["system","Pangururan"],"bh":["Lohit Devanagari"],"bho":["Lohit Devanagari"],"bk":["system","OpenDyslexic"],"bn":["Siyam Rupali","Lohit Bengali"],"bo":["Jomolhari"],"bod":["Jomolhari"],"bpy":["Siyam Rupali","Lohit Bengali"],"btk":["system","Pangururan"],"bug":["Saweri"],"ca":["system","OpenDyslexic"],"cdo":["system","CharisSIL"],"ckb":["system","Lateef","Scheherazade","Amiri"],"cr":["OskiEast"],"cy":["system","ComicNeue","OpenDyslexic"],"da":["system","OpenDyslexic"],"de":["system","OpenDyslexic"],"dre":["Jomolhari"],"dv":["FreeFont-Thaana"],"dz":["Jomolhari"],"en":["system","ComicNeue","OpenDyslexic"],"es":["system","OpenDyslexic"],"et":["system","OpenDyslexic"],"fa":["system","Iranian Sans","Iranian Serif","Lateef","Nazli","Scheherazade"],"fi":["system","OpenDyslexic"],"fo":["system","OpenDyslexic"],"fr":["system","OpenDyslexic"],"fy":["system","OpenDyslexic"],"ga":["system","OpenDyslexic"],"gd":["system","OpenDyslexic"],"gez":["AbyssinicaSIL"],"gl":["system","OpenDyslexic"],"goe":["Jomolhari"],"gom":["Lohit Devanagari"],"got":["system","Skeirs II"],"grc":["system","GentiumPlus"],"gu":["Lohit Gujarati"],"hbo":["Taamey Frank CLM","Alef"],"he":["system","Alef","Miriam CLM","Taamey Frank CLM"],"hi":["Lohit Devanagari"],"hu":["system","OpenDyslexic"],"hut":["Jomolhari"],"id":["system","ComicNeue","OpenDyslexic"],"ii":["Nuosu SIL"],"is":["system","OpenDyslexic"],"it":["system","OpenDyslexic"],"iu":["system","OskiEast"],"jv":["system","Tuladha Jejeg"],"jv-java":["Tuladha Jejeg"],"kbg":["Jomolhari"],"khg":["Jomolhari"],"km":["KhmerOSbattambang","Hanuman","KhmerOS","Nokora Regular","Suwannaphum"],"kn":["Lohit Kannada","Gubbi"],"kok":["Lohit Devanagari"],"kte":["Jomolhari"],"lb":["system","OpenDyslexic"],"lbj":["Jomolhari"],"lhm":["Jomolhari"],"li":["system","OpenDyslexic"],"lo":["Phetsarath"],"loy":["Jomolhari"],"luk":["Jomolhari"],"lya":["Jomolhari"],"mai":["Lohit Devanagari"],"mak":["Saweri"],"mi":["system","OpenDyslexic"],"ml":["system","AnjaliOldLipi","Meera"],"mr":["Lohit Marathi"],"ms":["system","ComicNeue","OpenDyslexic"],"muk":["Jomolhari"],"mul":["system","Autonym"],"my":["TharLon","Myanmar3","Padauk"],"nan":["system","CharisSIL","Doulos SIL"],"nb":["system","OpenDyslexic"],"ne":["Lohit Nepali","Madan"],"nl":["system","ComicNeue","OpenDyslexic"],"oc":["system","OpenDyslexic"],"ola":["Jomolhari"],"or":["Lohit Odia","Utkal"],"otb":["Jomolhari"],"pa":["Lohit Punjabi","Saab"],"pal":["Shapour"],"peo":["Artaxerxes"],"pl":["system","OpenDyslexic"],"pt":["system","OpenDyslexic"],"sa":["Lohit Devanagari"],"saz":["Pagul"],"si":["system","lklug"],"sq":["system","OpenDyslexic"],"sux":["Akkadian"],"sv":["system","OpenDyslexic"],"sw":["system","ComicNeue","OpenDyslexic"],"syc":["Estrangelo Edessa","East Syriac Adiabene","SertoUrhoy"],"ta":["system","Lohit Tamil","Lohit Tamil Classical","Thendral","Thenee"],"tcn":["Jomolhari"],"tcy":["Lohit Kannada","Gubbi"],"te":["Lohit Telugu"],"thw":["Jomolhari"],"ti":["AbyssinicaSIL"],"tig":["AbyssinicaSIL"],"tl":["system","ComicNeue","OpenDyslexic"],"tr":["system","OpenDyslexic"],"tsk":["Jomolhari"],"ur":["system","Hussaini Nastaleeq","NafeesWeb"],"wa":["system","OpenDyslexic"],"xct":["Jomolhari"],"yi":["system","Alef"],"zau":["Jomolhari"]},"fonts":{"AbyssinicaSIL":{"version":"1.500","eot":"AbyssinicaSIL\/AbyssinicaSIL-R.eot","ttf":"AbyssinicaSIL\/AbyssinicaSIL-R.ttf","woff":"AbyssinicaSIL\/AbyssinicaSIL-R.woff"},"Akkadian":{"version":"2.56","eot":"Akkadian\/Akkadian.eot","ttf":"Akkadian\/Akkadian.ttf","woff":"Akkadian\/Akkadian.woff"},"Alef":{"version":"1.0","ttf":"Alef\/Alef-Regular.ttf","eot":"Alef\/Alef-Regular.eot","woff":"Alef\/Alef-Regular.woff","variants":{"bold":"Alef Bold"}},"Alef Bold":{"version":"1.0","fontweight":"bold","ttf":"Alef\/Alef-Bold.ttf","eot":"Alef\/Alef-Bold.eot","woff":"Alef\/Alef-Bold.woff"},"Amiri":{"version":"1.0.2","ttf":"amiri\/amiri-regular.ttf","eot":"amiri\/amiri-regular.eot","woff":"amiri\/amiri-regular.woff","variants":{"bold":"Amiri Bold","bolditalic":"Amiri Bold Italic","italic":"Amiri Italic"}},"Amiri Bold":{"version":"1.0.2","fontweight":"bold","ttf":"amiri\/amiri-bold.ttf","eot":"amiri\/amiri-bold.eot","woff":"amiri\/amiri-bold.woff"},"Amiri Bold Italic":{"version":"1.0.2","fontweight":"bold","fontstyle":"italic","ttf":"amiri\/amiri-boldslanted.ttf","eot":"amiri\/amiri-boldslanted.eot","woff":"amiri\/amiri-boldslanted.woff"},"Amiri Italic":{"version":"1.0.2","fontstyle":"italic","ttf":"amiri\/amiri-slanted.ttf","eot":"amiri\/amiri-slanted.eot","woff":"amiri\/amiri-slanted.woff"},"AnjaliOldLipi":{"version":".0.730","eot":"AnjaliOldLipi\/AnjaliOldLipi.eot","ttf":"AnjaliOldLipLine truncated
|
||||
$.webfonts.repository = {"base":"..\/data\/fontrepo\/fonts\/","languages":{"adx":["Jomolhari"],"af":["system","OpenDyslexic"],"ahr":["Lohit Marathi"],"akk":["Akkadian"],"am":["AbyssinicaSIL"],"ang":["system","Junicode"],"ar":["system","Amiri"],"arb":["system","Amiri"],"arc":["Estrangelo Edessa","East Syriac Adiabene","SertoUrhoy"],"as":["system","Lohit Assamese"],"bbc":["system","Pangururan"],"bh":["Lohit Devanagari"],"bho":["Lohit Devanagari"],"bk":["system","OpenDyslexic"],"bn":["Siyam Rupali","Lohit Bengali"],"bo":["Jomolhari"],"bod":["Jomolhari"],"bpy":["Siyam Rupali","Lohit Bengali"],"btk":["system","Pangururan"],"bug":["Saweri"],"ca":["system","OpenDyslexic"],"cdo":["system","CharisSIL"],"ckb":["system","Lateef","Scheherazade","Amiri"],"cr":["OskiEast"],"cy":["system","ComicNeue","OpenDyslexic"],"da":["system","OpenDyslexic"],"de":["system","OpenDyslexic"],"dre":["Jomolhari"],"dv":["FreeFont-Thaana"],"dz":["Jomolhari"],"en":["system","ComicNeue","OpenDyslexic"],"es":["system","OpenDyslexic"],"et":["system","OpenDyslexic"],"fa":["system","Iranian Sans","Iranian Serif","Lateef","Nazli","Scheherazade"],"fi":["system","OpenDyslexic"],"fo":["system","OpenDyslexic"],"fr":["system","OpenDyslexic"],"fy":["system","OpenDyslexic"],"ga":["system","OpenDyslexic"],"gd":["system","OpenDyslexic"],"gez":["AbyssinicaSIL"],"gl":["system","OpenDyslexic"],"goe":["Jomolhari"],"gom":["Lohit Devanagari"],"got":["system","Skeirs II"],"grc":["system","GentiumPlus"],"gu":["Lohit Gujarati"],"hbo":["Taamey Frank CLM","Alef"],"he":["system","Alef","Miriam CLM","Taamey Frank CLM"],"hi":["Lohit Devanagari"],"hu":["system","OpenDyslexic"],"hut":["Jomolhari"],"id":["system","ComicNeue","OpenDyslexic"],"ii":["Nuosu SIL"],"is":["system","OpenDyslexic"],"it":["system","OpenDyslexic"],"iu":["system","OskiEast"],"jv":["system","Tuladha Jejeg"],"jv-java":["Tuladha Jejeg"],"kbg":["Jomolhari"],"khg":["Jomolhari"],"km":["KhmerOSbattambang","Hanuman","KhmerOS","Nokora Regular","Suwannaphum"],"kn":["Lohit Kannada","Gubbi"],"kok":["Lohit Devanagari"],"kte":["Jomolhari"],"lb":["system","OpenDyslexic"],"lbj":["Jomolhari"],"lhm":["Jomolhari"],"li":["system","OpenDyslexic"],"lo":["Phetsarath"],"loy":["Jomolhari"],"luk":["Jomolhari"],"lya":["Jomolhari"],"mai":["Lohit Devanagari"],"mak":["Saweri"],"mi":["system","OpenDyslexic"],"ml":["system","AnjaliOldLipi","Meera"],"mr":["Lohit Marathi"],"ms":["system","ComicNeue","OpenDyslexic"],"muk":["Jomolhari"],"mul":["system","Autonym"],"my":["TharLon","Myanmar3","Padauk"],"nan":["system","CharisSIL","Doulos SIL"],"nb":["system","OpenDyslexic"],"ne":["Lohit Nepali","Madan"],"nl":["system","ComicNeue","OpenDyslexic"],"oc":["system","OpenDyslexic"],"ola":["Jomolhari"],"or":["Lohit Odia","Utkal"],"otb":["Jomolhari"],"pa":["Lohit Punjabi","Saab"],"pal":["Shapour"],"peo":["Artaxerxes"],"pl":["system","OpenDyslexic"],"pt":["system","OpenDyslexic"],"sa":["Lohit Devanagari"],"saz":["Pagul"],"si":["system","lklug"],"sq":["system","OpenDyslexic"],"sux":["Akkadian"],"sv":["system","OpenDyslexic"],"sw":["system","ComicNeue","OpenDyslexic"],"syc":["Estrangelo Edessa","East Syriac Adiabene","SertoUrhoy"],"ta":["system","Lohit Tamil","Lohit Tamil Classical","Thendral","Thenee"],"tcn":["Jomolhari"],"tcy":["Lohit Kannada","Gubbi"],"te":["Lohit Telugu"],"thw":["Jomolhari"],"ti":["AbyssinicaSIL"],"tig":["AbyssinicaSIL"],"tl":["system","ComicNeue","OpenDyslexic"],"tr":["system","OpenDyslexic"],"tsk":["Jomolhari"],"ur":["system","Hussaini Nastaleeq","NafeesWeb"],"wa":["system","OpenDyslexic"],"xct":["Jomolhari"],"yi":["system","Alef"],"zau":["Jomolhari"]},"fonts":{"AbyssinicaSIL":{"version":"1.500","eot":"AbyssinicaSIL\/AbyssinicaSIL-R.eot","ttf":"AbyssinicaSIL\/AbyssinicaSIL-R.ttf","woff":"AbyssinicaSIL\/AbyssinicaSIL-R.woff"},"Akkadian":{"version":"2.56","eot":"Akkadian\/Akkadian.eot","ttf":"Akkadian\/Akkadian.ttf","woff":"Akkadian\/Akkadian.woff"},"Alef":{"version":"1.0","ttf":"Alef\/Alef-Regular.ttf","eot":"Alef\/Alef-Regular.eot","woff":"Alef\/Alef-Regular.woff","variants":{"bold":"Alef Bold"}},"Alef Bold":{"version":"1.0","fontweight":"bold","ttf":"Alef\/Alef-Bold.ttf","eot":"Alef\/Alef-Bold.eot","woff":"Alef\/Alef-Bold.woff"},"Amiri":{"version":"0.107","ttf":"amiri\/amiri-regular.ttf","eot":"amiri\/amiri-regular.eot","woff":"amiri\/amiri-regular.woff","variants":{"bold":"Amiri Bold","bolditalic":"Amiri Bold Italic","italic":"Amiri Italic"}},"Amiri Bold":{"version":"0.107","fontweight":"bold","ttf":"amiri\/amiri-bold.ttf","eot":"amiri\/amiri-bold.eot","woff":"amiri\/amiri-bold.woff"},"Amiri Bold Italic":{"version":"0.107","fontweight":"bold","fontstyle":"italic","ttf":"amiri\/amiri-boldslanted.ttf","eot":"amiri\/amiri-boldslanted.eot","woff":"amiri\/amiri-boldslanted.woff"},"Amiri Italic":{"version":"0.107","fontstyle":"italic","ttf":"amiri\/amiri-slanted.ttf","eot":"amiri\/amiri-slanted.eot","woff":"amiri\/amiri-slanted.woff"},"AnjaliOldLipi":{"version":".0.730","eot":"AnjaliOldLipi\/AnjaliOldLipi.eot","ttf":"AnjaliOldLipLine truncated
|
||||
}( jQuery ) );
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @author Niklas Laxström
|
||||
* @license GPL-2.0+
|
||||
* @file
|
||||
*/
|
||||
|
||||
// Standard boilerplate to define $IP
|
||||
if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
|
||||
$IP = getenv( 'MW_INSTALL_PATH' );
|
||||
} else {
|
||||
$dir = __DIR__;
|
||||
$IP = "$dir/../../..";
|
||||
}
|
||||
require_once "$IP/maintenance/Maintenance.php";
|
||||
|
||||
class CompileFontRepo extends Maintenance {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->mDescription = 'Creates JavaScript font repository.';
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$base = dirname( __DIR__ );
|
||||
|
||||
$compiler = new FontRepoCompiler(
|
||||
"$base/data/fontrepo/fonts",
|
||||
'../data/fontrepo/fonts/'
|
||||
);
|
||||
|
||||
$list = $compiler->getRepository();
|
||||
|
||||
$json = json_encode( $list );
|
||||
$js = <<<JAVASCRIPT
|
||||
// Do not edit! This file is generated from data/fontrepo by data/fontrepo/scripts/compile.php
|
||||
( function ( $ ) {
|
||||
$.webfonts = $.webfonts || {};
|
||||
$.webfonts.repository = $json;
|
||||
}( jQuery ) );
|
||||
|
||||
JAVASCRIPT;
|
||||
file_put_contents( "$base/resources/js/ext.uls.webfonts.repository.js", $js );
|
||||
|
||||
$this->output( "Done.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = 'CompileFontRepo';
|
||||
require_once DO_MAINTENANCE;
|
||||
Reference in new issue
Block a user