KbitFont 0.0.2
dotnet add package KbitFont --version 0.0.2
NuGet\Install-Package KbitFont -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="KbitFont" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KbitFont" Version="0.0.2" />
<PackageReference Include="KbitFont" />
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 KbitFont --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: KbitFont, 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.
#:package KbitFont@0.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KbitFont&version=0.0.2
#tool nuget:?package=KbitFont&version=0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
KbitFont.NET
KbitFont is a library for parsing Bits'N'Picas native save format files (.kbits
and .kbitx
).
Installation
dotnet add package KbitFont
Usage
Create
using KbitSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var font = new KbitFont();
font.Props.EmAscent = 14;
font.Props.EmDescent = 2;
font.Props.LineAscent = 14;
font.Props.LineDescent = 2;
font.Props.XHeight = 7;
font.Props.CapHeight = 10;
font.Names.Version = "1.0.0";
font.Names.Family = "My Font";
font.Names.Style = "Regular";
font.Names.Manufacturer = "Pixel Font Studio";
font.Names.Designer = "TakWolf";
font.Names.Description = "A pixel font";
font.Names.Copyright = "Copyright (c) TakWolf";
font.Names.LicenseDescription = "This Font Software is licensed under the SIL Open Font License, Version 1.1";
font.Names.VendorUrl = "https://github.com/TakWolf/kbitfont-dotnet";
font.Names.DesignerUrl = "https://takwolf.com";
font.Names.LicenseUrl = "https://openfontlicense.org";
font.Characters[65] = new KbitGlyph(
x: 0,
y: 14,
advance: 8,
bitmap: [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00],
[0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00],
[0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00],
[0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],
[0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],
[0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00],
[0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],
[0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],
[0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],
[0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
]);
font.NamedGlyphs[".notdef"] = new KbitGlyph(
x: 0,
y: 14,
advance: 8,
bitmap: [
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF],
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
]);
font.SaveKbits(Path.Combine(outputsDir, "my-font.kbits"));
font.SaveKbitx(Path.Combine(outputsDir, "my-font.kbitx"));
Load Kbits
using KbitSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var font = KbitFont.LoadKbits(Path.Combine("assets", "macintosh", "Athens.kbits"));
Console.WriteLine($"name: {font.Names.Family}");
Console.WriteLine($"size: {font.Props.EmHeight}");
Console.WriteLine($"ascent: {font.Props.LineAscent}");
Console.WriteLine($"descent: {font.Props.LineDescent}");
Console.WriteLine();
foreach (var (codePoint, glyph) in font.Characters)
{
Console.WriteLine($"char: {char.ConvertFromUtf32(codePoint)} ({codePoint:X4})");
Console.WriteLine($"xy: {(glyph.X, glyph.Y)}");
Console.WriteLine($"dimensions: {glyph.Dimensions}");
Console.WriteLine($"advance: {glyph.Advance}");
foreach (var bitmapRow in glyph.Bitmap)
{
var text = string.Join("", bitmapRow.Select(color => color <= 127 ? " " : "██"));
Console.WriteLine($"{text}*");
}
Console.WriteLine();
}
font.SaveKbits(Path.Combine(outputsDir, "Athens.kbits"));
Load Kbitx
using KbitSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var font = KbitFont.LoadKbitx(Path.Combine("assets", "macintosh", "Athens.kbitx"));
Console.WriteLine($"name: {font.Names.Family}");
Console.WriteLine($"size: {font.Props.EmHeight}");
Console.WriteLine($"ascent: {font.Props.LineAscent}");
Console.WriteLine($"descent: {font.Props.LineDescent}");
Console.WriteLine();
foreach (var (codePoint, glyph) in font.Characters)
{
Console.WriteLine($"char: {char.ConvertFromUtf32(codePoint)} ({codePoint:X4})");
Console.WriteLine($"xy: {(glyph.X, glyph.Y)}");
Console.WriteLine($"dimensions: {glyph.Dimensions}");
Console.WriteLine($"advance: {glyph.Advance}");
foreach (var bitmapRow in glyph.Bitmap)
{
var text = string.Join("", bitmapRow.Select(color => color <= 127 ? " " : "██"));
Console.WriteLine($"{text}*");
}
Console.WriteLine();
}
font.SaveKbitx(Path.Combine(outputsDir, "Athens.kbitx"));
Specifications
Font Struct
Kbits
Kbitx
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.