#font #cell #glutin #scale #width

prototty_glutin

Prototty context for glutin windows

33 releases (19 breaking)

Uses old Rust 2015

0.27.0 Mar 30, 2019
0.25.0 Mar 1, 2019
0.20.1 Apr 5, 2018
0.19.1 Mar 9, 2018
Download history 37/week @ 2023-06-05 4/week @ 2023-06-12 49/week @ 2023-06-19 48/week @ 2023-06-26 29/week @ 2023-07-03 6/week @ 2023-07-10 8/week @ 2023-07-17 8/week @ 2023-07-24 5/week @ 2023-07-31 8/week @ 2023-08-07 42/week @ 2023-08-14 38/week @ 2023-08-21 16/week @ 2023-08-28 42/week @ 2023-09-04 51/week @ 2023-09-11 18/week @ 2023-09-18

160 downloads per month

MIT license

81KB
2K SLoC

prototty_glutin

Version Documentation

A prototty frontend for opengl which uses glutin for window creation and input. Provides a Context which can render a view to a window, and access inputs.

Example

Let's continue the title example started here:

extern crate prototty;
extern crate prototty_glutin;

// Assuming the title and its views were defined here
extern crate prototty_title;

use prototty::{Renderer, inputs};
use prototty_title::*;

fn main() {

    // Use a builder to configure how text should be rendered.
    // This assumes "Hack-Regular.ttf" is in your "src" directory.
    let mut context = prototty_glutin::ContextBuilder::new_with_font(
        include_bytes!("Hack-Regular.ttf"))
        .with_window_dimensions(320, 240)
        .with_font_scale(32.0, 32.0)
        .with_cell_dimensions(16, 32)
        .with_underline_position(28)
        .with_underline_width(2)
        .with_max_grid_size(30, 30)
        .build().unwrap();

    let title = Title {
        width: 20,
        text: "My Title".to_string(),
    };

    let mut running = true;
    while running {

        // render the title using the DemoTitleView
        context.render(&DemoTitleView, &title).unwrap();

        // exit after the window is closed
        context.poll_input(|input| {
            if input == inputs::ETX {
                running = false;
            }
        });
    }
}

Running this will produce the following output in a new window:

Example

Dependencies

~5–7.5MB
~137K SLoC