servo / font-kit

A cross-platform font loading library written in Rust
Apache License 2.0
678 stars 100 forks source link

Readme example compile failed #167

Open oovm opened 3 years ago

oovm commented 3 years ago
use font_kit::{
    canvas::{Canvas, Format, RasterizationOptions},
    hinting::HintingOptions,
    source::SystemSource,
};

#[test]
fn main() {
    let font = SystemSource::new().select_by_postscript_name("ArialMT").unwrap().load().unwrap();

    let glyph_id = font.glyph_for_char('A').unwrap();
    let mut canvas = Canvas::new(&Size2D::new(32, 32), Format::A8);

    font.rasterize_glyph(
        &mut canvas,
        glyph_id,
        32.0,
        &Point2D::new(0.0, 32.0),
        HintingOptions::None,
        RasterizationOptions::GrayscaleAa,
    )
    .unwrap();
}

Size2D and Point2D is missing, while Transform2F and Vector2I does not reexported.

error[E0433]: failed to resolve: use of undeclared type or module `Size2D`
  --> projects\ascii-art-core\tests\main.rs:12:35
   |
12 |     let mut canvas = Canvas::new(&Size2D::new(32, 32), Format::A8);
   |                                   ^^^^^^ use of undeclared type or module `Size2D`

error[E0433]: failed to resolve: use of undeclared type or module `Point2D`
  --> projects\ascii-art-core\tests\main.rs:18:10
   |
18 |         &Point2D::new(0.0, 32.0),
   |          ^^^^^^^ use of undeclared type or module `Point2D`

error: aborting due to 2 previous errors
jdm commented 3 years ago

You're correct; the library should reexport Transform2F and Vector2I and the readme should use those instead.