Custom Fonts
You can apply custom fonts to your mathematical documents in TeXView by declaring CSS @font-face rules in a style file.
Directory Setup
Place your font files (e.g. .ttf, .otf, or .woff) inside your project's assets/ folder, and add a style sheet named flutter_tex.css:
Step-by-Step Guide
1. Define @font-face in assets/flutter_tex.css
Inside assets/flutter_tex.css, define the font family and relative path to the font file:
2. Register Assets in pubspec.yaml
Include both the stylesheet and your fonts in your pubspec.yaml:
3. (Web Only) Link in web/index.html
If deploying to Flutter Web, link the CSS file inside <head> in web/index.html:
Applying the Font in Dart
Use TeXViewFontStyle inside TeXViewStyle to assign your custom typeface, size, and weight:
Font Style Options
Size Units (TeXViewSizeUnit)
| Unit | CSS Equivalent | Description |
|---|---|---|
TeXViewSizeUnit.pixels |
px |
Fixed pixel dimensions (default). |
TeXViewSizeUnit.pt |
pt |
Points (1pt = 1/72 inch). Common for print and academic typography. |
TeXViewSizeUnit.em |
em |
Relative to the parent element's font size. |
TeXViewSizeUnit.percent |
% |
Scaled percentage relative to the parent. |
Font Weights (TeXViewFontWeight)
Supports standard CSS weights: normal, bold, bolder, lighter, and numerical weights from w100 through w900.