diff --git a/Polyhedra/PolyhedraFullLayer.swift b/Polyhedra/PolyhedraFullLayer.swift index d67e70a..e88f965 100644 --- a/Polyhedra/PolyhedraFullLayer.swift +++ b/Polyhedra/PolyhedraFullLayer.swift @@ -19,7 +19,7 @@ class PolyhedraFullLayer: CALayer { private var rotation: Int = .zero private var frameNumber: Int = .zero - public init(size: CGSize, fps: Int) { + public init(size: CGSize, fps: Int, isPreview: Bool) { let settings = PolyhedraSettings() self.polyhedraLayer = CALayer() self.polyhedraLayer.isOpaque = true @@ -41,15 +41,16 @@ class PolyhedraFullLayer: CALayer { super.init() self.isOpaque = true addSublayer(polyhedraLayer) - if settings.shouldShowPolyhedronName() { - let fontSize: CGFloat = CGFloat(radius) * 0.15 + if !isPreview && settings.shouldShowPolyhedronName() { // configure text - let font = NSFont.systemFont(ofSize: fontSize) + let font = NSFont.menuBarFont(ofSize: -1) + let fontSize = font.pointSize let textLayer = CATextLayer() textLayer.contentsScale = Polyhedron.scale let name = polyhedron.name let stringSize = name.size(withAttributes: [.font: font]) - textLayer.frame = CGRect(origin: CGPoint(x: fontSize, y: fontSize), size: stringSize) + let textOffset = CGFloat(radius) * 0.1 + textLayer.frame = CGRect(origin: CGPoint(x: textOffset, y: textOffset), size: stringSize) textLayer.font = font textLayer.fontSize = fontSize textLayer.alignmentMode = .left diff --git a/Polyhedra/PolyhedraScreenSaverView.swift b/Polyhedra/PolyhedraScreenSaverView.swift index e2ddb8b..9837473 100644 --- a/Polyhedra/PolyhedraScreenSaverView.swift +++ b/Polyhedra/PolyhedraScreenSaverView.swift @@ -29,7 +29,7 @@ class PolyhedraScreenSaverView: ScreenSaverView { override func startAnimation() { let fps = PolyhedraScreenSaverView.calculateFramesPerSecond() animationTimeInterval = 1.0 / Double(fps) - let polyhedronScreenSaverLayer = PolyhedraFullLayer(size: frame.size, fps: fps) + let polyhedronScreenSaverLayer = PolyhedraFullLayer(size: frame.size, fps: fps, isPreview: isPreview) layer?.drawsAsynchronously = true layer?.isOpaque = true layer?.addSublayer(polyhedronScreenSaverLayer)