Example_PixelFont

Description

sealed class Tinman.Demo.Examples.Code.Example_PixelFont

Full source code is included in the Tinman 3D SDK download.

This example shows how to use the PixelFontBuilder class in order to generate pixel font images, which can be loaded with Graphics.LoadFontFrom to get PixelFont resources.

Public / Methods

Generate_​Alterebro


public static method Generate_Alterebro → (2)

font in : IPixelFontGlyphs own

[not-null]
The IPixelFontGlyphs object that returns the font glyphs.

output in : Path

[not-null]
The directory to write the pixel font file to.

Generates the pixel-font-pxb resource file, which is used by PixelFont.HandleSmall.

There are two built-in fonts: the bigger one is PixelFont.HandleDefault, which is based on the famous VGA Bios font; the smaller one is PixelFont.HandleSmall, which is based on a true-type font file. This example shows how to generate the latter one.

Alterebro Pixel Font Regular
Creative Commons Attribution Non-commercial
https://alterebro.com/
https://duckduckgo.com/?q=Alterebro+Pixel+Font

If you have trouble finding the font online, please download the original font file from here:
https://media.tinman3d.com/alterebro-pixel-font.ttf
After downloading the above font file, the pixel font can be generated like this:

Path inputDir;
Path outputDir;
Path fontFile;
SystemFontGlyphs glyphs; // [!]

inputDir = ...;
outputDir = ...;

fontFile = inputDir.AppendName("alterebro-pixel-font.ttf");

glyphs = SystemFontGlyphs.For(fontFile);

Example_PixelFont.Generate_Alterebro(glyphs, outputDir);

The SystemFontGlyphs class is part of the Tinman.AddOns.WinForms and Tinman.AddOns.WPF components (choose either one).

IOException

If an I/O error has occurred.

Generate_​Nanum​Barun​Gothic


public static method Generate_NanumBarunGothic → (2)

font in : IPixelFontGlyphs own

[not-null]
The IPixelFontGlyphs object that returns the font glyphs.

output in : Path

[not-null]
The directory to write the pixel font file to.

Generates a pixel font for a non-latin font file.

If you have trouble finding the font online, please download the original font file from here:
https://media.tinman3d.com/NanumBarunGothic.ttf
After downloading the above font file, the pixel font can be generated like this:

Path inputDir;
Path outputDir;
Path fontFile;
SystemFontGlyphs glyphs; // [!]

inputDir = ...;
outputDir = ...;

fontFile = inputDir.AppendName("NanumBarunGothic.ttf");

glyphs = SystemFontGlyphs.For(fontFile, 20);

Example_PixelFont.Generate_NanumBarunGothic(glyphs, outputDir);

The SystemFontGlyphs class is part of the Tinman.AddOns.WinForms and Tinman.AddOns.WPF components (choose either one).

IOException

If an I/O error has occurred.