Example_PixelFont
Description
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
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_NanumBarunGothic
Generates a pixel font for a non-latin font file.
Nanum Barun Gothic Web Fonts
https://github.com/hiun/NanumBarunGothic
SIL Open Font Licence (OFL)
https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL
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.