---
title: "Glyph ink: bounds and band intercepts"
url: https://recursiveai.org/onefont/docs/glyphs/
description: "A glyph’s tight ink bounds and the x-intervals where its ink crosses a horizontal band, for text-decoration-skip-ink, without drawing it."
version: "1.7.0"
source: https://github.com/recursive-ai-oss/onefont-csharp/blob/ae5d7cadd6a519a9396e4df804ae53ec28ef546d/docs/glyphs.md
---

# Glyph ink: bounds and band intercepts

Two methods on `FontFace` answer questions about a glyph's ink without drawing it. Both work at the face's current variation instance and for TrueType (simple and composite glyphs), OpenType-CFF and CFF2 outlines. All values are in font units with y pointing up.

## Tight bounds

```csharp
GlyphBounds b = face.GetGlyphBounds(glyphId);   // b.MinX, b.MinY, b.MaxX, b.MaxY, b.IsEmpty
```

The bounds are the exact extents of the curves, not of their control points: a quadratic or cubic segment contributes its end points and the points where its x or y derivative vanishes. `IsEmpty` is `true` (and the values are zero) for a blank glyph, a glyph with no outline (including bitmap-only glyphs), a glyph whose data is damaged, and a glyph id out of range. The result equals `GetOutline(glyphId).TightBox()` to within single-precision rounding, and fontTools' `BoundsPen` on the committed test fonts.

## Band intercepts (`text-decoration-skip-ink`)

```csharp
Span<float> ranges = stackalloc float[32];
int need = face.GetGlyphIntercepts(glyphId, bottom, top, ranges);   // [x0, x1, x2, x3, ...]
float[] all = face.GetGlyphIntercepts(glyphId, bottom, top);        // allocating form
```

The result is the sorted, merged list of x-intervals `[x0, x1, x2, x3, ...]` where the glyph's filled ink lies inside the horizontal band `bottom < y < top`.

- **Fill rule.** Nonzero winding, as in every font format here. A counter (the hole of an "O") is a gap between two intervals; a contour wound the same way as the one around it fills its inside.
- **Open band.** Ink that only touches the band's edge (a flat bottom sitting exactly on `top`) does not count. Intervals of no width are dropped. Touching or overlapping intervals are merged.
- **Return value and short spans.** The span form returns the number of floats the whole answer needs (twice the interval count) even when the span is too short, and writes as many whole pairs as fit, so the caller can retry with a larger span. It returns 0 when `bottom` is not below `top`, when either is NaN, when the band holds no ink, for a blank or damaged glyph and for an id out of range. Infinite edges are clamped to ±1e8.
- **Accuracy.** Curves are evaluated exactly, not flattened: each is cut where y (and x) are extreme so the pieces are monotone, and the band edge is found on a monotone piece by a 60-step bisection. The intervals are within 0.01 font unit of the true ink for coordinates up to 10,000; the remainder is rounding of the result to `float`.
- **Method.** The projection onto x of the ink inside the band is reached, at every x, by the highest ink point on that vertical line. That point lies either on an outline edge inside the band or on the band's top line. So the answer is the union of the x-extents of the edges clipped to the band, the filled spans of the horizontal line just under `top` and the filled spans just over `bottom`. Edges are the outline's segments plus the straight segment that closes each figure.

## Cost and limits

- Both methods read the glyph through the same cache as `GetOutline` (up to 8,192 glyphs per face), so the first call for a glyph loads its outline and later calls reuse it. Once the outline is cached, `GetGlyphBounds` and the span form of `GetGlyphIntercepts` allocate nothing (scratch space comes from `ArrayPool<double>.Shared`).
- Work is O(n log n) in the number of outline segments (an outline has at most 262,144), with no recursion; sorting is a heap sort, so results are identical on every platform.
- A glyph whose data is damaged or over the outline limits gives an empty result from these two methods, where `GetOutline` raises `FontFormatException`.
