Struct font_kit::loaders::freetype::Font [−][src]
pub struct Font { /* fields omitted */ }
Expand description
A cross-platform loader that uses the FreeType library to load and rasterize fonts.
On macOS and Windows, the Cargo feature loader-freetype-default
can be used to opt into this
loader by default.
Implementations
Loads a font from raw font data (the contents of a .ttf
/.otf
/etc. file).
If the data represents a collection (.ttc
/.otc
/etc.), font_index
specifies the index
of the font to load from it. If the data represents a single font, pass 0 for font_index
.
Loads a font from a .ttf
/.otf
/etc. file.
If the file is a collection (.ttc
/.otc
/etc.), font_index
specifies the index of the
font to load from it. If the file represents a single font, pass 0 for font_index
.
Loads a font from the path to a .ttf
/.otf
/etc. file.
If the file is a collection (.ttc
/.otc
/etc.), font_index
specifies the index of the
font to load from it. If the file represents a single font, pass 0 for font_index
.
Creates a font from a native API handle.
Loads the font pointed to by a handle.
Determines whether a blob of raw font data represents a supported font, and, if so, what type of font it is.
Determines whether a file represents a supported font, and, if so, what type of font it is.
Determines whether a path points to a supported font, and, if so, what type of font it is.
Returns the wrapped native font handle.
This function increments the reference count of the FreeType face before returning it.
Therefore, it is the caller’s responsibility to free it with FT_Done_Face
.
Returns the PostScript name of the font. This should be globally unique.
Returns the full name of the font (also known as “display name” on macOS).
Returns the name of the font family.
Returns true if and only if the font is monospace (fixed-width).
Returns the values of various font properties, corresponding to those defined in CSS.
Returns the usual glyph ID for a Unicode character.
Be careful with this function; typographically correct character-to-glyph mapping must be done using a shaper such as HarfBuzz. This function is only useful for best-effort simple use cases like “what does character X look like on its own”.
Returns the glyph ID for the specified glyph name.
Returns the number of glyphs in the font.
Glyph IDs range from 0 inclusive to this value exclusive.
pub fn outline<S>(
&self,
glyph_id: u32,
hinting: HintingOptions,
sink: &mut S
) -> Result<(), GlyphLoadingError> where
S: OutlineSink,
[src]
pub fn outline<S>(
&self,
glyph_id: u32,
hinting: HintingOptions,
sink: &mut S
) -> Result<(), GlyphLoadingError> where
S: OutlineSink,
[src]Sends the vector path for a glyph to a path builder.
If hinting_mode
is not None, this function performs grid-fitting as requested before
sending the hinding outlines to the builder.
TODO(pcwalton): What should we do for bitmap glyphs?
Returns the boundaries of a glyph in font units.
Returns the distance from the origin of the glyph with the given ID to the next, in font units.
Returns the amount that the given glyph should be displaced from the origin.
FIXME(pcwalton): This always returns zero on FreeType.
pub fn supports_hinting_options(
&self,
hinting_options: HintingOptions,
for_rasterization: bool
) -> bool
[src]
pub fn supports_hinting_options(
&self,
hinting_options: HintingOptions,
for_rasterization: bool
) -> bool
[src]Returns true if and only if the font loader can perform hinting in the requested way.
Some APIs support only rasterizing glyphs with hinting, not retriving hinted outlines. If
for_rasterization
is false, this function returns true if and only if the loader supports
retrieval of hinted outlines. If for_rasterization
is true, this function returns true
if and only if the loader supports rasterizing hinted glyphs.
pub fn raster_bounds(
&self,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
hinting_options: HintingOptions,
rasterization_options: RasterizationOptions
) -> Result<RectI, GlyphLoadingError>
[src]
pub fn raster_bounds(
&self,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
hinting_options: HintingOptions,
rasterization_options: RasterizationOptions
) -> Result<RectI, GlyphLoadingError>
[src]Returns the pixel boundaries that the glyph will take up when rendered using this loader’s rasterizer at the given size and origin.
pub fn rasterize_glyph(
&self,
canvas: &mut Canvas,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
hinting_options: HintingOptions,
rasterization_options: RasterizationOptions
) -> Result<(), GlyphLoadingError>
[src]
pub fn rasterize_glyph(
&self,
canvas: &mut Canvas,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
hinting_options: HintingOptions,
rasterization_options: RasterizationOptions
) -> Result<(), GlyphLoadingError>
[src]Rasterizes a glyph to a canvas with the given size and origin.
Format conversion will be performed if the canvas format does not match the rasterization options. For example, if bilevel (black and white) rendering is requested to an RGBA surface, this function will automatically convert the 1-bit raster image to the 32-bit format of the canvas. Note that this may result in a performance penalty, depending on the loader.
If hinting_options
is not None, the requested grid fitting is performed.
Returns a handle to this font, if possible.
This is useful if you want to open the font with a different loader.
Attempts to return the raw font data (contents of the font file).
If this font is a member of a collection, this function returns the data for the entire collection.
Returns the raw contents of the OpenType table with the given tag.
Tags are four-character codes. A list of tags can be found in the OpenType specification.
Trait Implementations
type NativeFont = NativeFont
type NativeFont = NativeFont
The handle that the API natively uses to represent a font.
Loads a font from raw font data (the contents of a .ttf
/.otf
/etc. file). Read more
Loads a font from a .ttf
/.otf
/etc. file. Read more
Determines whether a blob of raw font data represents a supported font, and, if so, what type of font it is. Read more
Determines whether a file represents a supported font, and, if so, what type of font it is.
Returns the wrapped native font handle.
Creates a font from a native API handle.
Returns the PostScript name of the font. This should be globally unique.
Returns the full name of the font (also known as “display name” on macOS).
Returns the name of the font family.
Returns true if and only if the font is monospace (fixed-width).
Returns the values of various font properties, corresponding to those defined in CSS.
Returns the usual glyph ID for a Unicode character. Read more
Returns the glyph ID for the specified glyph name.
Returns the number of glyphs in the font. Read more
fn outline<S>(
&self,
glyph_id: u32,
hinting_mode: HintingOptions,
sink: &mut S
) -> Result<(), GlyphLoadingError> where
S: OutlineSink,
[src]
fn outline<S>(
&self,
glyph_id: u32,
hinting_mode: HintingOptions,
sink: &mut S
) -> Result<(), GlyphLoadingError> where
S: OutlineSink,
[src]Sends the vector path for a glyph to a sink. Read more
Returns the boundaries of a glyph in font units. The origin of the coordinate space is at the bottom left. Read more
Returns the distance from the origin of the glyph with the given ID to the next, in font units. Read more
Returns the amount that the given glyph should be displaced from the origin.
Attempts to return the raw font data (contents of the font file). Read more
fn supports_hinting_options(
&self,
hinting_options: HintingOptions,
for_rasterization: bool
) -> bool
[src]
fn supports_hinting_options(
&self,
hinting_options: HintingOptions,
for_rasterization: bool
) -> bool
[src]Returns true if and only if the font loader can perform hinting in the requested way. Read more
fn rasterize_glyph(
&self,
canvas: &mut Canvas,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
hinting_options: HintingOptions,
rasterization_options: RasterizationOptions
) -> Result<(), GlyphLoadingError>
[src]
fn rasterize_glyph(
&self,
canvas: &mut Canvas,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
hinting_options: HintingOptions,
rasterization_options: RasterizationOptions
) -> Result<(), GlyphLoadingError>
[src]Rasterizes a glyph to a canvas with the given size and transform. Read more
Get font fallback results for the given text and locale. Read more
Returns the OpenType font table with the given tag, if the table exists.
Loads a font from the path to a .ttf
/.otf
/etc. file. Read more
Loads the font pointed to by a handle.
Determines whether a path points to a supported font, and, if so, what type of font it is.
fn raster_bounds(
&self,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
_: HintingOptions,
_: RasterizationOptions
) -> Result<RectI, GlyphLoadingError>
[src]
fn raster_bounds(
&self,
glyph_id: u32,
point_size: f32,
transform: Transform2F,
_: HintingOptions,
_: RasterizationOptions
) -> Result<RectI, GlyphLoadingError>
[src]Returns the pixel boundaries that the glyph will take up when rendered using this loader’s
rasterizer at the given point_size
and transform
. The origin of the coordinate space is
at the top left. Read more
Auto Trait Implementations
impl RefUnwindSafe for Font
impl UnwindSafe for Font
Blanket Implementations
Mutably borrows from an owned value. Read more