Skip to content

Commit eaa3c9a

Browse files
committed
Update unit tests
- move fonts to tests resources directory - remove Intel Clear-Light - add W3C unit test font Ahem - add new font info test fixes #117
1 parent a45ae21 commit eaa3c9a

File tree

9 files changed

+235
-10
lines changed

9 files changed

+235
-10
lines changed

sample-fonts/IntelClear-Light.ttf

-94.4 KB
Binary file not shown.
-5.88 KB
Binary file not shown.

tests/FontLib/FontTest.php

+23-10
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,30 @@ public function testLoadFileNotFound()
2222
}
2323
}
2424

25-
public function testLoadTTFFontSuccessfully()
25+
public function testLoadTTFFont()
2626
{
27-
$trueTypeFont = Font::load('sample-fonts/IntelClear-Light.ttf');
27+
$trueTypeFont = Font::load('tests/resources/fonts/ahem/ahem.ttf');
2828

2929
$this->assertInstanceOf('FontLib\TrueType\File', $trueTypeFont);
3030
}
3131

32-
public function test12CmapFormat()
32+
public function testGetFontInfoTTF()
3333
{
34-
$trueTypeFont = Font::load('sample-fonts/NotoSansShavian-Regular.ttf');
34+
$font = Font::load('tests/resources//fonts/ahem/ahem.ttf');
35+
$font->parse();
36+
$this->assertSame('Ahem', $font->getFontName());
37+
$this->assertSame('Regular', $font->getFontSubfamily());
38+
$this->assertSame('Version 1.50 Ahem', $font->getFontSubfamilyID());
39+
$this->assertSame('Ahem', $font->getFontFullName());
40+
$this->assertSame('Version 1.50', $font->getFontVersion());
41+
$this->assertSame(400, $font->getFontWeight());
42+
$this->assertSame('Ahem', $font->getFontPostscriptName());
43+
$this->assertTrue($font->close());
44+
}
45+
46+
public function testTTFCmap()
47+
{
48+
$trueTypeFont = Font::load('tests/resources/fonts/noto/NotoSansShavian-Regular.ttf');
3549

3650
$trueTypeFont->parse();
3751

@@ -40,17 +54,16 @@ public function test12CmapFormat()
4054
$cmapFormat4Table = $cmapTable[0];
4155

4256
$this->assertEquals(4, $cmapFormat4Table['format']);
43-
$this->assertEquals(6, $cmapFormat4Table['segCount']);
57+
$this->assertEquals(51, $cmapFormat4Table['segCount']);
4458
$this->assertEquals($cmapFormat4Table['segCount'], count($cmapFormat4Table['startCode']));
4559
$this->assertEquals($cmapFormat4Table['segCount'], count($cmapFormat4Table['endCode']));
4660

4761
$cmapFormat12Table = $cmapTable[1];
4862

4963
$this->assertEquals(12, $cmapFormat12Table['format']);
50-
$this->assertEquals(6, $cmapFormat12Table['ngroups']);
51-
$this->assertEquals(6, count($cmapFormat12Table['startCode']));
52-
$this->assertEquals(6, count($cmapFormat12Table['endCode']));
53-
$this->assertEquals(53, count($cmapFormat12Table['glyphIndexArray']));
64+
$this->assertEquals(294, $cmapFormat12Table['ngroups']);
65+
$this->assertEquals(294, count($cmapFormat12Table['startCode']));
66+
$this->assertEquals(294, count($cmapFormat12Table['endCode']));
67+
$this->assertEquals(383, count($cmapFormat12Table['glyphIndexArray']));
5468
}
55-
5669
}

tests/resources/fonts/ahem/LICENSE

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The Ahem font belongs to the public domain. In jurisdictions that do
2+
not recognize public domain ownership of these files, the following
3+
Creative Commons Zero declaration applies:
4+
http://labs.creativecommons.org/licenses/zero-waive/1.0/us/legalcode

tests/resources/fonts/ahem/README.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
The Ahem font was developed by Todd Fahrner and Myles C. Maxfield to
2+
help test writers develop predictable tests. The units per em is 1000,
3+
the ascent is 800, and the descent is 200, thereby making the em
4+
square exactly square. The glyphs for most characters is simply a box
5+
which fills this square. The codepoints mapped to this full square
6+
with a full advance are the following ranges:
7+
8+
U+20-U+26
9+
U+28-U+6F
10+
U+71-U+7E
11+
U+A0-U+C8
12+
U+CA-U+FF
13+
U+131
14+
U+152-U+153
15+
U+178
16+
U+192
17+
U+2C6-U+2C7
18+
U+2C9
19+
U+2D8-U+2DD
20+
U+394
21+
U+3A5
22+
U+3A7
23+
U+3A9
24+
U+3BC
25+
U+3C0
26+
U+2013-U+2014
27+
U+2018-U+201A
28+
U+201C-U+201E
29+
U+2020-U+2022
30+
U+2026
31+
U+2030
32+
U+2039-U+203A
33+
U+2044
34+
U+2122
35+
U+2126
36+
U+2202
37+
U+2206
38+
U+220F
39+
U+2211-U+2212
40+
U+2219-U+221A
41+
U+221E
42+
U+222B
43+
U+2248
44+
U+2260
45+
U+2264-U+2265
46+
U+22F2
47+
U+25CA
48+
U+3007
49+
U+4E00
50+
U+4E03
51+
U+4E09
52+
U+4E5D
53+
U+4E8C
54+
U+4E94
55+
U+516B
56+
U+516D
57+
U+5341
58+
U+56D7
59+
U+56DB
60+
U+571F
61+
U+6728
62+
U+6C34
63+
U+706B
64+
U+91D1
65+
U+F000-U+F002
66+
67+
The codepoints which are mapped to something else are the following:
68+
69+
" " (U+20): No path but full advance
70+
"p" (U+70): Path has 0 ascent but full descent
71+
"É" (U+C9): Path has 0 descent but full ascent
72+
Non-breaking space (U+A0): No path but full advance
73+
Zero-width non-breaking space (U+FEFF): No path and 0 advance
74+
En space (U+2002): No path and half advance
75+
Em space (U+2003): No path but full advance
76+
Three-per-em space (U+2004): No path and one third advance
77+
Four-per-em space (U+2005): No path and one quarter advance
78+
Six-per-em space (U+2006): No path and one sixth advance
79+
Thin space (U+2009): No path and one fifth advance
80+
Hair space (U+200A): No path and one tenth advance
81+
Zero width space (U+200B): No path and no advance
82+
Ideographic space (U+3000): No path but full advance
83+
Zero width non-joiner (U+200C): No path and no advance
84+
Zero width joiner (U+200D): No path and no advance
85+
Greek capital letter Upsilon (U+3A5): Thin vertical stripe and full advance
86+
Greek capital letter Chi (U+3A7): Thin horizontal stripe and full advance
87+
"横" (U+6A2A): Thin horizontal stripe and full advance
88+
"橫" (U+6A6B): Thin horizontal stripe and full advance;
89+
"縦" (U+7E26): Thin vertical stripe and full advance;
90+
"縱" (U+7E31): Thin vertical stripe and full advance;
91+
"纵" (U+7EB5): Thin vertical stripe and full advance.
92+
93+
Source: https://www.w3.org/Style/CSS/Test/Fonts/Ahem/

tests/resources/fonts/ahem/ahem.ttf

22 KB
Binary file not shown.

tests/resources/fonts/noto/LICENSE

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Copyright 2022 The Noto Project Authors
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
https://scripts.sil.org/OFL
6+
7+
8+
-----------------------------------------------------------
9+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10+
-----------------------------------------------------------
11+
12+
PREAMBLE
13+
The goals of the Open Font License (OFL) are to stimulate worldwide
14+
development of collaborative font projects, to support the font creation
15+
efforts of academic and linguistic communities, and to provide a free and
16+
open framework in which fonts may be shared and improved in partnership
17+
with others.
18+
19+
The OFL allows the licensed fonts to be used, studied, modified and
20+
redistributed freely as long as they are not sold by themselves. The
21+
fonts, including any derivative works, can be bundled, embedded,
22+
redistributed and/or sold with any software provided that any reserved
23+
names are not used by derivative works. The fonts and derivatives,
24+
however, cannot be released under any other type of license. The
25+
requirement for fonts to remain under this license does not apply
26+
to any document created using the fonts or their derivatives.
27+
28+
DEFINITIONS
29+
"Font Software" refers to the set of files released by the Copyright
30+
Holder(s) under this license and clearly marked as such. This may
31+
include source files, build scripts and documentation.
32+
33+
"Reserved Font Name" refers to any names specified as such after the
34+
copyright statement(s).
35+
36+
"Original Version" refers to the collection of Font Software components as
37+
distributed by the Copyright Holder(s).
38+
39+
"Modified Version" refers to any derivative made by adding to, deleting,
40+
or substituting -- in part or in whole -- any of the components of the
41+
Original Version, by changing formats or by porting the Font Software to a
42+
new environment.
43+
44+
"Author" refers to any designer, engineer, programmer, technical
45+
writer or other person who contributed to the Font Software.
46+
47+
PERMISSION & CONDITIONS
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
50+
redistribute, and sell modified and unmodified copies of the Font
51+
Software, subject to the following conditions:
52+
53+
1) Neither the Font Software nor any of its individual components,
54+
in Original or Modified Versions, may be sold by itself.
55+
56+
2) Original or Modified Versions of the Font Software may be bundled,
57+
redistributed and/or sold with any software, provided that each copy
58+
contains the above copyright notice and this license. These can be
59+
included either as stand-alone text files, human-readable headers or
60+
in the appropriate machine-readable metadata fields within text or
61+
binary files as long as those fields can be easily viewed by the user.
62+
63+
3) No Modified Version of the Font Software may use the Reserved Font
64+
Name(s) unless explicit written permission is granted by the corresponding
65+
Copyright Holder. This restriction only applies to the primary font name as
66+
presented to the users.
67+
68+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69+
Software shall not be used to promote, endorse or advertise any
70+
Modified Version, except to acknowledge the contribution(s) of the
71+
Copyright Holder(s) and the Author(s) or with their explicit written
72+
permission.
73+
74+
5) The Font Software, modified or unmodified, in part or in whole,
75+
must be distributed entirely under this license, and must not be
76+
distributed under any other license. The requirement for fonts to
77+
remain under this license does not apply to any document created
78+
using the Font Software.
79+
80+
TERMINATION
81+
This license becomes null and void if any of the above conditions are
82+
not met.
83+
84+
DISCLAIMER
85+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93+
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.

tests/resources/fonts/noto/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Noto Sans Shavian is an unmodulated (“sans serif”) design for texts in the
2+
historical artificial _Shavian_ script.
3+
4+
Noto Sans Shavian contains 53 glyphs, and supports 52 characters from the
5+
Unicode block Shavian.
6+
7+
### Supported writing systems
8+
#### Shavian
9+
10+
Shavian (𐑖𐑱𐑝𐑾𐑯 𐑨𐑤𐑓𐑩𐑚𐑧𐑑) is an artificial alphabet, written left-to-right.
11+
Created around 1960 by Ronald Kingsley Read for phonetic spelling of
12+
English. The winning entry in a competition posthumously funded by
13+
playwright Bernard Shaw. Also adopted for Esperanto.
14+
15+
Needs software support for complex text layout (shaping). Read more on
16+
[ScriptSource](https://scriptsource.org/scr/Shaw),
17+
[Unicode](https://www.unicode.org/versions/Unicode13.0.0/ch08.pdf#G27260),
18+
[Wikipedia](https://en.wikipedia.org/wiki/ISO_15924:Shaw),
19+
[Wiktionary](https://en.wiktionary.org/wiki/Category:Shavian_script),
20+
[r12a](https://r12a.github.io/scripts/links?iso=Shaw).
21+
22+
Source: https://github.com/google/fonts/tree/main/ofl/notosansshavian

0 commit comments

Comments
 (0)