|
8 | 8 |
|
9 | 9 | import XCTest |
10 | 10 | @testable import Silica |
| 11 | +import FontConfig |
11 | 12 |
|
12 | 13 | final class FontTests: XCTestCase { |
13 | 14 |
|
14 | 15 | func testCreateFont() { |
15 | 16 |
|
16 | 17 | #if os(Linux) |
17 | 18 | var fontNames = [ |
18 | | - ("LiberationSerif", "Liberation Serif"), |
19 | | - ("LiberationSerif-Bold", "Liberation Serif") |
| 19 | + ("LiberationSerif", "Liberation Serif", FontWeight.regular), |
| 20 | + ("LiberationSerif-Bold", "Liberation Serif", .bold) |
20 | 21 | ] |
21 | 22 |
|
22 | 23 | #else |
23 | 24 | var fontNames = [ |
24 | | - ("TimesNewRoman", "Times New Roman"), |
25 | | - ("TimesNewRoman-Bold", "Times New Roman") |
| 25 | + ("TimesNewRoman", "Times New Roman", FontWeight.regular), |
| 26 | + ("TimesNewRoman-Bold", "Times New Roman", .bold) |
26 | 27 | ] |
27 | 28 | #endif |
28 | 29 |
|
29 | 30 | #if os(macOS) |
30 | | - fontNames += [("MicrosoftSansSerif", "Microsoft Sans Serif"), |
31 | | - ("MicrosoftSansSerif-Bold", "Microsoft Sans Serif")] |
| 31 | + fontNames += [("MicrosoftSansSerif", "Microsoft Sans Serif", .regular), |
| 32 | + ("MicrosoftSansSerif-Bold", "Microsoft Sans Serif", .bold)] |
32 | 33 | #endif |
33 | 34 |
|
34 | | - for (fontName, expectedFullName) in fontNames { |
| 35 | + for (fontName, expectedFullName, weight) in fontNames { |
35 | 36 |
|
36 | | - guard let font = Silica.CGFont(name: fontName) |
| 37 | + guard let font = Silica.CGFont(name: fontName), |
| 38 | + let pattern = FontConfig.Pattern(cgFont: fontName) |
37 | 39 | else { XCTFail("Could not create font \(fontName)"); return } |
38 | 40 |
|
39 | 41 | XCTAssertEqual(font.name, font.name) |
40 | 42 | XCTAssertEqual(expectedFullName, font.scaledFont.fullName) |
| 43 | + XCTAssertEqual(pattern.family, font.family) |
| 44 | + XCTAssertEqual(pattern.weight, weight) |
41 | 45 | } |
42 | 46 | } |
43 | 47 | } |
0 commit comments