colinc86 / LaTeXSwiftUI

A SwiftUI view that renders LaTeX.
MIT License
197 stars 35 forks source link

Any chance you can add support for macOS 12? #20

Open longseespace opened 1 year ago

longseespace commented 1 year ago

Great package. Like the title, any chance you can add support for macOS 12?

Or can you give some pointers on which part of the codebase I should change to support macOS 12.

Thanks

colinc86 commented 1 year ago

Hey @longseespace, thank you!

The short answer is yes.

Long answer: There's a branch I've been working on called background-image (I've pushed it up) that gets rid of the ImageRenderer requirement that is constraining the current release to macOS >= v13 and iOS >= v16. It's not ready for release (see below), and some help could be used in this area.

Currently the view uses SVGView to create a SwiftUI view with the SVG data, and then it uses ImageRenderer to create the images. The downside to this approach is two-fold:

  1. We have to use ImageRenderer which requires newer operating systems
  2. We have to render on the main queue which causes the UI to unnecessarily stutter.

The new solution uses SwiftDraw to draw the SVG directly to a native image which happens on a background queue. If you look at the previews generated for the LaTeX view on this branch, you'll notice that the rendered paths are drawn incorrectly. I haven't had the time to mess with it yet, but it looks like the path's control points are incorrect for some reason when using SwiftDraw. It seems like a package issue since the SVGs rendered correctly with SVGView.

The line to check out is Renderer.swift line 392 on the background-image branch.

m-yeroshenko commented 6 months ago

Hi there, @colinc86! This is an amazing library, thanks for developing it! I have a question regarding the topic raised in this issue: how do you plan to replace Regex? Will you be using NSRegularExpression? Thanks for the answer.