Skip to content

Commit

Permalink
Fix SwiftPackageListCore to work on iOS and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
thompsondave committed Mar 16, 2023
1 parent 8b8c3fa commit dec8d2a
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
// Created by Felix Herrmann on 11.04.22.
//

import AppKit
#if os(OSX)
import AppKit
typealias AliasFont = NSFont
typealias AliasEdgeInsets = NSEdgeInsets
#elseif os(iOS)
import UIKit
typealias AliasFont = UIFont
typealias AliasEdgeInsets = UIEdgeInsets
#endif

import SwiftPackageList

struct PDFGenerator: OutputGenerator {
Expand Down Expand Up @@ -67,10 +76,10 @@ struct PDFGenerator: OutputGenerator {
}

private func buildAttributedString() throws -> NSMutableAttributedString {
guard let defaultFont = NSFont(name: "Helvetica", size: 12) else {
guard let defaultFont = AliasFont(name: "Helvetica", size: 12) else {
throw RuntimeError("Font \"Helvetica\" not available")
}
guard let boldFont = NSFont(name: "Helvetica Bold", size: 12) else {
guard let boldFont = AliasFont(name: "Helvetica Bold", size: 12) else {
throw RuntimeError("Font \"Helvetica Bold\" not available")
}

Expand Down Expand Up @@ -112,7 +121,7 @@ struct PDFGenerator: OutputGenerator {

private func calculateDrawableRect(in context: CGContext) -> CGRect {
let boxRect = context.boundingBoxOfClipPath
let insets = NSEdgeInsets(top: 80, left: 80, bottom: 80, right: 80)
let insets = AliasEdgeInsets(top: 80, left: 80, bottom: 80, right: 80)

let x = boxRect.origin.x + insets.left
let y = boxRect.origin.y + insets.top
Expand Down

0 comments on commit dec8d2a

Please sign in to comment.