saibatizoku/font8x8-rs

`GREEK_FONTS.get(chr)` incorrectly returns `None` for some characters

Closed this issue · 0 comments

If I take examples/unicode.rs and change the character being rendered to Omega (\u03a9) instead, no character is printed. This is despite GREEK_FONTS listing Omega as one of the characters.

Repro:

extern crate font8x8;
use font8x8::{UnicodeFonts, GREEK_FONTS};

fn main() {
    GREEK_FONTS.get('\u{03a9}').unwrap(); // panics!
}

I believe this is because GreekFonts.get_font uses a binary search, despite the font characters not being sorted by character code (they are sorted up through \u03a9, after which the next two characters are out of sequence). Binary search requires the array to be sorted in order to give correct results.