BdfFont 0.0.2
dotnet add package BdfFont --version 0.0.2
NuGet\Install-Package BdfFont -Version 0.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BdfFont" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BdfFont" Version="0.0.2" />
<PackageReference Include="BdfFont" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BdfFont --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BdfFont, 0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=BdfFont&version=0.0.2
#tool nuget:?package=BdfFont&version=0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BdfFont.NET
BdfFont is a library for manipulating Glyph Bitmap Distribution Format (BDF) Fonts.
Installation
dotnet add package BdfFont
Usage
Create
using BdfSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var font = new BdfFont(
pointSize: 16,
resolution: (75, 75),
boundingBox: (16, 16, 0, -2));
font.Glyphs.Add(new BdfGlyph(
name: "A",
encoding: 65,
scalableWidth: (500, 0),
deviceWidth: (8, 0),
boundingBox: (8, 16, 0, -2),
bitmap: [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]
]));
font.Properties.Foundry = "Pixel Font Studio";
font.Properties.FamilyName = "My Font";
font.Properties.WeightName = "Medium";
font.Properties.Slant = "R";
font.Properties.SetWidthName = "Normal";
font.Properties.AddStyleName = "Sans Serif";
font.Properties.PixelSize = font.PointSize;
font.Properties.PointSize = font.PointSize * 10;
font.Properties.ResolutionX = font.ResolutionX;
font.Properties.ResolutionY = font.ResolutionY;
font.Properties.Spacing = "P";
font.Properties.AverageWidth = Convert.ToInt32(Math.Round(font.Glyphs.Sum(glyph => glyph.DeviceWidthX * 10) / Convert.ToDouble(font.Glyphs.Count)));
font.Properties.CharsetRegistry = "ISO10646";
font.Properties.CharsetEncoding = "1";
font.GenerateNameAsXlfd();
font.Properties.DefaultChar = -1;
font.Properties.FontAscent = 14;
font.Properties.FontDescent = 2;
font.Properties.XHeight = 7;
font.Properties.CapHeight = 10;
font.Properties.FontVersion = "1.0.0";
font.Properties.Copyright = "Copyright (c) TakWolf";
font.Save(Path.Combine(outputsDir, "my-font.bdf"));
Load
using BdfSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var font = BdfFont.Load(Path.Combine("assets", "unifont", "unifont-16.0.02.bdf"));
Console.WriteLine($"name: {font.Name}");
Console.WriteLine($"size: {font.PointSize}");
Console.WriteLine($"ascent: {font.Properties.FontAscent}");
Console.WriteLine($"descent: {font.Properties.FontDescent}");
Console.WriteLine();
foreach (var glyph in font.Glyphs)
{
Console.WriteLine($"char: {char.ConvertFromUtf32(glyph.Encoding)} ({glyph.Encoding:X4})");
Console.WriteLine($"glyphName: {glyph.Name}");
Console.WriteLine($"advanceWidth: {glyph.DeviceWidthX}");
Console.WriteLine($"dimensions: {glyph.Dimensions}");
Console.WriteLine($"offset: {glyph.Offset}");
foreach (var bitmapRow in glyph.Bitmap)
{
var text = string.Join("", bitmapRow).Replace("0", " ").Replace("1", "██");
Console.WriteLine($"{text}*");
}
Console.WriteLine();
}
font.Save(Path.Combine(outputsDir, "unifont-16.0.02.bdf"));
Test Fonts
References
- X11 - Bitmap Distribution Format - Version 2.1
- Adobe - Glyph Bitmap Distribution Format (BDF) Specification - Version 2.2
- X Logical Font Description Conventions - X Consortium Standard
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.