You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,40 @@ struct MyView: View {
73
73
74
74
### Fonts
75
75
76
-
The view needs to be able to measure the current font's x-height to correctly size the characters inside of the rendered LaTeX SVG. To do that, the view must use the `UIFont`/`NSFont` classes and do its best to convert SwiftUI's `Font` structure into the correct `UIFont` instance. Currently, the view's functionality is limited to SwiftUI's static largeTitle, title, title1, headline, etc fonts.
76
+
The view needs to be able to measure the current font's x-height to correctly size the characters inside of the rendered LaTeX SVG. To do that, the view must use the `UIFont`/`NSFont` classes and do its best to convert SwiftUI's `Font` structure into the correct `UIFont` instance. Currently, the view's functionality is limited to SwiftUI's static largeTitle, title, title1, headline, etc fonts, or by using `UIFont`/`NSFont` types directly.
77
+
78
+
The `font` modifier has been overloaded so that you can give the `LaTeX` view `UIFont` and `NSFont` types directly. The following examples will render the size of the LaTeX correctly.
79
+
80
+
```swift
81
+
// SwiftUI perferred fonts
82
+
LaTeX("Hello, $\\LaTeX$!")
83
+
.font(.title)
84
+
85
+
LaTeX("Hello, $\\LaTeX$!")
86
+
.font(.caption)
87
+
88
+
// Any UIFont/NSFont - note that they should be passed directly to the view
89
+
LaTeX("Hello, $\\LaTeX$!")
90
+
.font(UIFont.systemFont(ofSize: 30))
91
+
92
+
LaTeX("Hello, $\\LaTeX$!")
93
+
.font(UIFont(name: "Avenir", size: 25)!)
94
+
```
95
+
96
+
The following examples will _not_ render the size of the LaTeX correctly.
0 commit comments