Documentation ¶
Index ¶
- func IntegerBounds(min, max Point) image.Rectangle
- func MakeScale(sx, sy float64) f64.Aff3
- func MakeTranslate(tx, ty float64) f64.Aff3
- func PointToImageCeil(p Point) image.Point
- func PointToImageExact(p Point) image.Point
- func PointToImageFloor(p Point) image.Point
- func TransformInverse(A f64.Aff3) f64.Aff3
- func TransformMultiply(L, R f64.Aff3) f64.Aff3
- type Component
- type Contour
- type ContourPoint
- type Outline
- type Outliner
- type Point
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntegerBounds ¶
Bound (float64) min and max Point to (integer) image.Rectangle
func PointToImageCeil ¶
Convert to an image.Point, rounding using ceil.
func PointToImageExact ¶
Convert to an image.Point, fatal if the conversion cannot be made exactly. :todo: change to propagate error to caller.
func PointToImageFloor ¶
Convert to an image.Point, rounding using floor when an exact conversion cannot be made. This and the following PointToImageCeil are intended for min/max bounds conversions.
func TransformInverse ¶
Return the result U where U A == identify Mostly following https://math.stackexchange.com/questions/397111/how-to-find-3-x-3-matrix-inverses
Types ¶
type Component ¶
type Component struct { // Both GlyphIndex and Base are ways to refer to // the component, but only one should be used. // When building from SVG, Base is used first (glyphs // have no glyph index number), then compiled as a number. // When building from TTF or similar, only GlyphIndex is used. GlyphIndex int Base string // The affine transformation. // By (obscure) convention Aff3 is a 3x3 matrix in // row-major order, where the bottom [0 0 1] row is implicit. M f64.Aff3 }
A component of a composite glyph. This is a model of a _reference_ to a component. The outlines of the component have to be fetched separately.
func MakeComponentAtXY ¶
func (*Component) TransformBounds ¶
Transform a bounding rectangle (by the component's transform).
type Contour ¶
type Contour struct { P []ContourPoint // In UFO a contour can have a unique identifier; // in COFF a name. Name string }
Models a single contour in a glyph.
func ContoursTTAdjust ¶
When contours are intended for a TrueType target: Adjust the contours to the integer grid. The returned contours are completely fresh. :todo: a later version will cleverly compute implicit points that may lie on the half-grid.
func ContoursTransform ¶
Transform all the points of all the contours in the slice by the specified transformation. The returned contours are completely fresh.
func ExpandImplicitTTContours ¶
When contours have been sourced from TrueType: Expand the contours by adding the implicit on-curve points. In TrueType outline fonts, the low-level point representation allows a space-saving optimisation where an on-curve point can be eliminated when it is exactly between two off-curve points. The existence of these implicit points can be inferred from two-adjacent off-curve points. This function adds them back in.
type ContourPoint ¶
Although in TrueType all points are given in integer coordinates, implicit on-curve points are exactly halfway between their neighbours, introducing the possibility that those points can have fractional (.5) coordinates. Which is why we use float. Also, CFF support 16.16 fixed point (a slightly obscure fact).
type Outline ¶
Model a glyph in outline format. An Outline is _simple_ when components is empty. An Outline is _composite_ when components is non-empty. A composite Outline has no contours (at least when sourced from TrueType). A simple Outline _may_ have no contours, and this is usual for the space glyphs.
func (*Outline) Bounds ¶
Somewhat crude bounds. It includes the off-curve control points in the bounds, making it possibly conservative. Though for the conventional contour descriptions for fonts it will make no difference, because such descriptions routinely include the cardinal extremal points.
func (*Outline) Close ¶
Close each contour by ensuring that the end point is the same as the start point. The outline is both mutated and returned.
type Point ¶
type Point struct {
X, Y float64
}
a 2D point in floating point coordinates.
func ContoursBounds ¶
Return bounds as (floating point) min (bottom left) and max (top right) points.