使用 Quartz 2d 绘制公式

发布于 2024-09-02 17:50:02 字数 82 浏览 7 评论 0原文

在我的 iPhone 应用程序中,我想绘制一些公式。我如何使用quartz 2d 来管理它?有没有办法像乳胶一样构建公式?或者有没有现成的框架?谢谢。

In my iPhone App I'd like to draw a few formulas. How can I manage that with quartz 2d? Is there a way to build formulas like for example in latex? Or are there any existing frameworks? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫离伤花 2024-09-09 17:50:02

作为一款专门实现此功能的 iPhone 应用程序的开发者,请相信我,排版方程并不是一件小事承诺。就我而言,我使用核心动画层来构造解析方程的子元素。方程是分层构造的,并且组成它们的运算也是如此布置的。每个操作都包含在其父操作的层中,并按照该特定操作的规则进行布局。

为了渲染方程中运算的视觉元素,我使用 Quartz 来绘制线条、符号等,但大多数绘图只是使用 NSString 文本绘图扩展在 CALayer 中绘制的文本。

我确实覆盖了标准 CALayer 渲染架构,以便根据这些方程生成 PDF,因为默认情况下 CALayer 不会渲染为矢量元素。有关此渲染如何在我的应用程序中工作的示例,请参阅开源核心图项目,它在底层做同样的事情。

我确实从方程中输出到 LaTeX,一旦将它们解析为分层数据结构,这就非常简单,但事实证明,将它们从 LaTeX 解析为该结构有点棘手。

对于简单的文本方程输入和评估,您可能会发现 Graham Cox 的 GCMathParser 很有用。

As the developer of an iPhone application which does just that, trust me when I say typesetting equations is not a trivial undertaking. In my case, I used Core Animation layers to construct the sub-elements of a parsed equation. The equations are constructed hierarchically, and the operations that compose them are laid out as such. Each operation is contained within its parent operation's layer, and laid out following the rules of that particular operation.

For rendering the visual elements of the operations within an equation, I used Quartz to draw lines, symbols, etc., but most of the drawing was simply text drawn within a CALayer using the NSString text drawing extensions.

I did override the standard CALayer rendering architecture for the generation of PDFs from these equations, because CALayers don't render as vector elements by default. For an example of how this rendering works in my application, see the open source Core Plot project, which does the same thing at its base level.

I do output to LaTeX from the equations, which is pretty simple once you've parsed them into a hierarchical data structure, but parsing them from LaTeX into that structure is proving a little trickier.

For simple text equation input and evaluation, you might find Graham Cox's GCMathParser to be of use.

何时共饮酒 2024-09-09 17:50:02

据我所知,没有真正为 Cocoa touch 实现的 Tex 引擎,但有一个轻量级的 Javascript 公式布局引擎: jsMath

There's no real Tex engine implemented for Cocoa touch that I have heard of, but there is a lightweight Javascript formulae-layout engine: jsMath.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文