From d306ef01d14e875f0a53e6a6aa00ae817a7c1105 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 10 Feb 2017 16:04:13 -0800 Subject: [PATCH] Complete the documentation --- examples/generate-atlas.rs | 1 - src/lib.rs | 31 +++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/examples/generate-atlas.rs b/examples/generate-atlas.rs index 6107b0ad..dc9c334d 100644 --- a/examples/generate-atlas.rs +++ b/examples/generate-atlas.rs @@ -75,7 +75,6 @@ fn main() { None => 0, }; - // FIXME(pcwalton) let (outlines, atlas); unsafe { let font = Font::from_collection_index(file.as_slice(), font_index).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 6956bcc1..bc8529bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,13 +36,40 @@ //! //! See `examples/generate-atlas.rs` for a simple example. //! -//! Typically, the steps to use Pathfidner are: +//! Typically, the steps to use Pathfinder are: //! //! 1. Create a `Rasterizer` object. This holds the OpenGL state. //! //! 2. Open the font from disk (or elsewhere), and call `Font::new()` (or //! `Font::from_collection_index` in the case of a `.ttc` or `.dfont` collection) to load it. -//! +//! +//! 3. If the text to be rendered is not already shaped, call +//! `Font::glyph_mapping_for_codepoint_ranges()` to determine the glyphs needed to render the +//! text, and call `shaper::shape_text()` to convert the text to glyph IDs. +//! +//! 4. Create an `OutlineBuilder` and call `OutlineBuilder::add_glyph()` on each glyph to parse +//! each outline from the font. Then upload the outlines to the GPU with +//! `OutlineBuilder::create_buffers()`. +//! +//! 5. Create an `AtlasBuilder` with a suitable width (1024 or 2048 is usually fine) and call +//! `AtlasBuilder::pack_glyph()` on each glyph you need to render. Then call +//! `AtlasBuilder::create_atlas()` to upload the atlas buffer to the GPU. +//! +//! 6. Make a `CoverageBuffer` of an appropriate size (1024 or 2048 pixels on each side is +//! typically reasonable). +//! +//! 7. Create an image to render the atlas to with `Rasterizer::device().create_image()`. The +//! format should be `R8` and the buffer should be created read-write. +//! +//! 8. Draw the glyphs with `Rasterizer::draw_atlas()`. +//! +//! Don't forget to flush the queue (`Rasterizer::queue().flush()`) and/or perform appropriate +//! synchronization (`glMemoryBarrier()`) as necessary. +//! +//! ## Hardware requirements +//! +//! Pathfinder requires at least OpenGL 3.3 and either OpenGL 4.3 compute shader or OpenCL 1.2. +//! Intel GPUs in Sandy Bridge processors or later should be OK. #![cfg_attr(test, feature(test))]