diff --git a/data/fontrepo/scripts/compile.php b/data/fontrepo/scripts/compile.php index 43136829..a202072f 100644 --- a/data/fontrepo/scripts/compile.php +++ b/data/fontrepo/scripts/compile.php @@ -1,36 +1,85 @@ $font ) { - foreach ( explode( ',', $font['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['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']; + } + if ( isset( $font['license'] ) ) { + $license = $font['license']; + } + $list['fonts'][$fontname] = array( - 'version' => $font['version'], - 'license' => @$font['license'], + 'version' => $version, + 'license' => $license, ); + if ( isset( $font['fontweight'] ) ) { + $list['fonts'][$fontname]['fontweight'] = $font['fontweight']; + } + if ( isset( $font['fontstyle'] ) ) { + $list['fonts'][$fontname]['fontstyle'] = $font['fontstyle']; + } + $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 ); + + 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 font formats are not explicitly defined, scan the directory. + if ( !isset( $list['fonts'][$fontname]['ttf'] ) ) { + 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 ); + } + } + + // 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']; } } }