Expand description
Glyph mapping.
A glyph mapping defines the position of characters in a MonoFont
image. This module provides
predefined mappings for common glyph subsets, but custom mappings are also supported.
§Custom mappings
Custom mappings can be defined in three different ways:
- The
StrGlyphMapping
type can be used to specify a character mapping by encoding the mapping as a string. - The
GlyphMapping
trait is implemented for all functionsFn(char) -> usize
. - The
GlyphMapping
trait can be implemented by a custom type.
§StrGlyphMapping
encoding
Strings without a \0
character can be used to directly map a character to its position in
the mapping string:
use embedded_graphics::mono_font::mapping::{GlyphMapping, StrGlyphMapping};
let mapping = StrGlyphMapping::new("abcdef1234", 0);
assert_eq!(mapping.index('a'), 0);
assert_eq!(mapping.index('b'), 1);
assert_eq!(mapping.index('1'), 6);
assert_eq!(mapping.index('2'), 7);
This direct mapping is inefficient for mappings that map consecutive ranges of characters to
consecutive index ranges. To define a range of characters a \0
character followed by the
start and end characters of the inclusive range can be used. This way the mapping in the previous
example can be abbreviated to:
use embedded_graphics::mono_font::mapping::{GlyphMapping, StrGlyphMapping};
let mapping = StrGlyphMapping::new("\0af\014", 0);
assert_eq!(mapping.index('a'), 0);
assert_eq!(mapping.index('b'), 1);
assert_eq!(mapping.index('1'), 6);
assert_eq!(mapping.index('2'), 7);
Structs§
- StrGlyph
Mapping - Glyph mapping stored as a UTF-8 string.
Enums§
- Mapping
- Mapping.
Constants§
- ASCII
- ASCII.
- ISO_
8859_ 1 - ISO/IEC 8859 Part 1: Latin-1, Western European.
- ISO_
8859_ 2 - ISO/IEC 8859 Part 2: Latin-2, Central European.
- ISO_
8859_ 3 - ISO/IEC 8859 Part 3: Latin-3, South European.
- ISO_
8859_ 4 - ISO/IEC 8859 Part 4: Latin-4, North European.
- ISO_
8859_ 5 - ISO/IEC 8859 Part 5: Latin/Cyrillic.
- ISO_
8859_ 7 - ISO/IEC 8859 Part 7: Latin/Greek.
- ISO_
8859_ 9 - ISO/IEC 8859 Part 9: Latin-5, Turkish.
- ISO_
8859_ 10 - ISO/IEC 8859 Part 10: Latin-6, Nordic.
- ISO_
8859_ 13 - ISO/IEC 8859 Part 13: Latin-7, Baltic Rim.
- ISO_
8859_ 14 - ISO/IEC 8859 Part 14: Latin-8, Celtic.
- ISO_
8859_ 15 - ISO/IEC 8859 Part 15: Latin-9 (revised Latin-1).
- ISO_
8859_ 16 - ISO/IEC 8859 Part 16: Latin-10: South-East European.
- JIS_
X0201 - JIS X 0201: Japanese katakana (halfwidth).
Traits§
- Glyph
Mapping - Mapping from characters to glyph indices.