Mediawiki WebFonts repository for jquery.webfonts
Added license and upstream information and a script to compile repoconfig automatically from metadata. also contains integration code Change-Id: Ib39668249dd568a1f6017f0c08a3b9d1e2067ae4
This commit is contained in:
committed by
Santhosh Thottingal
parent
a870263ad9
commit
3f4b5e4540
44
data/fontrepo/scripts/compile.php
Normal file
44
data/fontrepo/scripts/compile.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
$list = array();
|
||||
$list['base'] = '../data/fontrepo/fonts/';
|
||||
foreach ( glob( '../fonts/*/font.ini' ) as $inifile ) {
|
||||
$conf = parse_ini_file( $inifile, true );
|
||||
foreach ( $conf as $fontname => $font ) {
|
||||
foreach ( explode( ',', $font['languages'] ) as $rcode ) {
|
||||
$rcode = trim( $rcode );
|
||||
$code = str_replace( '*', '', $rcode );
|
||||
if ( !isset( $list['languages'][$code] ) ) {
|
||||
$list['languages'][$code] = array();
|
||||
}
|
||||
if ( strpos( $rcode, '*' ) !== false ) {
|
||||
array_unshift( $list['languages'][$code], $fontname );
|
||||
} else {
|
||||
$list['languages'][$code][] = $fontname;
|
||||
}
|
||||
}
|
||||
$list['fonts'][$fontname] = array(
|
||||
'version' => $font['version'],
|
||||
'license' => @$font['license'],
|
||||
);
|
||||
|
||||
$dir = dirname( $inifile );
|
||||
foreach ( glob( "$dir/*.{eot,ttf,woff,svg}", GLOB_BRACE ) as $fontfile ) {
|
||||
$type = substr( $fontfile, strrpos( $fontfile, '.' ) + 1 );
|
||||
$list['fonts'][$fontname][$type] = str_replace( dirname( $dir ) . '/', '', $fontfile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $list['languages'] );
|
||||
ksort( $list['fonts'] );
|
||||
|
||||
$json = json_encode( $list );
|
||||
$js = <<<JAVASCRIPT
|
||||
// Please 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 );
|
||||
Reference in New Issue
Block a user