How to render text with 1px stroke width at small sizes for embedded displays? #387
Unanswered
dortegacee
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Do you have documentation that supports this because this goes against expected behaviour. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I'm rendering text onto small monochrome OLED displays (SSD1305/SSD1306, 128×32 and 128×64, 1bpp) using
SixLabors.ImageSharp.Drawingv2.1.7 withSixLabors.Fontsv2.1.3 andSixLabors.ImageSharpv3.1.12, targeting .NET 10.On these displays, legibility requires character strokes to be exactly 1 pixel wide. At small font sizes (8–13pt), system fonts like Arial produce strokes that are 2–3px wide, making text look overly bold and hard to read at these resolutions.
What I've tried
1.
Brushes.Solid()fill (default)Fills the glyph interior — strokes are 2–3px wide at small sizes because that's how the font outlines are designed.
2.
Pens.Solid()stroke with small widthThis strokes the boundary path of the glyph fill region (the outline contour), not the stroke centerline. For a letter like "I", this traces both the left and right edges of the stem, producing double lines rather than a single thin stroke. Values below 1f (e.g., 0.2f) still produce multi-pixel results.
3. Embedded pixel font (current workaround)
We switched to an embedded pixel
.ttf(CozetteVector) whose glyph outlines are designed as exact pixel-aligned rectangles. At the font's native size,Brushes.Solid()fill produces 1px strokes because the outlines physically span only 1 pixel. This works, but it limits us to specific bitmap fonts at fixed sizes.The question
Is there a way within ImageSharp.Drawing to achieve 1px stroke rendering from standard vector fonts at small sizes?
TrueType hinting support in SixLabors.Fonts — Is there a planned feature to implement a TrueType bytecode interpreter that would enable grid-fitting? This would be the most direct solution.
Manual glyph path access — Is there a way to access the raw glyph IPath objects and apply custom transforms (e.g., scaling + quantizing control points to pixel grid) before rasterizing?
Any other workaround besides bitmap fonts for achieving pixel-crisp stems at small sizes?
Environment
SixLabors.ImageSharp3.1.12SixLabors.ImageSharp.Drawing2.1.7SixLabors.Fonts2.1.3Beta Was this translation helpful? Give feedback.
All reactions