alexheretic / ab-glyph

Rust API for loading, scaling, positioning and rasterizing OpenType font glyphs
Apache License 2.0
372 stars 24 forks source link

How to get glyph advance_width and advance_height (by used for layout)? #12

Closed TakWolf closed 4 years ago

TakWolf commented 4 years ago

If layout horizontal and from left to right:

advance_height = px_scale_font.ascent() - px_scale_font.descent(); // advance_width = ?

image

image ref from https://github.com/alexheretic/ab-glyph/issues/6

alexheretic commented 4 years ago

You mean the h_advance?

alexheretic commented 4 years ago

A simple layout example similar to rusttype's example code is used for benchmarks: https://github.com/alexheretic/ab-glyph/blob/master/dev/src/layout.rs

There's also glyph_brush_layout for more advanced stuff.