Fonts

Bald ist es soweit: Unsere nächste Leitstellenfahrt findet statt. Weitere Informationen findet ihr hier.

  • Fonts are fonts and are responsible for the variable display of text in OMSI. A font can contain any characters, numbers, letters or even colored images. In OMSI, fonts are used for vehicles (displays, license plates, matrices) and objects (passenger information systems, street signs, inscriptions, stop signs).

    1. General principles

    In the following, "character" means any character that is represented in a font. These can be normal letters or numbers, but also pictograms or colored images.

    1.1. What is a font?

    Fonts are represented in Omsi as so-called text text textures. A font consists of two or three individual files (see also file formats) with different contents:

    • An OFT file (OmsiFontType, pure text) with the name of the font and information about the characters and positions used
    • An image file (_alpha.bmp) that defines the mask ("the shape") of the characters
    • An image file that specifies the color (or contains images). [optional]

    The font system in OMSI is therefore based on the fact that there is one set of data per font: The texture contains all characters of a font, the configuration file contains information on how characters are read from the texture.


    [errobox]Image files for fonts should always be saved as bitmap with a bit depth of 24! [/errobox]


    Basically, a font is nothing more than a summary of individual images. Omsi can then put these images together in a meaningful way so that it makes sense in the game itself. For the program itself, what is shown makes no sense. Therefore passers-by cannot recognize or even use what is displayed with fonts. All that remains is a (for the program) useless composition of images.

    1.2. Use of a font

    Fonts can be found several times in Omsi. For example, fonts are used to represent certain texts or character strings that are variable in Omsi. A good example are car license plates: Every moving vehicle in Omsi can have a license plate number. The letters and number sequences are then automatically created by Omsi. The font can be used to display anything you want on the license plate, not only letters, numbers and characters, but also images such as nationality signs, plaques or frames. (Another possibility for designing license plates is to integrate the license plate "statically" into the repaint, this possibility does not use fonts). Furthermore, fonts can be found on display devices. (Interior displays, IBIS, printer, thermometer, etc.)

    1.3. Fonts or textures

    The rolling ribbons and signs in vehicles used in Omsi are not represented by fonts, but by changing textures. Font-controlled displays can only combine individual characters or character strings. The possibilities are many, but not unlimited: (Changing) textures are useful when formatted coherent words (e.g. target signs, roll tape textures, advertising posters) are to be converted. Fonts are therefore suitable for this purpose if

    • all characters are to be formatted in the same way, i.e. individual characters are not highlighted,
    • the displayed combinations are not yet known at the time of content creation (e.g. current time or date of the game)
    • the text to be displayed changes continuously (e.g. departure time),
    • the text to be displayed is unpredictable (e.g. displays on buses are controlled by the player) or
    • the text changes randomly (e.g. capacity of a parking garage).

    Fonts are therefore used exactly when the text is specified by the script system in the broadest sense.

    The task of actually implementing the fonts remains with the content creator:

    • For license plates or car numbers no special script is usually required.
    • All types of bus displays that have to do with the timetable (destination sign, IBIS, etc.) are displayed using a yard file.
    • For objects, the text is entered in the editor or loaded by script.
    • For vehicles there is still the possibility of script textures.

    OMSI does not "read" fonts in the same way that humans read text, but merely converts characters (strings) into a graphic. Humans cannot read either, so the way it works, such as the farm file, is not controlled by the displayed text, but by "internal" codes. So it cannot be recognized whether a displayed text "makes sense" or not, only the single characters are put together. Also things like line break, hyphenation and handling of overlength (if the text is longer than the display allows) have to be considered when implementing dynamic displays!

    1.4. Fonts in Microsoft Windows

    There are numerous sites for downloading and installing fonts for Windows, including

    • CAT Fonts (License-free use of all offered fonts, also in payware),
    • fonts2u,
    • Dafont (free for private use only),
    • MyFont (with text preview),
    • 1001 Free Fonts and
    • Google Fonts.

    Depending on the format of the fonts, they can be intuitively imported into Windows with a double click (TrueType/.ttf and OpenType/.otf) or a font viewer, e.g. dp4 Font Viewer (free of charge) must be used. In case of problems it can also help to copy the file manually to C:\Windows\Fonts. These fonts will then be available in all programs used, such as word processing or image editing programs.


    [errobox]Also fonts are partly subject to copyright! The respective licenses should be observed without fail. [/errobox]

    2. The Alpha Texture

    The alpha texture is a kind of "template" and defines the shape of the characters. Even if the file names suggest it the other way around, the alpha texture is the "main texture" of a font. Everything that later belongs to the font is white, everything that should not be displayed and is transparent in OMSI is black, simply put: white font on a black background. However, sharp-edged edges can be omitted, OMSI converts grey tones at the edges into partial transparency (as far as possible).

    Recommended sizes are from 256 to 1024 pixels. Larger fonts may appear blurred due to downscaling, depending on the object and use.3512-font-alpha-vorschau-jpg

    Also the place, where later are colored pictures, must be marked with white, here in the example two rectangular pictograms and a circle symbol. The space should also be taken into account.

    For the alpha texture any image editing program can be used (see file formats), ideally with a text tool. The background must be coloured in full black and the font in full white. After considering the quality and resolution of the font and a rough estimate of how many characters are required (For example, 38 characters are sufficient for a license plate from the GDR, namely A-Z, 0-9, hyphen and a space. If lower case letters, special characters or characters in different widths are added, the quantity increases), it is usually sufficient to write all characters one after the other and change the size until the targeted texture size (see Texture) fits. You can also add arbitrary shapes for images (squares, rectangles, circles, ellipses, etc.). The characters should not touch each other or overlap unless it is intentional. Authentic results can be obtained if the distance from character to character is like in a normal text. Against this background, spaces should also be inserted between two visible characters to estimate the distance. OMSI cuts out characters as a straight rectangle, so the font should be straight.

    3. The image texture (optional)

    The image texture is necessary if no monochrome font is displayed, but there are colored pictograms or images. Both textures must have exactly the same pixel size. OMSI places the image texture - simply put - under the alpha texture and replaces everything that is white in the alpha with the color underlying the image texture.3515-font-vorschau-jpgNow the pictograms are filled with color, the font will later be white.

    It is important to note that the cut out alpha parts must match the image texture exactly, otherwise display errors would occur. In an image processing program this can be simulated e.g. with different layers, where the alpha texture gets the highest priority and is "multiplied" to the image texture. In the example, the font is colored orange for clarification (if one would save the colored layer as image texture and the other as alpha texture, this would also result in OMSI) and the areas of the pictograms are exactly on top of each other.

    4. The OFT file

    The OFT file is a simple text file, in which you enter where exactly characters are located in the corresponding graphic file and with which character on the keyboard it can be called. How such a file is structured is explained in the section Structure of an OFT file for the font.


    There are only two commands that are used in this file. These define where an image begins, ends and how large it is. In addition, the associated texture graphics are assigned to this font and the name of the font is also specified. All specifications in the font.oft refer to the pixel position in the graphic. It is also possible to combine two OFT files for two different fonts in one graphic and integrate them in Omsi by certain specified conditions. Errors in this file are reported by Omsi and the font is not displayed.


    The OFT file contains only the name of the font, the corresponding image textures and the positions within the image texture. Depending on the size of the font, the OFT file can have several hundred kB. But it should not exceed 1 MB, because Omsi cannot handle such large files. So useless comments should be kept short and only serve as short information.


    ]On the one hand, the two image files should not be too small, otherwise Omsi cannot display them properly. This would make the font, which can be displayed in Omsi large, appear very pixelated and blurred. If the textures are too large, there are problems with the size display in Omsi and the font does not appear correctly.


    The basic format of the image files is irrelevant. It is not necessary to use a rectangular format, as is usual with textures. So all characters can be displayed in a row or even be arranged in a square. It is only important that both texture files have the same pixel height and width. So they have to be congruent!

    5. Structure of the OFT file

    5.1. Creating the OFT file

    The structure of an OFT file is similar to the structure of a cfg file in Omsi. Again, you can write whatever you want as long as there is no command at the beginning of the line. A valid command is always put in square brackets and must always be at the beginning of the line to be recognized and read. In addition, this command must stand alone in the line.


    Doe OFT file is a simple text file that can be easily created with Word, Word++, Office Word, Open Word, or other writing programs. The file is then saved as normal text file .txt and finally the texture extension is rewritten by txt too often. The query whether this change should be accepted, even if this file could then become unusable for this computer, must be confirmed with OK. Only two commands are allowed in this OFT file:

    • [newfont] here a new character set is defined
    • [char] This defines a single image section

    Each of these two commands then has a certain number of fixed strings between them.


    [newfont]
    1. name of the font without file extension
    2. associated bitmap file name (image texture) including file extension
    3. associated aplha texture with file extension
    4. height of the characters in pixels, including vertical spacing
    5. horizontal gap between the characters


    This command is entered only once and then applies to a single font.


    [char]
    1st code character
    2. left pixel where the character begins
    3. right pixel where the character ends
    4. topmost pixel of the character line


    This command is entered multiple times and is then for a single or multiple contiguous characters.


    So the commands could be written in the OFT file:

    Code
    [newfont]
    Kennz_DDR
    DDR.bmp
    DDR_alpha.bmp
    49
    4


    The individual letters, numbers and characters follow from here:

    This means for the letter A: The letter A starts at vertical pixel column 1 and ends at vertical pixel column 29. The uppermost row of letters starts at horizontal pixel row 2. All letters are 49 pixels high, so the lowest edge of the letter at pixel row 51. This results in an image section for Omsi with coordinates from pixel 1.2 to pixel 29.51


    [errobox]There is one special feature. If a character is requested for which there is no character code, Omsi will consider this font file as faulty and will not work with it. Under each [char] command a character code must also be entered. This should not be difficult so far. The special feature is the space character. Here a simple space character is set under the command [char]. If the space character is missing at this point, Omsi does not recognize the entire font and an error is displayed. In the alpha texture, no characters are entered, but only a black pixel area is left as long as the character should be black. Otherwise, the respective color or colors are entered.[/errorbox]

    5.2. What are character codes and which ones are allowed

    Omsi uses a character code to identify a section of an image. For example, if you would draw an image in the pixel coordinates 1.2 to 29.51, you must give this image a character code for identification. So these are characters that Omsi can recognize. All letters (upper and lower case), all umlauts (Ä; Ö; Ü; ß), all digits and all keyboard characters (+ - . , ; : € @ µ < * ~ = / & % $ § etc.) are allowed. So everything with which Omsi can assign a certain pixel area.

    [errorbox]Thus, up to 110 character codes can be assigned in a font (German keyboard {QWERTZ}). But this does not mean that you can only use a maximum of 110 pixel areas in a font texture. You can use any number of pixel areas. For example, the 38 characters from the GDR license plate, the 38 characters from the West German license plate and the 76 characters for the Euro license plate could be suppressed within a texture, and in addition to that, a lot of country codes (blue field on the EU license plate).

    [errorbox]With the OFT file, you then only need to access a certain group of screen sections. So you would have three OFT fonts, each using the same image texture and alpha texture. However, for the sake of clarity, large, extensive fonts should be provided with a single texture so that the texture size does not become oversized. It would also be possible to enter all characters in one texture, with only one OFT file. However, it would then no longer be possible to access them with a simple entry in the bus selection menu.

    6. Create font faces for Omsi

    6.1. What you need for a writing surface

    To create a text area in Omsi, a 3D program is mandatory. The correct use of this 3D program is a prerequisite for this tutorial. Which 3D program is used is irrelevant (e.g. Modeler, Blender, Cinema 4D, SketchUp etc.).

    6.2. Create a font area

    With a 3D program you create a simple surface that is preferably square. For the license plate, you create a simple small surface that covers the entire title block. This title block need not have more than 2 polygons. Next, this title block is mapped, i.e. a texture is assigned and the texture is applied to the object slide. The required texture is irrelevant, because it is only used as a placeholder. What can be seen or not seen on this texture is not important for Omsi later. For example, you can use the carrier texture "D_kennzeichen.bmp" for the indicator. On the 3D object, the entire texture surface, i.e. all pixels of the texture are then mapped. It doesn't matter that the texture has only 8192 pixels.

    For one bus you need 2 slides. For the front and for the rear license plate. For car numbers, you do the same. So after the mapping, the 3D object is duplicated. The individual surfaces are then moved in front of the license plate surfaces of the vehicle until they are about 1 millimeter in front of the license plate and cover the title block of the license plate. For a single bus consisting of one body, you can then export both texture surfaces as one object. The same applies to the vehicle number. As long as all slides are on one bus body, all number surfaces can be exported as one object. Even if you have a smaller area inside the vehicle, or a larger one on an outer sheet metal side. For curves on the bus, the surface must of course have several polygons, so that the carrier surface can be adapted to the bus body.

    But for an articulated bus, you have to export the surfaces for each part of the vehicle separately. If you have more than one typeface, for example in a multi-line printer or information system, then a separate object must be exported for each separate information request. This means an object slide for the info line (line number, destination code, circulation number, stop code), for the stop display, destination display (if this is to be displayed separately), for the delay/early departure display and for other text fields such as time, next but one stop, etc. It is also possible to combine all objects into one if you have split the different displays on different texture levels.

    6.3. Using title blocks in Omsi

    First of all, the 3D objects should be converted to the Omsie's own o3d format with the x-to-o3d converter (included in the unofficial SDK). Next, the o3d-objects are entered in the model.cfg. These entries take place exclusively in the model.cfg. First of course the mesh (object) is entered. Afterwards the function commands for this mesh follow.

    • Entry of the Mesh.

    [mesh]

    License plate.o3d


    The object name with the file extension is therefore entered here.

    • Entry of the texture, if it is to be changed.


    [matl]

    D-identification number.bmp

    0


    Here the command is followed by the texture name used and mapped on the object with the file extension. Below this follows the corresponding texture layer. If several texture layers are created, then this command follows several times in this mesh section.

    • Associated texture layer.

    [useTextTexture]

    X


    With this command the spelling is important, because it is essential to pay attention to upper and lower case. Otherwise this command is not readable for Omsi. The X indicates the number of the entry sequence of the text textures of this mesh which will be accessed later. This entry follows later.

    • Setting the transparency.

    [matl_alpha]

    2


    Here the entire field is set to transparent. This transparency depends on the alpha channel of the mapped texture. Since this texture does not contain an alpha channel, the whole object becomes transparent. The font then appears from the font, with the alpha texture set as a mask and the image texture set as a color.

    • Assignment of the texture

    [matl_texadress_clamp]


    With this command a texture is displayed once if the texture has been mapped tiled on the slide, i.e. appears multiple times on a texture.

    6.4. Create textures

    At the beginning of each model.cfg are the assigned variable names for the Repaints and below that the list of text textures. There are two different commands possible here, which determine the number of strings under the command. So Omsi knows how many lines have to be read after the command and which line stands for what exactly.


    • [texttexture] - with 8 following lines
    • [texttexture_enh] - with 10 following lines

    6.4.1. Automatic centered alignment

    The command [texttexture] has 8 lines. If not all 8 lines are described, this command is considered invalid and Omsi will display an error. If more than 8 lines are written, only the first 8 lines will be read. All further lines (strings) are irrelevant for this entry.


    [textteture]

    • String variable
    • font name
    • Width of the font in pixels
    • Font height in pixels
    • Monochrome color or color of the image texture
    • Color code red
    • Green colour code
    • Color code blue

    What the individual lines mean is explained in the section Meaning of the individual strings. (A click on a string leads directly to the meaning).

    6.4.2. Manual alignment

    The command [texttexture_enh] has 10 lines which are extracted. Again, less lines are output as errors and more lines are ignored. So the prefix _enh only tells you how many strings to read.


    [texttexture_enh]

    • String variable
    • font name
    • Width of the font in pixels
    • Font height in pixels
    • Monochrome color or color of the image texture
    • Color code red
    • Green colour code
    • Color code blue
    • Orientation or alignment of the font
    • Align pixel to grid


    (A click on a string leads directly to the meaning)



    6.4.3. Meaning of the individual strings

    This is followed by the explanations of what the individual strings are for:

    6.4.3.1. String variable

    The string variable is the variable with which Omsi recognizes what should be displayed on this texture. So it is the identification of which text texture was entered. There are some fixed string variables that do not have to be entered in a script with a system macro. They are already programmed on the Omsi side. The string variables that are not hard-coded must appear in the script (S.$.String variable). These are already fixed for the license plate number and the car numbers:


    Car number: number

    Indicator: identical


    Further string variables must be entered in the script so that Omsi knows which variable is to be read (if necessary, where to find this variable), whether this read value is to be converted and how this information is to be displayed. The result is then named with a variable name so that Omsi can assign this variable name later (S.$.String variable). In the first string under [texttexture] this string variable appears, which identifies the entry. This string variable now contains letters, numbers and characters (character codes), which Omsi replaces with the character codes of the font. The masks found for the individual pixel areas are then combined and can be displayed on the area. Everything that is black on the alpha texture becomes completely transparent, while everything that is white is displayed with the pixel area on the image texture. The string variable used must be spelled correctly for Omsi to find this variable. Also, the macro must be entered and all variable names must be verified, otherwise the variable name is invalid.

    6.4.3.2. font name

    In the second string the name of the font to be used is entered. The file name is not entered because the file name must always be OFT. Omsi cannot use other file extensions. Again, the file name must be entered correctly so that Omsi can find the required font. The font must be located in the Omsi subfolder "Fonts".

    6.4.3.3. Width of the font in pixels

    The width of the font is now specified here. The decisive factor is not the width of the font in the font, but the pixels of the basic texture.

    6.4.3.4. Height of the font in pixels

    The height of the font is also determined by the pixels of the basic texture. Together with the width, a font can thus be displayed larger or smaller than in the font.

    6.4.3.5. Monochrome color or color of the image texture

    Only 2 digits are allowed here.

    • 0 = The following color code is to be used.
    • 1 = The background from the image texture should be used (can be colored).

    With these numbers you can set whether everything should be displayed with a monochrome color or whether the color from the image file should be used. So for the indicator you can choose a color that will appear for all white pixels in the alpha texture of the font. With a value of zero, the color of the image texture is used, which means that solid colored characters are possible.

    6.4.3.6. Color Code Red

    The color value of the red color. This value can range from black (0) to wine red, dark red, red, light red, blow red and white (255).

    6.4.3.7. Color code green


    The color value of the green color. This value can also appear from black (0), through dark green, green, light green to white (255).

    6.4.3.8. Color code blue

    The color value of the blue color Here everything is again in blue, as with the other colors.

    Together these 3 color settings, in Omsi you have the possibility to display 16.974.593 different colors. The 3 colour values are mixed together.

    6.4.3.9. Orientation or alignment of the font

    With the prefix _enh this and the following line are read. This string determines how Omsi should align the font on the texture carrier. The following options are available for this

    • 0 = Centered
    • 1 = Arranged on the left side
    • 2 = Arranged on the right side
    • 3 = Best centred over the lateral distance. The displayed image files are thus set exactly in the middle.
    • 4 = Centered over the left distance, if double spaces have been entered there.
    • 5 = Centered over the right distance, if double spaces have been entered there.
    6.4.3.10. Align pixel to grid

    This allows the font to be aligned horizontally, with only two options available.


    • 0 = Alignment of the available font height, whereby the same number of pixels is set above and below.
    • 1 = Alignment of the font, using the height of the pixels of the font. Depending on how the font is constructed, a font can then be placed at the bottom or at the top.

    6.5. Assigning a texture to the object

    The order in which the text texture entries are made is decisive. This count is zero-based, meaning the order starts with the first entry with 0, the second is entry 1, the third is entry 2 and so on. This count is also found in the model.cfg under the respective mesh entries.


    Under the command:

    • Associated text texture.

    [useTextTexture]

    X


    the X stands for the count value of the text texture sequence. Therefore, most text texture entries are numbered sequentially, starting with zero.

Teilen

CC BY-SA 4.0

Sämtliche Inhalte unseres OMSI-Wiki sind unter Creative Commons Namensnennung & Weitergabe unter gleichen Bedingungen (CC BY-SA 4.0) lizensiert.