Skip to content

Commit d667d80

Browse files
pbkingmadhusudhand
andauthored
Font Library: Changed the OTF mime type expected value to be what PHP returns (#54886)
* Changed the OTF mime type expected value to be what PHP returns * add unit test for otf file installation --------- Co-authored-by: madhusudhand <[email protected]>
1 parent f637b37 commit d667d80

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

lib/experimental/fonts/font-library/class-wp-font-library.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function get_expected_font_mime_types_per_php_version( $php_versio
3636
$php_7_ttf_mime_type = $php_version_id >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf';
3737

3838
return array(
39-
'otf' => 'font/otf',
39+
'otf' => 'application/vnd.ms-opentype',
4040
'ttf' => $php_version_id >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type,
4141
'woff' => $php_version_id >= 80100 ? 'font/woff' : 'application/font-woff',
4242
'woff2' => $php_version_id >= 80100 ? 'font/woff2' : 'application/font-woff2',
612 KB
Binary file not shown.

phpunit/tests/fonts/font-library/wpFontFamily/install.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public function test_should_move_local_fontfaces( $font_data, array $files_data,
167167
copy( __DIR__ . '/../../../data/fonts/cooper-hewitt.woff', $file['tmp_name'] );
168168
} elseif ( 'font/woff2' === $file['type'] ) {
169169
copy( __DIR__ . '/../../../data/fonts/DMSans.woff2', $file['tmp_name'] );
170+
} elseif ( 'application/vnd.ms-opentype' === $file['type'] ) {
171+
copy( __DIR__ . '/../../../data/fonts/gilbert-color.otf', $file['tmp_name'] );
170172
}
171173
}
172174

@@ -302,6 +304,32 @@ public function data_should_move_local_fontfaces() {
302304
),
303305
'expected' => array( 'dm-sans_regular_500.woff2' ),
304306
),
307+
// otf font type.
308+
'otf local font' => array(
309+
'font_data' => array(
310+
'name' => 'Gilbert Color',
311+
'slug' => 'gilbert-color',
312+
'fontFamily' => 'Gilbert Color',
313+
'fontFace' => array(
314+
array(
315+
'fontFamily' => 'Gilbert Color',
316+
'fontStyle' => 'regular',
317+
'fontWeight' => '500',
318+
'uploadedFile' => 'files0',
319+
),
320+
),
321+
),
322+
'files_data' => array(
323+
'files0' => array(
324+
'name' => 'gilbert-color.otf',
325+
'type' => 'application/vnd.ms-opentype',
326+
'tmp_name' => wp_tempnam( 'Gilbert-' ),
327+
'error' => 0,
328+
'size' => 123,
329+
),
330+
),
331+
'expected' => array( 'gilbert-color_regular_500.otf' ),
332+
),
305333
);
306334
}
307335

phpunit/tests/fonts/font-library/wpFontLibrary/getMimeTypes.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
3434
'version 7.2' => array(
3535
'php_version_id' => 70200,
3636
'expected' => array(
37-
'otf' => 'font/otf',
37+
'otf' => 'application/vnd.ms-opentype',
3838
'ttf' => 'application/x-font-ttf',
3939
'woff' => 'application/font-woff',
4040
'woff2' => 'application/font-woff2',
@@ -43,7 +43,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
4343
'version 7.3' => array(
4444
'php_version_id' => 70300,
4545
'expected' => array(
46-
'otf' => 'font/otf',
46+
'otf' => 'application/vnd.ms-opentype',
4747
'ttf' => 'application/font-sfnt',
4848
'woff' => 'application/font-woff',
4949
'woff2' => 'application/font-woff2',
@@ -52,7 +52,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
5252
'version 7.4' => array(
5353
'php_version_id' => 70400,
5454
'expected' => array(
55-
'otf' => 'font/otf',
55+
'otf' => 'application/vnd.ms-opentype',
5656
'ttf' => 'font/sfnt',
5757
'woff' => 'application/font-woff',
5858
'woff2' => 'application/font-woff2',
@@ -61,7 +61,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
6161
'version 8.0' => array(
6262
'php_version_id' => 80000,
6363
'expected' => array(
64-
'otf' => 'font/otf',
64+
'otf' => 'application/vnd.ms-opentype',
6565
'ttf' => 'font/sfnt',
6666
'woff' => 'application/font-woff',
6767
'woff2' => 'application/font-woff2',
@@ -70,7 +70,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
7070
'version 8.1' => array(
7171
'php_version_id' => 80100,
7272
'expected' => array(
73-
'otf' => 'font/otf',
73+
'otf' => 'application/vnd.ms-opentype',
7474
'ttf' => 'font/sfnt',
7575
'woff' => 'font/woff',
7676
'woff2' => 'font/woff2',
@@ -79,7 +79,7 @@ public function data_should_supply_correct_mime_type_for_php_version() {
7979
'version 8.2' => array(
8080
'php_version_id' => 80200,
8181
'expected' => array(
82-
'otf' => 'font/otf',
82+
'otf' => 'application/vnd.ms-opentype',
8383
'ttf' => 'font/sfnt',
8484
'woff' => 'font/woff',
8585
'woff2' => 'font/woff2',

0 commit comments

Comments
 (0)