Crate msdfgen_sys
source ·Expand description
Unsafe bindings to msdfgen
This crate provides generated unsafe Rust bindings to msdfgen C library.
Probably this isn’t that you really need. See safe bindings.
Structs
A single closed contour of a shape.
A cubic Bezier curve.
Container for a single edge of dynamic type.
An abstract edge segment.
The configuration of the MSDF error correction pass.
The configuration of the distance field generator algorithm.
A line segment.
The configuration of the multi-channel distance field generator algorithm.
A transformation from shape coordinates to pixel coordinates.
A quadratic Bezier curve.
Represents a horizontal scanline intersecting a shape.
An intersection with the scanline.
Vector shape representation.
Represents a signed distance and alignment, which together can be compared to uniquely determine the closest edge segment.
A 2-dimensional euclidean vector with double precision.
Implementation based on the Vector2 template from Artery Engine.
@author Viktor Chlumsky
Constants
Computes and compares the exact shape distance for each suspected artifact.
Only computes exact shape distance at edges. Provides a good balance between speed and precision.
Never computes exact shape distance.
Skips error correction pass.
Only corrects artifacts at edges.
Corrects artifacts at edges and other discontinuous distances only if it does not affect edges or corners.
Corrects all discontinuities of the distance field regardless if edges are adversely affected.
Statics
The default value of minDeviationRatio.
The default value of minImproveRatio.
Functions
Adds an edge to the contour.
Creates a new edge in the contour and returns its reference.
Adjusts the bounding box to fit the contour.
Adjusts the bounding box to fit the contour border’s mitered corners.
Reverses the sequence of edges on the contour.
Computes the winding of the contour. Returns 1 if positive, -1 if negative.
Swaps the edges held by a and b.
Converts a previously retrieved signed distance from origin to pseudo-distance.
Converts the shape coordinate to pixel coordinate.
Converts the vector to pixel coordinate space.
Converts the X-coordinate from shape to pixel coordinate space.
Converts the Y-coordinate from shape to pixel coordinate space.
Converts the pixel coordinate to shape coordinate.
Converts the vector from pixel coordinate space.
Converts the X-coordinate from pixel to shape coordinate space.
Converts the Y-coordinate from pixel to shape coordinate space.
Returns the number of intersections left of x.
Decides whether the scanline is filled at x based on fill rule.
Populates the intersection list.
Returns the total sign of intersections left of x.
Adds a contour.
Adds a blank contour and returns its reference.
Adjusts the bounding box to fit the shape.
Adjusts the bounding box to fit the shape border’s mitered corners.
Returns the total number of edge segments
Computes the minimum bounding box that fits the shape, optionally with a (mitered) border.
Normalizes the shape geometry for distance field generation.
Assumes its contours are unoriented (even-odd fill rule). Attempts to orient them to conform to the non-zero winding rule.
Outputs the scanline that intersects the shape at y.
Performs basic checks to determine if the object represents a valid shape.
Returns the angle of the vector in radians (atan2).
Returns a vector with the same length that is orthogonal to this one.
Returns a vector with unit length that is orthogonal to this one.
Returns the vector’s length.
Returns the normalized vector - one that has the same direction but unit length.
Returns a vector projected along this one.
Sets the vector to zero.
Sets individual elements of the vector.
Fixes the sign of the input signed distance field, so that it matches the shape’s rasterized fill.
The alternative coloring by distance tries to use different colors for edges that are close together.
This should theoretically be the best strategy on average. However, since it needs to compute the distance
between all pairs of edges, and perform a graph optimization task, it is much slower than the rest.
The alternative “ink trap” coloring strategy is designed for better results with typefaces
that use ink traps as a design feature. It guarantees that even if all edges that are shorter than
both their neighboring edges are removed, the coloring remains consistent with the established rules.
Assigns colors to edges of the shape in accordance to the multi-channel distance field technique.
May split some edges if necessary.
angleThreshold specifies the maximum angle (in radians) to be considered a corner, for example 3 (~172 degrees).
Values below 1/2 PI will be treated as the external angle.
Estimates the portion of the area that will be filled incorrectly when rendering using the SDF.
Generates a multi-channel signed distance field. Edge colors must be assigned first! (See edgeColoringSimple)
Generates a multi-channel signed distance field with true distance in the alpha channel. Edge colors must be assigned first.
Generates a single-channel signed pseudo-distance field.
Generates a conventional single-channel signed distance field.
Resolves the number of intersection into a binary fill value based on fill rule.
Predicts potential artifacts caused by the interpolation of the MSDF and corrects them by converting nearby texels to single-channel.
The original version of the error correction algorithm.
Applies the simplified error correction to all discontiunous distances (INDISCRIMINATE mode). Does not need shape or translation.
Applies the simplified error correction to edges only (EDGE_ONLY mode). Does not need shape or translation.
Rasterizes the shape into a monochrome bitmap.
Reconstructs the shape’s appearance into output from the distance field sdf.
Saves the bitmap as a BMP file.
Saves the bitmap as an uncompressed floating-point TIFF file.
Analytically constructs a scanline at y evaluating fill by linear interpolation of the SDF.
Snaps the values of the floating-point bitmaps into one of the 256 values representable in a standard 8-bit bitmap.
Type Definitions
Edge color specifies which color channels an edge belongs to.
Configuration of whether to use an algorithm that computes the exact shape distance at the positions of suspected artifacts. This algorithm can be much slower.
Mode of operation.
Fill rule dictates how intersection total is interpreted during rasterization.
A 2-dimensional euclidean vector with double precision.
Implementation based on the Vector2 template from Artery Engine.
@author Viktor Chlumsky