Skip to content

Commit

Permalink
Change expected OTF files mime type
Browse files Browse the repository at this point in the history
porting: WordPress/gutenberg#54886

Co-authored-by: Madhu Dollu <1935113+madhusudhand@users.noreply.github.com>
Co-authored-by: Jason Crist <146530+pbking@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 28, 2023
1 parent 04fe719 commit 839ff70
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/wp-includes/fonts/class-wp-font-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function get_expected_font_mime_types_per_php_version( $php_versio
$php_7_ttf_mime_type = $php_version_id >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf';

return array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => $php_version_id >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type,
'woff' => $php_version_id >= 80100 ? 'font/woff' : 'application/font-woff',
'woff2' => $php_version_id >= 80100 ? 'font/woff2' : 'application/font-woff2',
Expand Down
Binary file added tests/phpunit/tests/data/fonts/gilbert-color.otf
Binary file not shown.
28 changes: 28 additions & 0 deletions tests/phpunit/tests/fonts/font-library/wpFontFamily/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public function test_should_move_local_fontfaces( $font_data, array $files_data,
copy( __DIR__ . '/../../../data/fonts/cooper-hewitt.woff', $file['tmp_name'] );
} elseif ( 'font/woff2' === $file['type'] ) {
copy( __DIR__ . '/../../../data/fonts/DMSans.woff2', $file['tmp_name'] );
} elseif ( 'application/vnd.ms-opentype' === $file['type'] ) {
copy( __DIR__ . '/../../../data/fonts/gilbert-color.otf', $file['tmp_name'] );
}
}

Expand Down Expand Up @@ -302,6 +304,32 @@ public function data_should_move_local_fontfaces() {
),
'expected' => array( 'dm-sans_regular_500.woff2' ),
),
// otf font type.
'otf local font' => array(
'font_data' => array(
'name' => 'Gilbert Color',
'slug' => 'gilbert-color',
'fontFamily' => 'Gilbert Color',
'fontFace' => array(
array(
'fontFamily' => 'Gilbert Color',
'fontStyle' => 'regular',
'fontWeight' => '500',
'uploadedFile' => 'files0',
),
),
),
'files_data' => array(
'files0' => array(
'name' => 'gilbert-color.otf',
'type' => 'application/vnd.ms-opentype',
'tmp_name' => wp_tempnam( 'Gilbert-' ),
'error' => 0,
'size' => 123,
),
),
'expected' => array( 'gilbert-color_regular_500.otf' ),
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
'version 7.2' => array(
'php_version_id' => 70200,
'expected' => array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => 'application/x-font-ttf',
'woff' => 'application/font-woff',
'woff2' => 'application/font-woff2',
Expand All @@ -43,7 +43,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
'version 7.3' => array(
'php_version_id' => 70300,
'expected' => array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => 'application/font-sfnt',
'woff' => 'application/font-woff',
'woff2' => 'application/font-woff2',
Expand All @@ -52,7 +52,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
'version 7.4' => array(
'php_version_id' => 70400,
'expected' => array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => 'font/sfnt',
'woff' => 'application/font-woff',
'woff2' => 'application/font-woff2',
Expand All @@ -61,7 +61,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
'version 8.0' => array(
'php_version_id' => 80000,
'expected' => array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => 'font/sfnt',
'woff' => 'application/font-woff',
'woff2' => 'application/font-woff2',
Expand All @@ -70,7 +70,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
'version 8.1' => array(
'php_version_id' => 80100,
'expected' => array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => 'font/sfnt',
'woff' => 'font/woff',
'woff2' => 'font/woff2',
Expand All @@ -79,7 +79,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
'version 8.2' => array(
'php_version_id' => 80200,
'expected' => array(
'otf' => 'font/otf',
'otf' => 'application/vnd.ms-opentype',
'ttf' => 'font/sfnt',
'woff' => 'font/woff',
'woff2' => 'font/woff2',
Expand Down

0 comments on commit 839ff70

Please sign in to comment.