Skip to content

Commit 635ecb8

Browse files
Update to latest tags
1 parent 627177d commit 635ecb8

44 files changed

Lines changed: 599 additions & 1623 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

articles/fonts/hinting.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# TrueType Hinting
2+
3+
Font hinting is the use of instructions in a font to adjust outline glyphs for a raster grid. In TrueType fonts, those instructions are bytecode programs stored in the font. The rasterizer executes them at a given size and DPI to move outline points before the glyph is drawn.
4+
5+
## Why Hinting Exists
6+
7+
Outline fonts are scalable. Raster images are not. When a glyph is small, its outline has to be represented by a limited number of pixels. Without adjustment, similar stems can round to different widths, horizontal features can fall between pixel rows, and small counters or serifs can lose definition.
8+
9+
Hinting changes the scaled outline before rasterization. It can improve:
10+
11+
- stem thickness
12+
- counter shape
13+
- baseline alignment
14+
- x-height consistency
15+
- serif and bar visibility
16+
- mark attachment stability
17+
18+
The effect is most visible for small UI text at ordinary screen DPI. At larger sizes or high-resolution outputs, the outline has more pixels available and hinting usually has less visible effect.
19+
20+
## How Fonts Applies Hinting
21+
22+
[`TextOptions.HintingMode`](xref:SixLabors.Fonts.TextOptions.HintingMode) controls whether Fonts applies TrueType hinting:
23+
24+
- [`HintingMode.None`](xref:SixLabors.Fonts.HintingMode.None) leaves glyph outlines unhinted.
25+
- [`HintingMode.Standard`](xref:SixLabors.Fonts.HintingMode.Standard) applies the library's FreeType v40-compatible TrueType hinting behavior.
26+
27+
```csharp
28+
using SixLabors.Fonts;
29+
30+
Font font = SystemFonts.CreateFont("Segoe UI", 11);
31+
TextOptions options = new(font)
32+
{
33+
Dpi = 96,
34+
HintingMode = HintingMode.Standard
35+
};
36+
```
37+
38+
The active font size and [`Dpi`](xref:SixLabors.Fonts.TextOptions.Dpi) matter because hinting targets a specific pixels-per-em scale.
39+
40+
## Fonts' Hinting Approach
41+
42+
Fonts uses a TrueType bytecode interpreter modeled on FreeType's v40 subpixel hinting behavior. In practical terms, that means Fonts preserves full vertical TrueType instruction processing while intentionally disabling horizontal hinting.
43+
44+
This approach is designed for modern antialiased text rendering, where horizontal subpixel placement should remain smooth and glyph advances should not be forced into old bi-level grid-fitting behavior. It gives small text the vertical alignment benefits of TrueType hinting while avoiding legacy horizontal snapping that can make spacing and shapes less consistent in modern raster output.
45+
46+
When hinting is active, Fonts:
47+
48+
- executes the font program from `fpgm` to initialize TrueType function definitions
49+
- scales the Control Value Table from `cvt ` for the current size and DPI
50+
- executes the `prep` program to establish the graphics state for glyph programs
51+
- applies `cvar` deltas to control values for variable TrueType fonts before hinting
52+
- provides normalized variation coordinates for TrueType variation-aware instructions
53+
- adds the four TrueType phantom points used for horizontal and vertical metrics during glyph hinting
54+
- executes each glyph's TrueType instructions against the resolved outline
55+
- leaves the outline unhinted if a glyph has no instructions, hinting is inhibited by the font program, or instruction execution fails
56+
57+
## TrueType Scope
58+
59+
Fonts applies this hinting path to TrueType outlines. It does not turn CFF or CFF2 outlines into hinted TrueType outlines, and it does not change which glyphs are selected for the text.
60+
61+
Within the TrueType path, Fonts supports:
62+
63+
- TrueType glyph instruction execution.
64+
- Standard TrueType hinting tables such as `fpgm`, `prep`, and `cvt `.
65+
- Per-glyph hinting at the active size and DPI.
66+
- `cvar`-driven control-value adjustments for variable TrueType fonts before hinting runs.
67+
- Hinted contour-point resolution for GPOS anchor data when a font uses contour-point anchors.
68+
- Font-specific compatibility behavior for fonts known to require hinting.
69+
70+
## When to Enable It
71+
72+
Use [`HintingMode.Standard`](xref:SixLabors.Fonts.HintingMode.Standard) when rendering small TrueType UI text to a raster target and you want grid-fitted outlines.
73+
74+
Use [`HintingMode.None`](xref:SixLabors.Fonts.HintingMode.None) when you want raw outline behavior, when you are rendering large display text, or when the text is being treated as artwork rather than screen UI.
75+
76+
There is no universal best setting. Hinting is a raster-quality tradeoff: it can make small text clearer, but it can also move outlines away from their pure scaled design.
77+
78+
## Common Misunderstandings
79+
80+
Hinting does not:
81+
82+
- fix missing glyphs
83+
- enable ligatures or OpenType features
84+
- choose fallback fonts
85+
- reorder complex scripts
86+
- resolve bidirectional text
87+
- change Unicode indexing or grapheme behavior
88+
89+
Those are layout and shaping concerns. For those, see [Text Shaping](shaping.md).
90+
91+
## Further Reading
92+
93+
[The Raster Tragedy](http://rastertragedy.com/) is a useful deeper discussion of why rasterizing outline text is difficult and why hinting can matter for small text.
94+
95+
## Related Topics
96+
97+
- [Text Layout and Options](textlayout.md)
98+
- [Text Shaping](shaping.md)
99+
- [Font Metrics](fontmetrics.md)
100+
- [Custom Rendering](customrendering.md)

articles/fonts/hintingandshaping.md

Lines changed: 0 additions & 160 deletions
This file was deleted.

articles/fonts/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The Unicode pages are part of the practical API story, not a side topic. Most re
1818
Fonts is licensed under the terms of the [Six Labors Split License, Version 1.0](https://github.com/SixLabors/Fonts/blob/main/LICENSE). See https://sixlabors.com/pricing for commercial licensing details.
1919

2020
>[!IMPORTANT]
21-
>Starting with Fonts 3.0.0, projects that directly depend on SixLabors.Fonts require a valid Six Labors license at build time. Add `sixlabors.lic` to your repository root, set `SixLaborsLicenseFile`, or set `SixLaborsLicenseKey`. This enforcement applies to direct dependencies only. See [License Enforcement Changes and a New Subscription Tier](https://sixlabors.com/posts/licence-enforcement-changes/) for details.
21+
>Starting with Fonts 3.0.0, projects that directly depend on SixLabors.Fonts require a valid Six Labors license at build time. This enforcement applies to direct dependencies only. See [License Enforcement Changes and a New Subscription Tier](https://sixlabors.com/posts/licence-enforcement-changes/) for details.
2222
2323
### Installation
2424

@@ -55,9 +55,9 @@ paket add SixLabors.Fonts --version VERSION_NUMBER
5555
5656
### How to use the license file
5757

58-
Add the supplied `sixlabors.lic` file to your repository root. Use the file as supplied; it already contains the complete license string required by the build.
58+
By default, the build searches from each project directory for `sixlabors.lic`. Place the supplied file in the directory that contains the project file, or in a subdirectory below it. Use the file as supplied; it already contains the complete license string required by the build.
5959

60-
If you want to keep the file somewhere else, set `SixLaborsLicenseFile` in your project file or a shared props file:
60+
If you want to keep the file somewhere else, including a repository root that sits above the project directory, set `SixLaborsLicenseFile` in your project file or a shared props file:
6161

6262
```xml
6363
<PropertyGroup>
@@ -104,7 +104,8 @@ If you are new to Fonts, start with [Loading Fonts and Collections](gettingstart
104104
- [Selection and Bidi Drag](caretsandselection.md)
105105
- [Text Layout and Options](textlayout.md)
106106
- [OpenType Features](opentypefeatures.md)
107-
- [Hinting and Shaping](hintingandshaping.md)
107+
- [Text Shaping](shaping.md)
108+
- [TrueType Hinting](hinting.md)
108109
- [Color Fonts](colorfonts.md)
109110
- [Unicode, Code Points, and Graphemes](unicode.md)
110111
- [Fallback Fonts and Multilingual Text](fallbackfonts.md)

articles/fonts/opentypefeatures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Some OpenType features are especially relevant in vertical layout, such as [`Kno
126126

127127
Those work alongside [`LayoutMode`](xref:SixLabors.Fonts.TextOptions.LayoutMode); they do not replace it.
128128

129-
For the surrounding layout controls, see [Text Layout and Options](textlayout.md). For the broader shaping pipeline, see [Hinting and Shaping](hintingandshaping.md).
129+
For the surrounding layout controls, see [Text Layout and Options](textlayout.md). For the broader shaping pipeline, see [Text Shaping](shaping.md).
130130

131131
### Practical guidance
132132

0 commit comments

Comments
 (0)