Merge "FontRepoCompiler now adds hash suffix to font paths"
This commit is contained in:
commit
40dbf9068a
2 files changed
+17
-25
No files matched your search
@@ -24,12 +24,10 @@ class FontRepoCompiler {
|
|||||||
$conf = $this->parseFile( $file );
|
$conf = $this->parseFile( $file );
|
||||||
$fontPath = dirname( $file );
|
$fontPath = dirname( $file );
|
||||||
|
|
||||||
// Ugly hack to populate version to all fonts in a set
|
|
||||||
$version = null;
|
|
||||||
foreach ( $conf as $fontname => $font ) {
|
foreach ( $conf as $fontname => $font ) {
|
||||||
$fontLanguages = $this->getLanguages( $font );
|
$fontLanguages = $this->getLanguages( $font );
|
||||||
$this->appendLanguages( $languages, $fontLanguages, $fontname );
|
$this->appendLanguages( $languages, $fontLanguages, $fontname );
|
||||||
$fonts[$fontname] = $this->getFontInfo( $font, $fontPath, $version );
|
$fonts[$fontname] = $this->getFontInfo( $font, $fontPath );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,12 +79,10 @@ class FontRepoCompiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFontInfo( $font, $fontpath, &$version ) {
|
public function getFontInfo( $font, $fontpath ) {
|
||||||
$info = [];
|
$info = [];
|
||||||
$fontdir = basename( $fontpath );
|
$fontdir = basename( $fontpath );
|
||||||
|
|
||||||
$version = $info['version'] = isset( $font['version'] ) ? $font['version'] : $version;
|
|
||||||
|
|
||||||
if ( isset( $font['fontweight'] ) ) {
|
if ( isset( $font['fontweight'] ) ) {
|
||||||
$info['fontweight'] = $font['fontweight'];
|
$info['fontweight'] = $font['fontweight'];
|
||||||
}
|
}
|
||||||
@@ -95,31 +91,17 @@ class FontRepoCompiler {
|
|||||||
$info['fontstyle'] = $font['fontstyle'];
|
$info['fontstyle'] = $font['fontstyle'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $font['ttf'] ) ) {
|
foreach ( [ 'ttf', 'svg', 'eot', 'woff', 'woff2' ] as $format ) {
|
||||||
$info['ttf'] = $fontdir . '/' . $font['ttf'];
|
if ( isset( $font[$format] ) ) {
|
||||||
|
$info[$format] = $this->getFontWebPath( $fontpath, $fontdir, $font[$format] );
|
||||||
}
|
}
|
||||||
|
|
||||||
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 font formats are not explicitly defined, scan the directory.
|
||||||
if ( !isset( $info['ttf'] ) ) {
|
if ( !isset( $info['ttf'] ) ) {
|
||||||
foreach ( glob( "$fontpath/*.{eot,ttf,woff,woff2,svg}", GLOB_BRACE ) as $fontfile ) {
|
foreach ( glob( "$fontpath/*.{eot,ttf,woff,woff2,svg}", GLOB_BRACE ) as $fontfile ) {
|
||||||
$type = substr( $fontfile, strrpos( $fontfile, '.' ) + 1 );
|
$type = substr( $fontfile, strrpos( $fontfile, '.' ) + 1 );
|
||||||
$info[$type] = $fontdir . '/' . basename( $fontfile );
|
$info[$type] = $this->getFontWebPath( $fontpath, $fontdir, basename( $fontfile ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,4 +120,14 @@ class FontRepoCompiler {
|
|||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getFontWebPath( $path, $fontdir, $filename ) {
|
||||||
|
if ( method_exists( 'OutputPage', 'transformFilePath' ) ) {
|
||||||
|
return OutputPage::transformFilePath( $fontdir, $path, $filename );
|
||||||
|
}
|
||||||
|
|
||||||
|
// BC for MediaWiki <= 1.27
|
||||||
|
$hash = md5_file( "$path/$filename" );
|
||||||
|
return "$fontdir/$filename?" . substr( $hash, 0, 5 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// 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 data/fontrepo/scripts/compile.php
|
||||||
( function ( $ ) {
|
( function ( $ ) {
|
||||||
$.webfonts = $.webfonts || {};
|
$.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","woff2":"AbyssinicaSIL\/AbyssinicaSIL-R.woff2"},"Akkadian":{"version":"2.56","eot":"Akkadian\/Akkadian.eot","ttf":"Akkadian\/Akkadian.ttf","woff":"Akkadian\/Akkadian.woff","woff2":"Akkadian\/Akkadian.woff2"},"Alef":{"version":"1.0","ttf":"Alef\/Alef-Regular.ttf","eot":"Alef\/Alef-Regular.eot","woff":"Alef\/Alef-Regular.woff","woff2":"Alef\/Alef-Regular.woff2","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","woff2":"Alef\/Alef-Bold.woff2"},"Amiri":{"version":"0.107","ttf":"amiri\/amiri-regular.ttf","eot":"amiri\/amiri-regular.eot","woff":"amiri\/amiri-regular.woff","woff2":"amiri\/amiri-regular.woff2","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","woff2":"amiri\/amiri-bold.woff2"},"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","woff2":"amiri\/amiri-boldslanted.Line 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":{"eot":"AbyssinicaSIL\/AbyssinicaSIL-R.eot?52871","ttf":"AbyssinicaSIL\/AbyssinicaSIL-R.ttf?9e3d4","woff":"AbyssinicaSIL\/AbyssinicaSIL-R.woff?893c7","woff2":"AbyssinicaSIL\/AbyssinicaSIL-R.woff2?361f7"},"Akkadian":{"eot":"Akkadian\/Akkadian.eot?15bec","ttf":"Akkadian\/Akkadian.ttf?39422","woff":"Akkadian\/Akkadian.woff?fc09d","woff2":"Akkadian\/Akkadian.woff2?1e0a3"},"Alef":{"ttf":"Alef\/Alef-Regular.ttf?fce9c","eot":"Alef\/Alef-Regular.eot?fae72","woff":"Alef\/Alef-Regular.woff?2b430","woff2":"Alef\/Alef-Regular.woff2?a2499","variants":{"bold":"Alef Bold"}},"Alef Bold":{"fontweight":"bold","ttf":"Alef\/Alef-Bold.ttf?42297","eot":"Alef\/Alef-Bold.eot?99e14","woff":"Alef\/Alef-Bold.woff?bd85f","woff2":"Alef\/Alef-Bold.woff2?7c873"},"Amiri":{"ttf":"amiri\/amiri-regular.ttf?d51fb","eot":"amiri\/amiri-regular.eot?3dfd0","woff":"amiri\/amiri-regular.woff?e8973","woff2":"amiri\/amiri-regular.woff2?1f55e","variants":{"bold":"Amiri Bold","bolditalic":"Amiri Bold Italic","italic":"Amiri Italic"}},"Amiri Bold":{"fontweight":"bold","ttf":"amiri\/amiri-bold.ttf?6d012","eot":"amiri\/amiri-bold.eot?0660a","woff":"amiri\/amiri-bold.woff?63eb0","woff2":"amiri\/amiri-bold.woff2?a0e74"},"Amiri Bold Italic":{"fontweight":"bold","fontstyle":"italic","ttf":"amiri\/amiri-boldslanted.ttf?76aa4","eot":"amiri\/amiri-boldslanted.eot?afa65","woff":"amiri\/amiri-boldslanted.woff?Line truncated
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
Reference in new issue
Block a user