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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
platforms: [
.iOS(.v15),
.macOS(.v12),
.visionOS(.v1)
.visionOS(.v2)
],
products: [
.library(
Expand Down
22 changes: 6 additions & 16 deletions Sources/LaTeXSwiftUI/Extensions/Image+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,15 @@ import SwiftUI

internal extension Image {

init(image: _Image, scale: CGFloat = 1.0) {
init(image: _Image) {
#if os(iOS) || os(visionOS)
// `UIImage(cgImage:scale:orientation:)` already carries the display
// scale, so its `size` is in points.
self.init(uiImage: image)
#else
if scale > 1.0 {
let scaledSize = NSSize(
width: image.size.width / scale,
height: image.size.height / scale
)

let scaledImage = image.resized(to: scaledSize)
if let representation = image.representations.first {
scaledImage.addRepresentation(representation)
}

self.init(nsImage: scaledImage)
return
}

// `NSImage(cgImage:size:)` is created with the logical size, so its
// `size` is already in points — dividing by the display scale again
// would lay the image out at half its intended size on Retina screens.
self.init(nsImage: image)
#endif
}
Expand Down
47 changes: 0 additions & 47 deletions Sources/LaTeXSwiftUI/Extensions/NSImage+Extensions.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ extension TeXInputProcessorOptions {
convenience init(processEscapes: Bool, errorMode: LaTeX.ErrorMode) {
self.init()
self.processEscapes = processEscapes


// MathJaxSwift 3.5.0 ships `defaultDigits` with its escapes stripped
// (`\{,\}` → `{,}`, `\.` → `.`), so the unescaped `.` matches *any*
// character and the tokenizer swallows whatever follows a number: `x^{2}`
// loses its closing brace and MathJax fails with "Extra open brace or
// missing close brace". Restore MathJax's own default regex.
// See colinc86/MathJaxSwift#45.
digits = #"^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)"#


var packages = TeXInputProcessorOptions.Packages.all
if errorMode != .rendered {
if let noErrorsIndex = packages.firstIndex(of: TeXInputProcessorOptions.Packages.noerrors) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/LaTeXSwiftUI/Models/Renderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ extension Renderer {
Cache.shared.setImageCacheValue(image, for: cacheKey)

// Finish up
return Image(image: image, scale: displayScale)
return Image(image: image)
.renderingMode(renderingMode)
.antialiased(true)
.interpolation(.high)
Expand Down
2 changes: 1 addition & 1 deletion Sources/LaTeXSwiftUI/Previews/LaTeX_Previews+Fonts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import SwiftUI

#if os(iOS)
#if os(iOS) || os(visionOS)
import UIKit
typealias PlatformFont = UIFont
#else
Expand Down