Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Dec 14, 2024
1 parent 40c8910 commit e5affd8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Tests/SilicaTests/FontTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,40 @@

import XCTest
@testable import Silica
import FontConfig

final class FontTests: XCTestCase {

func testCreateFont() {

#if os(Linux)
var fontNames = [
("LiberationSerif", "Liberation Serif"),
("LiberationSerif-Bold", "Liberation Serif")
("LiberationSerif", "Liberation Serif", FontWeight.regular),
("LiberationSerif-Bold", "Liberation Serif", .bold)
]

#else
var fontNames = [
("TimesNewRoman", "Times New Roman"),
("TimesNewRoman-Bold", "Times New Roman")
("TimesNewRoman", "Times New Roman", FontWeight.regular),
("TimesNewRoman-Bold", "Times New Roman", .bold)
]
#endif

#if os(macOS)
fontNames += [("MicrosoftSansSerif", "Microsoft Sans Serif"),
("MicrosoftSansSerif-Bold", "Microsoft Sans Serif")]
fontNames += [("MicrosoftSansSerif", "Microsoft Sans Serif", .regular),
("MicrosoftSansSerif-Bold", "Microsoft Sans Serif", .bold)]
#endif

for (fontName, expectedFullName) in fontNames {
for (fontName, expectedFullName, weight) in fontNames {

guard let font = Silica.CGFont(name: fontName)
guard let font = Silica.CGFont(name: fontName),
let pattern = FontConfig.Pattern(cgFont: fontName)
else { XCTFail("Could not create font \(fontName)"); return }

XCTAssertEqual(font.name, font.name)
XCTAssertEqual(expectedFullName, font.scaledFont.fullName)
XCTAssertEqual(pattern.family, font.family)
XCTAssertEqual(pattern.weight, weight)
}
}
}

0 comments on commit e5affd8

Please sign in to comment.