Link Search Menu Expand Document

Configuring TEXDraw

Here we discuss of customizing TEXDraw functionality.

File Structure

├─┬ Core                 (Internal engine code files)
 ├─┬ Atom                             (Atom classes)
  └── ***Atom.cs
 ├─┬ Box                               (Box classes)
  └── ***Box.cs
 ├─┬ Engine                       (Main engine code)
  ├── TexOrchestrator.cs       (orchestrator class)
  ├── TexModuleInitiator.cs   (command definitions)
  ├── TexModuleParser.cs         (parser flow code)
  └── ***.cs
 ├─┬ Internal             (Internal utility helpers)
  ├── TexUtility.cs    (unicode character mappings)
  └── ***.cs
 └── ***.cs
├─┬ Editor                  (Internal editor scripts)
 ├─┬ Resources        (Editor-only sample resources)
  └── ***.tex
 └── ***.cs
├─┬ Fonts             (List of fonts used in TEXDraw)
 ├─┬ Math   (Required basic fonts for math commands)
  └── ***.ttf
 ├─┬ Extras        (optional font and symbol styles)
  └── ***.ttf
 ├─┬ User                       (Custom font styles)
  └── ***.ttf
 ├─┬ Sprites   (Custom sprite pack as symbol styles)
 | └── ***.png
 └─┬ TMPro     (TextMeshPro generated font metadata)
   └── ***.asset
├─┬ Resources     (TEXDraw font and config metadata)
 ├─┬ TexFontMetadata (Saved font character configs)
 | └── ***.asset
 ├── TEXDrawPreference.asset  (Central config file)
 ├── TEXDrawConfiguration.asset  (Prop config file)
 └── TEX-Default.mat             (Default material)
├─┬ Scripts                  (Runtime Unity scripts)
 ├── ***.cs
 └── ***.shader
├── Readme.txt
└── Version.txt

The Menu Bar

Tools, TEXDraw
├── Show Preference          (Select TEXDrawPreference.asset)
├── Rebuild Font Data          (Update changes to font asset)
├── Rebuild TEXDraw on Scene         (Force redraw in editor)
├── Select default material          (Select TEX-Default.mat)
├── ──────────────────────
├── Pool checks        (Open a window to inspect memory pool)
├── Dump Symbols          (Dump list of symbols to clipboard)
├── ──────────────────────
├── Set Selected as Template  (Set selected as template for future new TEXDraw object)
├── Clear Template          (Revert to default template)
├── ──────────────────────
├── Enable TextMeshPro Integration (Enable TMP-based rendering)

Preference File

TEXDraw requires sets of config in order to run. A project-wide settings is available in Assets/Plugins/TEXDraw/TEXDrawPreference.asset. You can also access this file from the menu bar Tools > TEXDraw > Show Preferences. Opening this asset file gives you three tabs:

  • Characters Tab: To manage the character set used in TEXDraw, along with character symbol names and their each type. You can see list of fonts and symbols available in TEXDraw here too.
  • Configurations Tab: To manage the default configuration values to all TEXDraw objects. All measurements are in points.
    • Document
      • Retina Ratio. Used by (Non-TMP) font renderer, the resolution ratio of font textures, higher values can be set for higher screen DPI.
      • Signed Coefficient. TextMeshPro specific value
      • Debug. Internal debugging render flag. (to be used with TEXDRAW_DEBUG compilation flag)
      • Pixels Per Inch. Adjust inch to pixel ratio based on Native Size for spaces and other measurements here.
      • Native Size. To be used with Pixels Per Inch (effective calculation in “Unity Pixel” is (Text Size / Native Size) * (Pixels Per Inch / 72.27), note “Unity Pixel” is the relative pixel adjusted by Canvas UI settings).
    • Paragraph
      • Alignment. Default text-mode alignment (0 left, 1 right).
      • Justify. Default text-mode justification (enabled by default).
      • Indent. Default indentation mode (disabled by default, even though by the “convention” of LaTeX, this should be set to enabled).
      • Right to Left. Nothing happens. To be implemented.
      • Centered Math Block. Override alignment to be centered in math block? (enabled by default).
      • Line Spacing. Default additional space between text lines.
      • Paragraph Spacing. Default additional space between paragraphs. (this overrides Line Spacing)
      • Indent Spacing. Default indentation spacing for first line in paragraph.
      • Bullet Spacing. Default indentation for bullets and numbering.
      • Left Padding. Default paragraph left padding.
      • Right Padding. Default paragraph right padding.
    • Typeface
      • Default Typeface. Text-mode typeface (default is cmr).
      • Typewriter Typeface. Typewriter (\tt) typeface (default is cmtt).
      • Math Typeface. Algebraic math typeface (default is cmmi).
      • Function Typeface. Font for math functions (default is cmr).
      • Blank Space Width. Standard space character width.
      • Line Ascent. Default line ascent (distance from top of the line to baseline). Used to give standard margin of the top line between lines.
      • Line Median. Default line median (distance from baseline to middle of the line). Used to align delimiters and fractions to keep it center along the median.
      • Line Descent. Default line descent (distance from baseline to bottom of the line). Used to give standard margin of the bottom line between lines.
      • Underline Level. Used for underline positioning (the line vertical position).
      • Overline Level. Used for overline positioning (the line vertical position).
      • Midline Level. Used for midline positioning (the line vertical position).
    • Math
      • Thin Space. Width of the thin space character and glue matrix with level of 1.
      • Medium Space. Width of the medium space character and glue matrix with level of 2.
      • Thick Space. Width of the thick space character and glue matrix with level of 3 or 4.
      • Script Ratio. the ratio of size for all level one script.
      • Script Script Ratio. The ratio of size for all level two or more scripts.
      • Line Thickness. Thickness of lines (used in horizontal lines and fraction).
      • Radical Line Thickness. Thickness of line used in radical / root expression.
      • Delimiter Padding. Negative padding between delimiter extension so it looks like merged into one.
      • Frame Padding. Padding inside table cell.
      • Matrice Padding. Padding inside matrix cell.
      • Fraction Padding. Horizontal padding inside fraction cell.
      • Upper Baseline Distance. Distance from top of the line to the upper baseline in Large operator.
      • Upper Minimum Distance. Minimum distance between top of the line to the upper descent in Large operator.
      • Lower Baseline Distance. Distance from bottom of the line to the lower baseline in Large operator.
      • Lower Minimum Distance. Minimum distance between bottom of the line to the lower ascent in Large operator.
      • Script Horizontal Margin. Horizontal margin after script.
      • Script Height Margin. Maximum vertical height in superscript.
      • Script Depth Margin.Maximum vertical height in subscript.
      • Script Ascent Offset. Vertical offset of the superscript.
      • Script Ascent Cramped Offset. Vertical offset of the superscript when cramped.
      • Script Descent Offset. Vertical offset of the subscript.
    • Glue Table the coded table of glue distances. See glue matrix tab!
    • Inline Macros. List of inline function macros. Commonly used for precomposed functions.
    • Block Macros. List of block function macros. Commonly used for document sections.
    • Symbol Aliases. A list of symbol and function name aliases.
    • Global Symbol Table. List of fonts that will be looked up as globals symbols.
  • Glue Matrix the coded table of glue distances. See in LaTeX for more details.

Adding New Fonts

To add a font, you need to:

  1. Get a font file, either a TTF or OTF file.
  2. Rename it to a command name, so it only contain letters.
  3. Import it into the Assets/Plugins/TEXDraw/Font/User folder.
  4. Click the Rebuild Font Data button in the menu bar (Tools > TEXDraw).

The name of the font file will be used as the command. For example, if you import MyFont.ttf, the command to activate that font will be \MyFont. This is all that you need to use any custom font in TEXDraw.

If you want make it the default, you can set it as the default font, by going to the Configuration file and go to section Typeface, Default Typeface and type the name of the font.

Extending TEXDraw

TEXDraw can be more powerful by extending it functionalities. Go to the next page!