Skip to content

Commit a115954

Browse files
committed
fixed Linux support
1 parent f344df4 commit a115954

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

Package.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,14 @@ let package = Package(
55
dependencies: [
66
.Package(url: "https://github.com/PureSwift/Cairo.git", majorVersion: 1)
77
],
8+
targets: [
9+
10+
Target(
11+
name: "SilicaTests",
12+
dependencies: [.Target(name: "Silica")]),
13+
Target(
14+
name: "Silica")
15+
16+
],
817
exclude: ["Xcode"]
918
)

Sources/Silica/Font.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private func FcPattern(name: String) -> (pointer: OpaquePointer, family: String)
161161
// should free memory, but crashes
162162
// defer { free(traitsCString) }
163163

164-
let traitsString = String(utf8String: trimmedCString)!
164+
let traitsString = String(cString: trimmedCString)
165165

166166
let familyLength = name.utf8.count - traitsString.utf8.count - 1 // for separator
167167

@@ -231,3 +231,11 @@ internal extension String {
231231
return String(utf8[indexRange])
232232
}
233233
}
234+
235+
internal extension String {
236+
237+
func contains(_ other: String) -> Bool {
238+
239+
return strstr(self, other) != nil
240+
}
241+
}

Sources/SilicaTests/FontTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class FontTests: XCTestCase {
1515

1616
func testCreateSimpleFont() {
1717

18-
guard let font = Font(name: "MicrosoftSansSerif")
18+
guard let font = Silica.Font(name: "MicrosoftSansSerif")
1919
else { XCTFail("Could not create font"); return }
2020

2121
let expectedFullName = "Microsoft Sans Serif"
@@ -26,7 +26,7 @@ final class FontTests: XCTestCase {
2626

2727
func testCreateTraitFont() {
2828

29-
guard let font = Font(name: "MicrosoftSansSerif-Bold")
29+
guard let font = Silica.Font(name: "MicrosoftSansSerif-Bold")
3030
else { XCTFail("Could not create font"); return }
3131

3232
let expectedFullName = "Microsoft Sans Serif"

Xcode/Silica/Silica.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
6E5041631CE8F13C0087E9A3 /* CGPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGPath.swift; sourceTree = "<group>"; };
8686
6E5041641CE8F13C0087E9A3 /* CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreGraphics.swift; sourceTree = "<group>"; };
8787
6E572EB91CDFE21E002E245A /* AffineTransform.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AffineTransform.swift; sourceTree = "<group>"; };
88+
6EC4D07E1D031435009E499F /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../../Package.swift; sourceTree = "<group>"; };
8889
6EEFFEAE1CE0797900515526 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
8990
6EEFFEB01CE07B6B00515526 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
9091
6EEFFEB21CE07BDE00515526 /* DrawingMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DrawingMode.swift; sourceTree = "<group>"; };
@@ -133,6 +134,7 @@
133134
6E339B5F1CDFC492008E399E = {
134135
isa = PBXGroup;
135136
children = (
137+
6EC4D07E1D031435009E499F /* Package.swift */,
136138
6E169A5B1CE428ED00C60B0B /* Dependencies */,
137139
6E339B831CDFC663008E399E /* Sources */,
138140
6E339B6B1CDFC492008E399E /* Silica */,

0 commit comments

Comments
 (0)