PcfFont 0.0.1
dotnet add package PcfFont --version 0.0.1
NuGet\Install-Package PcfFont -Version 0.0.1
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="PcfFont" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PcfFont" Version="0.0.1" />
<PackageReference Include="PcfFont" />
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 PcfFont --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PcfFont, 0.0.1"
#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=PcfFont&version=0.0.1
#tool nuget:?package=PcfFont&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PcfFont.NET
PcfFont is a library for manipulating Portable Compiled Format (PCF) Fonts.
Installation
dotnet add package PcfFont
Usage
Create
using PcfSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var builder = new PcfFontBuilder();
builder.Config.FontAscent = 14;
builder.Config.FontDescent = 2;
builder.Glyphs.Add(new PcfGlyph(
name: "A",
encoding: 65,
scalableWidth: 500,
characterWidth: 8,
dimensions: (8, 16),
offset: (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]
]));
builder.Properties.Foundry = "Pixel Font Studio";
builder.Properties.FamilyName = "My Font";
builder.Properties.WeightName = "Medium";
builder.Properties.Slant = "R";
builder.Properties.SetWidthName = "Normal";
builder.Properties.AddStyleName = "Sans Serif";
builder.Properties.PixelSize = 16;
builder.Properties.PointSize = builder.Properties.PixelSize * 10;
builder.Properties.ResolutionX = 75;
builder.Properties.ResolutionY = 75;
builder.Properties.Spacing = "P";
builder.Properties.AverageWidth = Convert.ToInt32(Math.Round(builder.Glyphs.Sum(glyph => glyph.CharacterWidth * 10) / Convert.ToDouble(builder.Glyphs.Count)));
builder.Properties.CharsetRegistry = "ISO10646";
builder.Properties.CharsetEncoding = "1";
builder.Properties.GenerateXlfd();
builder.Properties.XHeight = 7;
builder.Properties.CapHeight = 10;
builder.Properties.FontVersion = "1.0.0";
builder.Properties.Copyright = "Copyright (c) TakWolf";
builder.Save(Path.Combine(outputsDir, "my-font.pcf"));
Load
using PcfSpec;
var outputsDir = Path.Combine("build");
if (Directory.Exists(outputsDir))
{
Directory.Delete(outputsDir, true);
}
Directory.CreateDirectory(outputsDir);
var font = PcfFont.Load(Path.Combine("assets", "unifont", "unifont-16.0.02.pcf"));
Console.WriteLine($"name: {font.Properties!.Font}");
Console.WriteLine($"size: {font.Properties!.PointSize}");
Console.WriteLine($"ascent: {font.Accelerators!.FontAscent}");
Console.WriteLine($"descent: {font.Accelerators!.FontDescent}");
Console.WriteLine();
foreach (var (encoding, glyphIndex) in font.BdfEncodings!)
{
var glyphName = font.GlyphNames![glyphIndex];
var metric = font.Metrics![glyphIndex];
var bitmap = font.Bitmaps![glyphIndex];
Console.WriteLine($"char: {char.ConvertFromUtf32(encoding)} ({encoding:X4})");
Console.WriteLine($"glyphName: {glyphName}");
Console.WriteLine($"advanceWidth: {metric.CharacterWidth}");
Console.WriteLine($"dimensions: {metric.Dimensions}");
Console.WriteLine($"offset: {metric.Offset}");
foreach (var bitmapRow in bitmap)
{
var text = string.Join("", bitmapRow).Replace("0", " ").Replace("1", "██");
Console.WriteLine($"{text}*");
}
Console.WriteLine();
}
font.Save(Path.Combine(outputsDir, "unifont-16.0.02.pcf"));
Test Fonts
References
- FreeType font driver for PCF fonts
- FontForge - The X11 PCF bitmap font file format
- The X Font Library
- bdftopcf
- bdftopcf - docs
- 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.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 127 | 4/6/2025 |