TTFText User Guide


(WORK IN PROGRESS)

The Text Mesh Editor

Main settings

Font Selection

Select the font you which to use from all available TTF fonts present in your System  (or restrict only to those in the asset DataBase). You can toggle from one view to the other by pressing the button "Show System Font"/"Hide System Fonts". If you want to use a font that is located elsewhere, just add it as an asset by clicking the  "Add Font" button.

Text

Specify here the text to render.

Set Object Name

If this is set to true, the name of the Game Object is updated upon text modification to reflect the changes.

Font Size

Specify the font size (in meter). Note that this specify a "nominal size" specific to the font and does not correspond to the size of any character.

Simplify Outline

By changing this parameter you can decimate some points from the outline of your text in order to reduce the number of  triangles in the generated mesh.

Embold

This parameter allows you to add or remove some boldness to your fonts. The algorithm used does not necessarily work perfectly on all fonts but works nicely in many cases.

Slant

As Embold allows you to change the fickness of your font, slant allows you to change freely the inclination of the characters.

One GameObject Per

The default value for this option is Text meaning that the whole input text is generated as a single mesh. In many cases, it is useful for algorithmic, gamelogic, or mesh size limitations to use more than one gameobject for the whole text. Thus, this option allows you to split your text in subobjects. One subobject will be created for each character, word or line depending on the option you choose.

In the case where you create subojects, a prefab should be passed in order to make the text visible.  This prefab should generally contain a component to receive the mesh (Cloth or Mesh Filter), and a component renderer (MeshRenderer or ClothRenderer).

A component TTFSubmesh will be associated to each generated gameobject. This component will allow the other scripts  to know the text that is associated with current mesh, and its index in the generation of the different subojects (More info will be provided in future versions)

Have a look at the demo scene 3 for an example of text using that feature.

Prefab

This is the prefab used in conjunction with the previous option. See previous menu for detail.

Extrusion

This panel allows you to define the way the 3d mesh is generated from the 2d text outline.

Extrusion Mode

For convenience multiple extrusion modes are provided:
  • None :  No extrusion is performed, the text remains flat.  The parameter backFace allows to select whether the text is double-sided (visible from both side or not). If a back-face is generated, it  may be mapped to a different texture than the front-face (see Texture Mapping below).
  • Simple : Create a simple extrusion of the text.  The parameter Extrusion Depth  lets you specify the length of the extrusion (the distance in-between front-face and back-face).
  • Bevel : Create rounded angles. This extrusion mode can be parameterized with the following options :
    • Extrusion Depth : Length of the extrusion (distance in-between front-face and back-face).
    • Bevel Force : Change in emboldment.
    • Steps : Number of interpolation steps in the Bevel.
    • Bevel Depth % : Depth (in percentage of the whole extrusion depth) on which the Bevel is computed.
  • Bent : Variant of Bevel that is softer and spreaded along the mesh. This extrusion mode accepts the following parameter
    • Extrusion Depth : Length of the extrusion (distance in-between front-face and back-face).
    • Bevel Force : Change in emboldment.
    • Steps : Number of interpolation steps in the Bevel.
    • Gamma :  Exponential factor defining how the interpolation gets thinner as it arrives close to the angles.
  • Free Hand : In this mode, you can freely define the shape of the extrusion using an Animation Curve.
    • Extrusion Depth : Length of the extrusion (distance in-between front-face and back-face).
    • Curve :  Where you define the shape of the extrusion.
    • Coefficient :
  • Pipe : In this mode, a 3d pipe is drawned around the text outline.
    • Radius : Radius of the pipe.
    • Number of Edges : Number of interpolation points for the circles forming the border of the pipe.

Text Layout

One Line

In this mode, the text to render will be generated as a single line. The option Character Spacing represents a multiplicative factor that is used to tune the distance between glyphes.

Paragraph

In this mode, the text will be rendered as a multiline text according to the specified line width. The layout of the whole paragraph can be tuned with the following options:
  • Paragraph Alignment : Specify the alignment of the text for each line. The following modes are supported :
    • Left : Left justify text in paragraph.
    • Right : Right justify text in paragraph.
    • Center : Center text in paragraph.
    • Fully Justified : Justify all lines by adding space between characters so that they fill the desired line width.
    • Justified : Justify all lines but the last one. The last line is left justified.  
  • Character Spacing :Specify a factor to tune the distance between characters. In case when the line must be fully justified, this parameter is not used to compute character positions but still considered to compute the line break positions.
  • Line Width : Maximum width of a line.
  • Line Spacing (Mult.) : Specify a multiplicative factor to tune the distance between two lines.
  • Line Spacing (Add.) : Specify a constant additive value to tune the distance between two lines. If the multiplicative factor is set to 0, this can be used to hard set  this distance.
Markup Language and Styles (1.1)

TTF Text markup with HTML based syntax :

Example :
<@style=big@> <@ style = red @>  This  <@ pop @> is still big <@ pop @> !

Styles are with mentioned names are dynamically created in the scene. They may
be used by all the objects in that scene.


Most properties of TTFTextStyle objects also directly accessible :
<@Size=3@>Size <@Embold=+-0.3@>3<@pop@><@pop@>

The operator =+ (resp=*) is the equivalent of =*  (resp *=) in C#.

Thus is <@Size=*=1.5> Big  <@Size=*=1.5> Bigger  <@Size=*=1.5> and Huge.

The operator <@pop@> or <@end@> is used to end the section opened by the most recently non-closed tag.

Texture Mapping

The mapping of the texture on the generated 3d text mesh can be parameterized with the following options:

  • Split Sides : If this option is checked, the mesh will be made of one different submeshes for each side. This is useful if you want to have different textures for each side of the mesh. 
  • UV Mapping : Two different UV Mapping modes are possible :
    • Box :  In box mode the UV coordinates are changing linearly with x and y coordinates in the mesh. Z is affecting both u and v at the same time linearly too.  u and v are computed either directly from the vertice coordinate in a real world space, either from a space normalized at the size of mesh.
    • Spherical : In Spherical mode, the UV coordinates are computed as projected from a sphere : according to the euler angles linking an azimuth direction the vector form the center of the 3D mesh, and the vertice considered in that mesh.
  • UV Scaling Factor : Specify a vector that can be used to scale the uv coordinates computed in both Box or Spherical  mode. 

3D Object Alignment

Horizontal Attachment/Vertical Attachment : These parameters set the position of the builded mesh relative to the transform of the GameObject. By default, the transform corresponds to the center of the mesh.


Other elements

  •  Save Mesh : By clicking this button, you can save the generated mesh as a new asset so that it can easily be reused by other components in your project. This option is only available when the whole text is rendered as one unique mesh (i.e. One GameObject Per Text  is selected).
  •  Add Font : Use this button to import a True Type font as an asset in your project.

Text subobjects

Subobjects can be used to create miscellaneous  effects : one color per word, animate independantly each word or letter, and so on. To use this feature you must create a prefab that will be instanciated as a template for each subobject. Your prefab can contain any scripts or component you wish but, in most cases, it should probably contains at least a MeshRenderer and a MeshFilter in order to render the Text Mesh. A TTFSubtext component is also instanciated for each subobject.  This component contains information such as the sequence index of the generated element that can be used by your scripts

Embedded fonts

To work on any platform, TTF Text now allows to embed fonts in your application. When this option is enabled, TTF Text used a C#-only triangulation algorithm. The adavantage of using a C# only implementation with embedded fonts is that it should work on all platforms.

As soon as the Embedded Fonts option is selected  the changes are reflected in the editor and you can observe the mesh reconstructed from the embedded fonts. By default embedded fonts embed only the ASCII charset. If you are working with a different alphabet  or if you need accents to be supported, a "Additional characters" field is available to specify the other character that should be embedded. Because it would require to embed many ideograms, this option is not recommended for languages with ideograms.We are thinking at solutions for these languages.

The C# triangulation algorithm currently does not support self-intersecting polygons (which can happen quite easily when the simplification / embolden amount are changed )

Animations 

This section of the manual concerns TTF Text 1.0 - An update of TTF Text 1.1 will give you information on how to animate new texts with the unity animator.

TTF Text 1.0 is compatible with Unity module for animation. However, as properties are not visible from the animator, you will need to also animate the curve rebuildMeshes / rebuildOutlines so that the system can be aware that some parameters have been modified and the Text Mesh should be rebuild.



In this example, the Embold value is modified along the time, however for the rebuild of the mesh to be actually perforrmed we also 
animate Rebuildmeshes variable.