Skip to content

Commit

Permalink
fixed Linux support
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Jun 4, 2016
1 parent f344df4 commit a115954
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
)
10 changes: 9 additions & 1 deletion Sources/Silica/Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -231,3 +231,11 @@ internal extension String {
return String(utf8[indexRange])
}
}

internal extension String {

func contains(_ other: String) -> Bool {

return strstr(self, other) != nil
}
}
4 changes: 2 additions & 2 deletions Sources/SilicaTests/FontTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions Xcode/Silica/Silica.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
6E5041631CE8F13C0087E9A3 /* CGPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGPath.swift; sourceTree = "<group>"; };
6E5041641CE8F13C0087E9A3 /* CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreGraphics.swift; sourceTree = "<group>"; };
6E572EB91CDFE21E002E245A /* AffineTransform.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AffineTransform.swift; sourceTree = "<group>"; };
6EC4D07E1D031435009E499F /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../../Package.swift; sourceTree = "<group>"; };
6EEFFEAE1CE0797900515526 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
6EEFFEB01CE07B6B00515526 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
6EEFFEB21CE07BDE00515526 /* DrawingMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DrawingMode.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -133,6 +134,7 @@
6E339B5F1CDFC492008E399E = {
isa = PBXGroup;
children = (
6EC4D07E1D031435009E499F /* Package.swift */,
6E169A5B1CE428ED00C60B0B /* Dependencies */,
6E339B831CDFC663008E399E /* Sources */,
6E339B6B1CDFC492008E399E /* Silica */,
Expand Down

0 comments on commit a115954

Please sign in to comment.