Returns the raw font data for `ch`. Each entry in the array corresponds to a row of pixels and is a bitmask indicating which pixels to turn on.
(&self, mut ch: char)
| 51 | /// Each entry in the array corresponds to a row of pixels and is a bitmask indicating which |
| 52 | /// pixels to turn on. |
| 53 | pub(crate) fn glyph(&self, mut ch: char) -> &'static [u8] { |
| 54 | if !(' '..='~').contains(&ch) { |
| 55 | // TODO(jmmv): Would be nicer to draw an empty box, much like how unknown Unicode |
| 56 | // characters are typically displayed. |
| 57 | ch = '?'; |
| 58 | } |
| 59 | let height = self.glyph_size.height * self.stride; |
| 60 | let offset = ((ch as usize) - (' ' as usize)) * height; |
| 61 | debug_assert!(offset < (self.data.len() + height)); |
| 62 | &self.data[offset..offset + height] |
| 63 | } |
| 64 | |
| 65 | /// Computes the number of characters that fit within the given pixels `area`. |
| 66 | pub fn chars_in_area(&self, area: SizeInPixels) -> CharsXY { |
no outgoing calls