Added fonts and provided previews.
This commit is contained in:
14
README.md
14
README.md
@@ -54,6 +54,12 @@ f(x) = \int\limits_{-\infty}^\infty\!\hat f(\xi)\,e^{2 \pi i \xi x}\,\mathrm{d}\
|
||||

|
||||
|
||||
More examples are included in [EXAMPLES](EXAMPLES.md)
|
||||
|
||||
## Fonts
|
||||
Here are previews of the included fonts:
|
||||
|
||||

|
||||

|
||||
|
||||
## Requirements
|
||||
`SwiftMath` works on iOS 11+ or MacOS 12+. It depends
|
||||
@@ -170,7 +176,7 @@ This is a list of formula types that the library currently supports:
|
||||
* Equation alignment
|
||||
* Change bold, roman, caligraphic and other font styles (\\bf, \\text, etc.)
|
||||
* Most commonly used math symbols
|
||||
* Colors
|
||||
* Colors for both text and background
|
||||
|
||||
Note: SwiftMath only supports the commands in LaTeX's math mode. There is
|
||||
also no language support for other than west European langugages and some
|
||||
@@ -225,13 +231,15 @@ The default font is *Latin Modern Math*. This can be changed as:
|
||||
label.font = MTFontManager.fontmanager.termesFont(withSize:20)
|
||||
```
|
||||
|
||||
This project has five fonts bundled with it, but you can use any OTF math
|
||||
This project has 12 fonts bundled with it, but you can use any OTF math
|
||||
font. A python script is included that generates the `.plist` files
|
||||
required for an `.otf` font to work with `SwiftMath`. If you generate
|
||||
(and test) any other fonts please contribute them back to this project for
|
||||
others to benefit.
|
||||
|
||||
Note: The `KpMath-Light` and `KpMath-Sans` fonts currently incorrectly
|
||||
|
||||
|
||||
Note: The `KpMath-Light`, `KpMath-Sans`, `Asana` fonts currently incorrectly
|
||||
render very large radicals. It appears that the font files do
|
||||
not properly define the offsets required to typeset these glyphs. If
|
||||
anyone can fix this, it would be greatly appreciated.
|
||||
|
||||
@@ -11,30 +11,53 @@ import UIKit
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
public enum MathFont: String, CaseIterable {
|
||||
public enum MathFont: String, CaseIterable, Identifiable {
|
||||
|
||||
public var id: Self { self } // Makes things simpler for SwiftUI
|
||||
|
||||
case latinModernFont = "latinmodern-math"
|
||||
case kpMathLightFont = "KpMath-Light"
|
||||
case kpMathSansFont = "KpMath-Sans"
|
||||
case xitsFont = "xits-math"
|
||||
case termesFont = "texgyretermes-math"
|
||||
case asanaFont = "Asana-Math"
|
||||
case eulerFont = "Euler-Math"
|
||||
case firaFont = "FiraMath-Regular"
|
||||
case notoSansFont = "NotoSansMath-Regular"
|
||||
case libertinusFont = "LibertinusMath-Regular"
|
||||
case garamondFont = "Garamond-Math"
|
||||
case leteSansFont = "LeteSansMath"
|
||||
|
||||
var fontFamilyName: String {
|
||||
switch self {
|
||||
case .latinModernFont: return "Latin Modern Math"
|
||||
case .kpMathLightFont: return "KpMath"
|
||||
case .kpMathSansFont: return "KpMath"
|
||||
case .xitsFont: return "XITS Math"
|
||||
case .termesFont: return "TeX Gyre Termes Math"
|
||||
case .latinModernFont: "Latin Modern Math"
|
||||
case .kpMathLightFont: "KpMath"
|
||||
case .kpMathSansFont: "KpMath"
|
||||
case .xitsFont: "XITS Math"
|
||||
case .termesFont: "TeX Gyre Termes Math"
|
||||
case .asanaFont: "Asana Math"
|
||||
case .eulerFont: "Euler Math"
|
||||
case .firaFont: "Fira Math"
|
||||
case .notoSansFont: "Noto Sans Math"
|
||||
case .libertinusFont: "Libertinus Math"
|
||||
case .garamondFont: "Garamond Math"
|
||||
case .leteSansFont: "Lete Sans Math"
|
||||
}
|
||||
}
|
||||
var fontName: String {
|
||||
switch self {
|
||||
case .latinModernFont: return "LatinModernMath-Regular"
|
||||
case .kpMathLightFont: return "KpMath-Light"
|
||||
case .kpMathSansFont: return "KpMath-Sans"
|
||||
case .xitsFont: return "XITSMath"
|
||||
case .termesFont: return "TeXGyreTermesMath-Regular"
|
||||
case .latinModernFont: "LatinModernMath-Regular"
|
||||
case .kpMathLightFont: "KpMath-Light"
|
||||
case .kpMathSansFont: "KpMath-Sans"
|
||||
case .xitsFont: "XITSMath"
|
||||
case .termesFont: "TeXGyreTermesMath-Regular"
|
||||
case .asanaFont: "Asana Math"
|
||||
case .eulerFont: "Euler Math"
|
||||
case .firaFont: "Fira Math"
|
||||
case .notoSansFont: "Noto Sans Math"
|
||||
case .libertinusFont: "Libertinus Math"
|
||||
case .garamondFont: "Garamond Math"
|
||||
case .leteSansFont: "Lete Sans Math"
|
||||
}
|
||||
}
|
||||
public func cgFont() -> CGFont {
|
||||
|
||||
@@ -56,6 +56,34 @@ public class MTFontManager {
|
||||
MTFontManager.fontManager.font(withName: "texgyretermes-math", size: size)
|
||||
}
|
||||
|
||||
public func asanaFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "Asana-Math", size: size)
|
||||
}
|
||||
|
||||
public func eulerFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "Euler-Math", size: size)
|
||||
}
|
||||
|
||||
public func firaRegularFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "FiraMath-Regular", size: size)
|
||||
}
|
||||
|
||||
public func notoSansRegularFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "NotoSansMath-Regular", size: size)
|
||||
}
|
||||
|
||||
public func libertinusRegularFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "LibertinusMath-Regular", size: size)
|
||||
}
|
||||
|
||||
public func garamondMathFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "Garamond-Math", size: size)
|
||||
}
|
||||
|
||||
public func leteSansFont(withSize size:CGFloat) -> MTFont? {
|
||||
MTFontManager.fontManager.font(withName: "LeteSansMath", size: size)
|
||||
}
|
||||
|
||||
public var defaultFont: MTFont? {
|
||||
MTFontManager.fontManager.latinModernFont(withSize: kDefaultFontSize)
|
||||
}
|
||||
|
||||
BIN
Sources/SwiftMath/mathFonts.bundle/Asana-Math.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/Asana-Math.otf
Normal file
Binary file not shown.
4343
Sources/SwiftMath/mathFonts.bundle/Asana-Math.plist
Normal file
4343
Sources/SwiftMath/mathFonts.bundle/Asana-Math.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/SwiftMath/mathFonts.bundle/Euler-Math.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/Euler-Math.otf
Normal file
Binary file not shown.
2165
Sources/SwiftMath/mathFonts.bundle/Euler-Math.plist
Normal file
2165
Sources/SwiftMath/mathFonts.bundle/Euler-Math.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/SwiftMath/mathFonts.bundle/FiraMath-Regular.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/FiraMath-Regular.otf
Normal file
Binary file not shown.
3064
Sources/SwiftMath/mathFonts.bundle/FiraMath-Regular.plist
Normal file
3064
Sources/SwiftMath/mathFonts.bundle/FiraMath-Regular.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/SwiftMath/mathFonts.bundle/Garamond-Math.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/Garamond-Math.otf
Normal file
Binary file not shown.
7910
Sources/SwiftMath/mathFonts.bundle/Garamond-Math.plist
Normal file
7910
Sources/SwiftMath/mathFonts.bundle/Garamond-Math.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/SwiftMath/mathFonts.bundle/LeteSansMath.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/LeteSansMath.otf
Normal file
Binary file not shown.
5393
Sources/SwiftMath/mathFonts.bundle/LeteSansMath.plist
Normal file
5393
Sources/SwiftMath/mathFonts.bundle/LeteSansMath.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/SwiftMath/mathFonts.bundle/LibertinusMath-Regular.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/LibertinusMath-Regular.otf
Normal file
Binary file not shown.
4276
Sources/SwiftMath/mathFonts.bundle/LibertinusMath-Regular.plist
Normal file
4276
Sources/SwiftMath/mathFonts.bundle/LibertinusMath-Regular.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Sources/SwiftMath/mathFonts.bundle/NotoSansMath-Regular.otf
Normal file
BIN
Sources/SwiftMath/mathFonts.bundle/NotoSansMath-Regular.otf
Normal file
Binary file not shown.
9356
Sources/SwiftMath/mathFonts.bundle/NotoSansMath-Regular.plist
Normal file
9356
Sources/SwiftMath/mathFonts.bundle/NotoSansMath-Regular.plist
Normal file
File diff suppressed because it is too large
Load Diff
BIN
img/FontsPreview.png
Normal file
BIN
img/FontsPreview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 199 KiB |
BIN
img/FontsPreviewLight.png
Normal file
BIN
img/FontsPreviewLight.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 154 KiB |
Reference in New Issue
Block a user