Show / Hide Table of Contents

Class LabelFormatter

Helper class to uniformly reformat token streams into a line-wrapping TextLabel. -Problem description: Text in classic Daggerfall uses hard-coded positions, line breaks, and other justification tokens which assume text is written only with a certain size pixel font and only over a 320x200 display area. This is very problematic for correct translation support as international text require fonts of different proportions and each language requires variable distance to express the same concepts. To make matter worse, embedded formatting is broken in several places such as books, where text can become aligned oddly or even overflow the display area completely. A general solution is needed that can reformat text from various sources (quests, books, TEXT.RSC, etc.) into a new layout that will wrap words cleanly and use line breaks only when required. -Earlier implementation: Daggerfall Unity first implemented true classic pixel font support and followed the same formatting tokens precisely. This resulted in a perfect recreation of classic Daggerfall's user interface, but also inherited the same general limitations. When SDF fonts were implemented, they still followed the same formatting as classic. Glyphs were even stretched/squished to occupy the same spaces. While this made text somewhat clearer to read, formatting remained uncomfortable and inflexible. -Iterated implementation: The only way forward to correctly support translations will first require cleaner text formatting. This is a multi-stage process that first implementes new font and formatting support. It is necessary for this system to support both classic and SDF pathways with either default fonts or custom fonts for non-Latin characters. Ideally this will support text read from classic binary data in addition to new language databases. -Purpose of this helper class: This class is an attempt at creating a tool to automatically reformat classic text data from a variety of binary sources into a clean word-wrapped format. Its purpose is only to reformat classic text from the DOS binaries and classic quests to output text in a clean and readable manner for both classic and SDF font pathways. This class is not intended to be used with text sourced from translated text databases (in development) as this text will be written without classic formatting tokens and with normal word wrapping already in mind. -Supported classic sources: Initial support will be for automatically reformatting books. This will be extended to other areas where possible using lessons learned. Automatic text reformatting from classic binary data and quests will always remain "best effort". Eventually all in-game text will be migrated to a default text database at which point formatting can be cleaned up further.

Inheritance
Object
LabelFormatter
Namespace: DaggerfallWorkshop.Game.UserInterface
Assembly: Assembly-CSharp.dll
Syntax
public class LabelFormatter

Properties

| Improve this Doc View Source

Count

Gets number of labels formatted so far.

Declaration
public int Count { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

Clear()

Clear formatter of all data.

Declaration
public void Clear()
| Improve this Doc View Source

CreateLabels()

Create labels from formatted data. Note: If using TextLabel directly, consumer must set TextLabel.MaxWidth to suit layout area.

Declaration
public List<TextLabel> CreateLabels()
Returns
Type Description
List<TextLabel>
| Improve this Doc View Source

ReformatBook(Int32)

Declaration
public bool ReformatBook(int id)
Parameters
Type Name Description
Int32 id
Returns
Type Description
Boolean
| Improve this Doc View Source

ReformatBook(String)

Declaration
public bool ReformatBook(string filename)
Parameters
Type Name Description
String filename
Returns
Type Description
Boolean
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX