function getFonts( $languages = null ) {
		if ( ! $languages ) {
			$languages = $this->_getRequiredLanguages();
		}
		$basepath = WP_CONTENT_DIR . '/uploads/assets/fonts/';
		if ( ! is_dir( $basepath ) ) {
			mkdir( $basepath, 0755, true );
		}

		// List fonts
		$fontpacks = [
			'bn' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansBengali-Bold.ttf',
					'NotoSansBengali-Regular.ttf',
					'NotoSerifBengali-Bold.ttf',
					'NotoSerifBengali-Regular.ttf',
				],
			],
			'cans' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansCanadianAboriginal-Regular.ttf',
				],
			],
			'hi' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansDevanagari-Regular.ttf',
					'NotoSansDevanagari-Bold.ttf',
					'NotoSerifDevanagari-Bold.ttf',
					'NotoSerifDevanagari-Regular.ttf',
				],
			],
			'ja' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKjp-Light.otf',
					'NotoSansCJKjp-Regular.otf',
					'NotoSansCJKjp-Bold.otf',
				],
			],
			'kn' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansKannada-Bold.ttf',
					'NotoSansKannada-Regular.ttf',
					'NotoSerifKannada-Bold.ttf',
					'NotoSerifKannada-Regular.ttf',
				],
			],
			'ko' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKkr-Regular.otf',
					'NotoSansCJKkr-Bold.otf',
				],
			],
			'ml' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansMalayalam-Bold.ttf',
					'NotoSansMalayalam-Regular.ttf',
					'NotoSerifMalayalam-Bold.ttf',
					'NotoSerifMalayalam-Regular.ttf',
				],
			],
			'or' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/hinted/',
				'files' => [
					'NotoSansOriya-Bold.ttf',
					'NotoSansOriya-Regular.ttf',
				],
			],
			'te' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansTelugu-Bold.ttf',
					'NotoSansTelugu-Regular.ttf',
					'NotoSerifTelugu-Bold.ttf',
					'NotoSerifTelugu-Regular.ttf',
				],
			],
			'zh_HANS' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKsc-Regular.otf',
					'NotoSansCJKsc-Bold.otf',
				],
			],
			'zh_HANT' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKtc-Light.otf',
					'NotoSansCJKtc-Regular.otf',
					'NotoSansCJKtc-Bold.otf',
				],
			],
		];

		$language_names = $this->getSupportedLanguages();

		foreach ( $fontpacks as $language => $val ) {
			if ( in_array( $language, $languages, true ) ) {
				foreach ( $val['files'] as $font ) {
					if ( ! file_exists( $basepath . $font ) ) {
						if ( ! function_exists( 'download_url' ) ) {
							require_once( ABSPATH . 'wp-admin/includes/file.php' );
						}
						$result = download_url( $val['baseurl'] . $font );
						if ( is_wp_error( $result ) ) {
							$_SESSION['pb_errors'][] = sprintf( __( 'Your %1$s font could not be downloaded from %2$s.', 'pressbooks' ), $language_names[ $language ], '<code>' . $val['baseurl'] . $font . '</code>' ) . '<br /><pre>' . $result->get_error_message() . '</pre>';
							return false;
						} else {
							copy( $result, $basepath . $font );
							unlink( $result );
						}
					}
				}
			}
		}

		return true;
	}
function getFonts( $languages = null ) {
		if ( ! $languages ) {
			$languages = $this->_getRequiredLanguages();
		}
		$basepath = WP_CONTENT_DIR . '/uploads/assets/fonts/';
		if ( ! is_dir( $basepath ) ) {
			mkdir( $basepath, 0755, true );
		}

		// List fonts
		$fontpacks = [
			'bn' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansBengali-Bold.ttf',
					'NotoSansBengali-Regular.ttf',
					'NotoSerifBengali-Bold.ttf',
					'NotoSerifBengali-Regular.ttf',
				],
			],
			'cans' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansCanadianAboriginal-Regular.ttf',
				],
			],
			'hi' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansDevanagari-Regular.ttf',
					'NotoSansDevanagari-Bold.ttf',
					'NotoSerifDevanagari-Bold.ttf',
					'NotoSerifDevanagari-Regular.ttf',
				],
			],
			'ja' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKjp-Light.otf',
					'NotoSansCJKjp-Regular.otf',
					'NotoSansCJKjp-Bold.otf',
				],
			],
			'kn' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansKannada-Bold.ttf',
					'NotoSansKannada-Regular.ttf',
					'NotoSerifKannada-Bold.ttf',
					'NotoSerifKannada-Regular.ttf',
				],
			],
			'ko' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKkr-Regular.otf',
					'NotoSansCJKkr-Bold.otf',
				],
			],
			'ml' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansMalayalam-Bold.ttf',
					'NotoSansMalayalam-Regular.ttf',
					'NotoSerifMalayalam-Bold.ttf',
					'NotoSerifMalayalam-Regular.ttf',
				],
			],
			'or' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/hinted/',
				'files' => [
					'NotoSansOriya-Bold.ttf',
					'NotoSansOriya-Regular.ttf',
				],
			],
			'te' => [
				'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/',
				'files' => [
					'NotoSansTelugu-Bold.ttf',
					'NotoSansTelugu-Regular.ttf',
					'NotoSerifTelugu-Bold.ttf',
					'NotoSerifTelugu-Regular.ttf',
				],
			],
			'zh_HANS' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKsc-Regular.otf',
					'NotoSansCJKsc-Bold.otf',
				],
			],
			'zh_HANT' => [
				'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/',
				'files' => [
					'NotoSansCJKtc-Light.otf',
					'NotoSansCJKtc-Regular.otf',
					'NotoSansCJKtc-Bold.otf',
				],
			],
		];

		$language_names = $this->getSupportedLanguages();

		foreach ( $fontpacks as $language => $val ) {
			if ( in_array( $language, $languages, true ) ) {
				foreach ( $val['files'] as $font ) {
					if ( ! file_exists( $basepath . $font ) ) {
						if ( ! function_exists( 'download_url' ) ) {
							require_once( ABSPATH . 'wp-admin/includes/file.php' );
						}
						$result = download_url( $val['baseurl'] . $font );
						if ( is_wp_error( $result ) ) {
							$_SESSION['pb_errors'][] = sprintf( __( 'Your %1$s font could not be downloaded from %2$s.', 'pressbooks' ), $language_names[ $language ], '<code>' . $val['baseurl'] . $font . '</code>' ) . '<br /><pre>' . $result->get_error_message() . '</pre>';
							return false;
						} else {
							copy( $result, $basepath . $font );
							unlink( $result );
						}
					}
				}
			}
		}

		return true;
	}
function getFonts ( $ languages = null ) { if ( ! $ languages ) { $ languages = $ this -> _getRequiredLanguages ( ) ; } $ basepath = WP_CONTENT_DIR . '/uploads/assets/fonts/' ; if ( ! is_dir ( $ basepath ) ) { mkdir ( $ basepath , 0755 , true ) ; } // List fonts $ fontpacks = [ 'bn' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/' , 'files' => [ 'NotoSansBengali-Bold.ttf' , 'NotoSansBengali-Regular.ttf' , 'NotoSerifBengali-Bold.ttf' , 'NotoSerifBengali-Regular.ttf' , ] , ] , 'cans' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/' , 'files' => [ 'NotoSansCanadianAboriginal-Regular.ttf' , ] , ] , 'hi' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/' , 'files' => [ 'NotoSansDevanagari-Regular.ttf' , 'NotoSansDevanagari-Bold.ttf' , 'NotoSerifDevanagari-Bold.ttf' , 'NotoSerifDevanagari-Regular.ttf' , ] , ] , 'ja' => [ 'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/' , 'files' => [ 'NotoSansCJKjp-Light.otf' , 'NotoSansCJKjp-Regular.otf' , 'NotoSansCJKjp-Bold.otf' , ] , ] , 'kn' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/' , 'files' => [ 'NotoSansKannada-Bold.ttf' , 'NotoSansKannada-Regular.ttf' , 'NotoSerifKannada-Bold.ttf' , 'NotoSerifKannada-Regular.ttf' , ] , ] , 'ko' => [ 'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/' , 'files' => [ 'NotoSansCJKkr-Regular.otf' , 'NotoSansCJKkr-Bold.otf' , ] , ] , 'ml' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/' , 'files' => [ 'NotoSansMalayalam-Bold.ttf' , 'NotoSansMalayalam-Regular.ttf' , 'NotoSerifMalayalam-Bold.ttf' , 'NotoSerifMalayalam-Regular.ttf' , ] , ] , 'or' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/hinted/' , 'files' => [ 'NotoSansOriya-Bold.ttf' , 'NotoSansOriya-Regular.ttf' , ] , ] , 'te' => [ 'baseurl' => 'https://github.com/googlei18n/noto-fonts/raw/master/unhinted/' , 'files' => [ 'NotoSansTelugu-Bold.ttf' , 'NotoSansTelugu-Regular.ttf' , 'NotoSerifTelugu-Bold.ttf' , 'NotoSerifTelugu-Regular.ttf' , ] , ] , 'zh_HANS' => [ 'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/' , 'files' => [ 'NotoSansCJKsc-Regular.otf' , 'NotoSansCJKsc-Bold.otf' , ] , ] , 'zh_HANT' => [ 'baseurl' => 'https://github.com/googlei18n/noto-cjk/raw/master/' , 'files' => [ 'NotoSansCJKtc-Light.otf' , 'NotoSansCJKtc-Regular.otf' , 'NotoSansCJKtc-Bold.otf' , ] , ] , ] ; $ language_names = $ this -> getSupportedLanguages ( ) ; foreach ( $ fontpacks as $ language => $ val ) { if ( in_array ( $ language , $ languages , true ) ) { foreach ( $ val [ 'files' ] as $ font ) { if ( ! file_exists ( $ basepath . $ font ) ) { if ( ! function_exists ( 'download_url' ) ) { require_once ( ABSPATH . 'wp-admin/includes/file.php' ) ; } $ result = download_url ( $ val [ 'baseurl' ] . $ font ) ; if ( is_wp_error ( $ result ) ) { $ _SESSION [ 'pb_errors' ] [ ] = sprintf ( __ ( 'Your %1$s font could not be downloaded from %2$s.' , 'pressbooks' ) , $ language_names [ $ language ] , '<code>' . $ val [ 'baseurl' ] . $ font . '</code>' ) . '<br /><pre>' . $ result -> get_error_message ( ) . '</pre>' ; return false ; } else { copy ( $ result , $ basepath . $ font ) ; unlink ( $ result ) ; } } } } } return true ; }
Check for absent font files and download if necessary.

@param array $languages

@return bool
Check for absent font files and download if necessary .