diff --git a/Package.swift b/Package.swift index e725503..fc56246 100644 --- a/Package.swift +++ b/Package.swift @@ -5,5 +5,14 @@ let package = Package( dependencies: [ .Package(url: "https://github.com/PureSwift/Cairo.git", majorVersion: 1) ], + targets: [ + + Target( + name: "SilicaTests", + dependencies: [.Target(name: "Silica")]), + Target( + name: "Silica") + + ], exclude: ["Xcode"] ) \ No newline at end of file diff --git a/Sources/Silica/Font.swift b/Sources/Silica/Font.swift index 49c4cae..bd95cd2 100644 --- a/Sources/Silica/Font.swift +++ b/Sources/Silica/Font.swift @@ -161,7 +161,7 @@ private func FcPattern(name: String) -> (pointer: OpaquePointer, family: String) // should free memory, but crashes // defer { free(traitsCString) } - let traitsString = String(utf8String: trimmedCString)! + let traitsString = String(cString: trimmedCString) let familyLength = name.utf8.count - traitsString.utf8.count - 1 // for separator @@ -231,3 +231,11 @@ internal extension String { return String(utf8[indexRange]) } } + +internal extension String { + + func contains(_ other: String) -> Bool { + + return strstr(self, other) != nil + } +} diff --git a/Sources/SilicaTests/FontTests.swift b/Sources/SilicaTests/FontTests.swift index 4cdb26b..3bf0a3b 100644 --- a/Sources/SilicaTests/FontTests.swift +++ b/Sources/SilicaTests/FontTests.swift @@ -15,7 +15,7 @@ final class FontTests: XCTestCase { func testCreateSimpleFont() { - guard let font = Font(name: "MicrosoftSansSerif") + guard let font = Silica.Font(name: "MicrosoftSansSerif") else { XCTFail("Could not create font"); return } let expectedFullName = "Microsoft Sans Serif" @@ -26,7 +26,7 @@ final class FontTests: XCTestCase { func testCreateTraitFont() { - guard let font = Font(name: "MicrosoftSansSerif-Bold") + guard let font = Silica.Font(name: "MicrosoftSansSerif-Bold") else { XCTFail("Could not create font"); return } let expectedFullName = "Microsoft Sans Serif" diff --git a/Xcode/Silica/Silica.xcodeproj/project.pbxproj b/Xcode/Silica/Silica.xcodeproj/project.pbxproj index cd545ed..2750a20 100644 --- a/Xcode/Silica/Silica.xcodeproj/project.pbxproj +++ b/Xcode/Silica/Silica.xcodeproj/project.pbxproj @@ -85,6 +85,7 @@ 6E5041631CE8F13C0087E9A3 /* CGPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGPath.swift; sourceTree = ""; }; 6E5041641CE8F13C0087E9A3 /* CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreGraphics.swift; sourceTree = ""; }; 6E572EB91CDFE21E002E245A /* AffineTransform.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AffineTransform.swift; sourceTree = ""; }; + 6EC4D07E1D031435009E499F /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../../Package.swift; sourceTree = ""; }; 6EEFFEAE1CE0797900515526 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 6EEFFEB01CE07B6B00515526 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = ""; }; 6EEFFEB21CE07BDE00515526 /* DrawingMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DrawingMode.swift; sourceTree = ""; }; @@ -133,6 +134,7 @@ 6E339B5F1CDFC492008E399E = { isa = PBXGroup; children = ( + 6EC4D07E1D031435009E499F /* Package.swift */, 6E169A5B1CE428ED00C60B0B /* Dependencies */, 6E339B831CDFC663008E399E /* Sources */, 6E339B6B1CDFC492008E399E /* Silica */,