Skip to main content

Crate fcft

Crate fcft 

Source
Expand description

Bindings for fcft, a font library font loading, shaping and glyph rasterization using FontConfig, FreeType, Harfbuzz and pixman.

§Usage

use fcft::{Canvas, Color, Font, Subpixel};

let font = Font::new(&["Open Sans:pixelsize=28"], None).unwrap();
let run = font.shape("Hello world!", Subpixel::None);
let width = run.width();

let (w, h, stride) = (400usize, font.height() as usize, 400usize * 4);
let mut buf = vec![0u8; stride * h];
let mut canvas = Canvas::from_xrgb8888(&mut buf, w as u32, h as u32, stride as u32);
canvas.draw(&run, 0, font.ascent(), Color::from_argb8888(0xff000000));

§Locale

fcft uses wcwidth internally. Its behaviour varies depending on LC_CTYPE, which SHOULD be a UTF-8 locale. Applications SHOULD call setlocale(LC_CTYPE, "") with a UTF-8 locale.

Re-exports§

pub use fcft_sys as ffi;

Structs§

Canvas
XRGB8888 pixel buffer wrapped as a pixman image, for compositing text.
Capabilities
Optional fcft features; presence depends on how fcft was compiled.
Color
Colour without premultiplied 16-bit channels.
Decoration
Position and thickness of an underline or strikeout, relative to the baseline.
Error
Font instantiation failed. fcft reports the reason only through its own logging. See init to raise the log level.
Font
Font instance at a fixed size, with per-codepoint FontConfig fallback and internal glyph caching.
Glyph
Rasterised glyph, borrowed from the Font or TextRun that produced it.
ShapedGlyph
Glyph within a TextRun, paired with its effective pen advance.
TextRun
A shaped, rasterised line of text.

Enums§

GlyphFormat
Pixel format of a glyph image, determining how to composite it.
LogClass
Verbosity of fcft’s own log output (on stderr).
LogColorize
Colouring of fcft’s own log output.
Subpixel
Subpixel rendering mode, applied only when the font has antialiasing enabled.

Functions§

capabilities
Which optional features this fcft build provides.
init
Initialise fcft with explicit logging options.