// SPDX-License-Identifier: GPL-3.0-or-later // Outlined vector adaptation of the historical Tandy Orchestra-90 label. // Usage: swift platforms/macos/Tools/make-orchestra-label.swift > docs/media/orchestra-90-label.svg import AppKit import CoreText func number(_ x: CGFloat) -> String { String(format: "%.4f", Double(x)) } func glyphPath(_ text: String, size: CGFloat) -> CGPath { let font = CTFontCreateWithName("EurostileBold" as CFString, size, nil) precondition(CTFontCopyPostScriptName(font) as String == "EurostileBold", "Label authoring requires Eurostile Bold; ordinary builds use the committed SVG/PDF assets.") let line = CTLineCreateWithAttributedString(NSAttributedString(string: text, attributes: [.font: font])) let path = CGMutablePath() for run in CTLineGetGlyphRuns(line) as! [CTRun] { let count = CTRunGetGlyphCount(run) var glyphs = [CGGlyph](repeating: 0, count: count), points = [CGPoint](repeating: .zero, count: count) CTRunGetGlyphs(run, CFRange(location: 0, length: 0), &glyphs) CTRunGetPositions(run, CFRange(location: 0, length: 0), &points) for i in 0.. String { let path = glyphPath(text, size: size) let box = path.boundingBoxOfPath, scale = min(1, width / box.width) let originX = centered ? x + (width - box.width * scale) / 2 : x var d = "" func point(_ p: CGPoint) -> String { "\(number(originX + (p.x-box.minX)*scale)) \(number(y + (box.maxY-p.y)*scale))" } path.applyWithBlock { e in let e = e.pointee switch e.type { case .moveToPoint: d += "M " + point(e.points[0]) case .addLineToPoint: d += " L " + point(e.points[0]) case .addQuadCurveToPoint: d += " Q " + point(e.points[0]) + " " + point(e.points[1]) case .addCurveToPoint: d += " C " + point(e.points[0]) + " " + point(e.points[1]) + " " + point(e.points[2]) case .closeSubpath: d += " Z " @unknown default: break } } return "" } if CommandLine.arguments.contains("--sdc") { // Center the color bars and title as one logo using the actual glyph ink, // rather than the maximum width reserved for text that may be shorter. let logoWidth = 90 + min(343, glyphPath("CoCo SDC", size: 58).boundingBoxOfPath.width) let logoX = (480 - logoWidth) / 2 print(""" CoCo SDC cartridge label Original outlined label based on the Retro Rewind CoCo SDC cartridge reference. No reference-photograph pixels or font files are embedded. See ATTRIBUTION.md. """) print(outline("CoCo SDC", x: logoX + 90, y: 48, width: 343, size: 58, color: "#171d20")) print(outline("FLOPPY DISK EMULATOR", x: 35, y: 123, width: 410, size: 29, color: "#343b3e", centered: true)) print(outline("FOR COLOR COMPUTERS", x: 40, y: 164, width: 400, size: 27, color: "#343b3e", centered: true)) print("") exit(0) } let speech = CommandLine.arguments.contains("--speech") print(""" \(speech ? "Speech/Sound" : "Orchestra-90") cartridge label Vector label adapted from historical Tandy cartridge-label references. Eurostile Bold lettering is outlined; no scanned pixels or font files are embedded. See ATTRIBUTION.md. """) print(outline("TANDY", x: 22, y: 63, width: 130, size: 33, color: "#283c92")) print(outline(speech ? "COLOR COMPUTER" : "ORCHESTRA 90-CC", x: 174, y: 69, width: 280, size: 25, color: "#171c20")) for (i, line) in (speech ? ["SPEECH", "SOUND", "CARTRIDGE"] : ["STEREO", "MUSIC", "SYNTHESIZER"]).enumerated() { print(outline(line, x: 174, y: CGFloat(124+i*33), width: 280, size: 31, color: "#171c20")) } print("")