A text renderer for Rust's embedded-graphics crate, based on U8g2

Overview

u8g2-fonts

Hello World text rendered by this crate

Crates.io Crates.io License Build Status docs.rs Coverage Status

This crate is a pure Rust reimplementation of the font subsystem of U8g2.

It is intended for the embedded-graphics ecosystem.

Licensing

While this crate is MIT / Apache-2.0 licensed, note that the fonts themselves are not.

For more information about the font licenses, read the license agreement of U8g2.

Example

let font = FontRenderer::new::<fonts::u8g2_font_haxrcorp4089_t_cyrillic>();
let text = "embedded-graphics";

font.render_aligned(
    text,
    display.bounding_box().center() + Point::new(0, 16),
    VerticalPosition::Baseline,
    HorizontalAlignment::Center,
    FontColor::Transparent(BinaryColor::On),
    &mut display,
)
.unwrap();

This example is based on the hello-world of the official embedded-graphics examples.

If we replace the text rendering section of the example with the code above, it produces this output:

Embedded-graphics example with our U8g2 font

Note that the letter i sits snuck in between the h and the c, compared to the original example. This is not a monospace font.

You might also like...
Ember is a minimalistic Rust library for creating 2D graphics, games, and interactive visualizations with ease and simplicity.
Ember is a minimalistic Rust library for creating 2D graphics, games, and interactive visualizations with ease and simplicity.

Ember Ember is a simple and fun 2D rendering library for Rust, allowing you to quickly create graphics and interactive applications with ease. It uses

Rust vs C: Software Graphics Challenge
Rust vs C: Software Graphics Challenge

Rust vs C: Reto de Gráficos por Software Aprende Rust y C programando gráficos por software con efectos de demoscene clásica de los años 80. Episodios

Text-based to-do management CLI & language server
Text-based to-do management CLI & language server

☑️ Todome (日本語版はこちら) Todome is a notation developed for making and editing to-do lists. It is inspired by Todo.txt, and in fact some of the todome not

Simple macros to write colored and formatted text to a terminal. Based on `termcolor`, thus also cross-platform.
Simple macros to write colored and formatted text to a terminal. Based on `termcolor`, thus also cross-platform.

Bunt: simple macro-based terminal colors and styles bunt offers macros to easily print colored and formatted text to a terminal. It is just a convenie

A library for building declarative text-based user interfaces
A library for building declarative text-based user interfaces

Intuitive docs.rs Documentation Intuitive is a component-based library for creating text-based user interfaces (TUIs) easily. It is heavily inspired b

Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

Source code for our paper
Source code for our paper "Higher-order finite elements for embedded simulation"

Higher-order Finite Elements for Embedded Simulation This repository contains the source code used to produce the results for our paper: Longva, A., L

A Rust command line tool to simplify embedded development and deployment.

Bobbin-CLI bobbin-cli is a tool designed to make it easy to build, deploy, test and debug embedded devices using a unified CLI. bobbin-cli understands

A plugin system for the Rhai embedded scripting language.

Rhai Dylib This crate exposes a simple API to load dylib Rust crates in a Rhai engine using Rhai modules. 🚧 This is a work in progress, the API is su

Comments
  • Use generate font file scripts from crate

    Use generate font file scripts from crate

    Is it possible to move the generate font file tool, such that it is usable from another rust project in order to automate the process of converting true type fonts (or anything convertible to bdf format) to this Rust representation?

    I make this request, as I were using the tool locally on my PC, but do not want to commit it into an Git project which is licensed completely different and the tool does not have any licensing information.

    opened by Rico1502 7
  • Optimize multiline args

    Optimize multiline args

    • Only compute horizontal bounding box where applicable
    • Only store necessary data in args line dimensions cache
    • Reduce cached lines to 5
    • Skip bounding box calculation of lines that won't get cached
    opened by Finomnis 0
  • Update base64 requirement from 0.13.0 to 0.20.0

    Update base64 requirement from 0.13.0 to 0.20.0

    Updates the requirements on base64 to permit the latest version.

    Changelog

    Sourced from base64's changelog.

    0.20.0

    Breaking changes

    • Update MSRV to 1.57.0
    • Decoding can now either ignore padding, require correct padding, or require no padding. The default is to require correct padding.
      • The NO_PAD config now requires that padding be absent when decoding.

    0.20.0-alpha.1

    Breaking changes

    • Extended the Config concept into the Engine abstraction, allowing the user to pick different encoding / decoding implementations.
      • What was formerly the only algorithm is now the FastPortable engine, so named because it's portable (works on any CPU) and relatively fast.
      • This opens the door to a portable constant-time implementation (#153, presumably ConstantTimePortable?) for security-sensitive applications that need side-channel resistance, and CPU-specific SIMD implementations for more speed.
      • Standard base64 per the RFC is available via DEFAULT_ENGINE. To use different alphabets or other settings (padding, etc), create your own engine instance.
    • CharacterSet is now Alphabet (per the RFC), and allows creating custom alphabets. The corresponding tables that were previously code-generated are now built dynamically.
    • Since there are already multiple breaking changes, various functions are renamed to be more consistent and discoverable.
    • MSRV is now 1.47.0 to allow various things to use const fn.
    • DecoderReader now owns its inner reader, and can expose it via into_inner(). For symmetry, EncoderWriter can do the same with its writer.
    • encoded_len is now public so you can size encode buffers precisely.

    0.13.1

    • More precise decode buffer sizing, avoiding unnecessary allocation in decode_config.

    0.13.0

    • Config methods are const
    • Added EncoderStringWriter to allow encoding directly to a String
    • EncoderWriter now owns its delegate writer rather than keeping a reference to it (though refs still work)
      • As a consequence, it is now possible to extract the delegate writer from an EncoderWriter via finish(), which returns Result<W> instead of Result<()>. If you were calling finish() explicitly, you will now need to use let _ = foo.finish() instead of just foo.finish() to avoid a warning about the unused value.
    • When decoding input that has both an invalid length and an invalid symbol as the last byte, InvalidByte will be emitted instead of InvalidLength to make the problem more obvious.

    0.12.2

    • Add BinHex alphabet

    0.12.1

    • Add Bcrypt alphabet

    0.12.0

    • A Read implementation (DecoderReader) to let users transparently decoded data from a b64 input source
    • IMAP's modified b64 alphabet
    • Relaxed type restrictions to just AsRef<[ut8]> for main encode*/decode* functions
    • A minor performance improvement in encoding

    0.11.0

    • Minimum rust version 1.34.0

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Releases(0.2.0)
  • 0.2.0(Sep 7, 2022)

    Breaking Changes

    • Move text rendered with HorizontalAlignment::Left left by one pixel.
      • Rendering with HorizontalAlignment::Left is now identical to rendering with render().
      • Matches the behaviour of embedded_graphics::text.

    Changes

    • Integration with embedded_graphics::text
      • New feature embedded_graphics_textstyle that enables it
      • Adds struct U8g2TextStyle that can be used as a character style for Text
    • Add new functions:
      • FontRenderer::with_ignore_unknown_chars()
      • FontRenderer::with_line_height()
      • FontRenderer::get_default_line_height()
    • Improve multiline rendering of format_args!():
      • Reduce memory consumption
      • Improve performance
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Aug 27, 2022)

    First official release!

    Changes

    • Remove InternalError error.
      • It shouldn't be the users problem if our fonts are broken. This error should never happen, therefore it shouldn't exist and be an assert instead.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0-alpha.1(Aug 26, 2022)

Owner
null
Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.

2D graphics in any programming language with just print statements!

Caleb Winston 123 Nov 20, 2022
12600+ icons pack for embedded graphics!

?? embedded-icon 12600+ ?? icons for embedded-graphics. ?? Features ?? Support to multiple icon packs - Easy to add support to! ?? Multiple resolution

Patrick José Pereira 3 Jul 24, 2023
Prisma2D - Fast, API agnostic, software only 2D graphics crate in pure Rust.

Prisma2D: Ultra-fast CPU 2D graphics Prisma2D is a blazingly fast, efficient yet minimal crate for basic 2D graphics on the CPU. for Rust. With Prisma

Aggelos Tselios 4 Nov 30, 2023
A Rust-based renderer for Remotion videos.

Rustymotion A Rust-based renderer for Remotion projects. ?? WARNING: This is exploratory work only, use at your own risk. Design Remotion allows you t

Siddharth 12 Oct 6, 2023
Revolutionize handheld gaming with adaptive game settings. Optimize graphics and gameplay experience based on real-time system metrics. Open-source project empowering developers to enhance games on portable devices

Welcome to the server-side application for the HarmonyLink project. This innovative software is developed with the Rust programming language and is ai

Jordon Brooks 5 Jun 28, 2023
An implementation of Piet's text interface using cosmic-text

piet-cosmic-text Implements piet's Text interface using the cosmic-text crate. License piet-cosmic-text is free software: you can redistribute it and/

John Nunley 7 Mar 12, 2023
Just a simple object renderer, written in under 500 lines using Rust.

All cargoes that the project runs are: bitflags: a crate for defining bitflag types cfg-if: a small macro crate for defining cfg-based - conditional c

null 3 May 4, 2023
A tiny software renderer written in Rust.

tiny-renderer 简单的软光栅化渲染器 基础数学库 Bresenham画线算法 Cohen-Sutherland线段裁剪算法 glTF模型加载 模型/视图/投影变换 背面剔除 视椎剔除 齐次空间裁剪 深度测试 Blinn–Phong着色模型 重心坐标插值 运行 bresenham画线算法

Night's Watch Games 9 May 29, 2023
Gauzilla: a 3D Gaussian Splatting renderer written in Rust for WebAssembly with lock-free multithreading

Gauzilla A 3D Gaussian Splatting (3DGS) renderer written in Rust for platform-agnostic WebAssembly (WASM) with lock-free multithreading. Uses WebGL an

Yoshi Sato 90 Jan 2, 2024
A rust crate for rendering large text to the terminal using font8x8 and ratatui.

tui-big-text tui-big-text is a rust crate that renders large pixel text as a ratatui widget using the glyphs from the font8x8 crate. Installation carg

Josh McKinney 7 Sep 7, 2023