Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions Bifcode.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions BifcodePackage/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions BifcodePackage/Sources/BifcodeFeature/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ContentView.swift
//
// Created on 17.12.2025.
// Copyright © 2025 IGR Soft. All rights reserved.
// Copyright © 2026 IGR Soft. All rights reserved.
//

import AppKit
Expand Down Expand Up @@ -89,6 +89,7 @@ public struct ContentView: View {
@AppStorage("indicatorSize") private var indicatorSize: Double = 48
@AppStorage("showTitle") private var showTitle: Bool = true
@AppStorage("fontSize") private var fontSize: Double = 14
@AppStorage("fontFamily") private var fontFamilyRaw: String = FontFamily.system.rawValue
@AppStorage("selectedTheme") private var selectedThemeRaw: String = EditorThemeOption.atomOneDark.rawValue
@AppStorage("themeMode") private var themeModeRaw: String = ThemeMode.dark.rawValue

Expand All @@ -104,6 +105,10 @@ public struct ContentView: View {
IndicatorStyle(rawValue: indicatorStyleRaw) ?? .iconAndText
}

private var fontFamily: FontFamily {
FontFamily(rawValue: fontFamilyRaw) ?? .system
}

private var selectedTheme: EditorThemeOption {
EditorThemeOption(rawValue: selectedThemeRaw) ?? .atomOneDark
}
Expand Down Expand Up @@ -292,7 +297,7 @@ public struct ContentView: View {
@MainActor
private func renderExportViewToImage() async -> NSImage? {
// Calculate size based on layout and content
let font = NSFont.monospacedSystemFont(ofSize: fontSize, weight: .regular)
let font = fontFamily.font(size: fontSize)

// Find the longest line in both panels
let doLines = viewModel.doPanel.code.components(separatedBy: "\n")
Expand Down
81 changes: 80 additions & 1 deletion BifcodePackage/Sources/BifcodeFeature/Models/SettingsTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,92 @@
// SettingsTypes.swift
//
// Created on 17.12.2025.
// Copyright © 2025 IGR Soft. All rights reserved.
// Copyright © 2026 IGR Soft. All rights reserved.
//

import AppKit
import CodeEditSourceEditor
import Foundation

// MARK: - Font Family

/// The font family for code display in the editor.
///
/// Provides a selection of popular monospace fonts suitable for code editing.
/// The default is the system monospace font (SF Mono on macOS).
///
/// ## Usage
///
/// ```swift
/// @AppStorage("fontFamily") private var fontFamily = FontFamily.system.rawValue
/// ```
///
/// ## Available Fonts
///
/// - **System** - SF Mono (default system monospace)
/// - **Menlo** - Classic macOS monospace font
/// - **Monaco** - Legacy macOS programming font
/// - **Courier** - Traditional monospace font
///
/// ## Topics
///
/// ### Fonts
///
/// - ``system``
/// - ``menlo``
/// - ``monaco``
/// - ``courier``
public enum FontFamily: String, CaseIterable, Sendable {
/// System monospace font (SF Mono on macOS).
///
/// The default font, matching Apple's design guidelines
/// for code display. Available in all weights.
case system

/// Menlo font family.
///
/// A classic macOS monospace font derived from Bitstream Vera Sans Mono.
/// Has been the default Terminal font for many years.
case menlo = "Menlo"

/// Monaco font family.
///
/// The original macOS programming font, used in classic Mac OS
/// and early versions of Xcode. Has a distinctive, compact style.
case monaco = "Monaco"

/// Courier New font family.
///
/// A traditional typewriter-style monospace font. Has a more
/// classic, formal appearance than other options.
case courier = "Courier New"

/// A human-readable label for display in pickers.
public var label: String {
switch self {
case .system: "SF Mono"
case .menlo: "Menlo"
case .monaco: "Monaco"
case .courier: "Courier New"
}
}

/// Creates an NSFont with this font family at the specified size.
///
/// - Parameter size: The font size in points.
/// - Returns: An NSFont configured with this font family, or the
/// system monospace font if the specified font is unavailable.
public func font(size: CGFloat) -> NSFont {
switch self {
case .system:
NSFont.monospacedSystemFont(ofSize: size, weight: .regular)
case .menlo, .monaco, .courier:
NSFont(name: rawValue, size: size)
?? NSFont.monospacedSystemFont(ofSize: size, weight: .regular)
}
}
}

// MARK: - Indicator Position

/// The position of the indicator badge within a code panel.
Expand Down
Loading