From 4c57614aad3f799f42cbb44cc7bc4267c1a7f7dd Mon Sep 17 00:00:00 2001 From: jackra1n Date: Tue, 21 Nov 2023 18:01:31 +0100 Subject: [PATCH] Trying to add pcsenior font to embedded graphics --- data/pcsenior.png | Bin 0 -> 2290 bytes data/pcsenior.raw | Bin 0 -> 2160 bytes src/display.rs | 26 ++++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 data/pcsenior.png create mode 100644 data/pcsenior.raw diff --git a/data/pcsenior.png b/data/pcsenior.png new file mode 100644 index 0000000000000000000000000000000000000000..58ee70228c70f27d48843ce726117fbe614a1921 GIT binary patch literal 2290 zcmVIIv2}l&t2$a=!m3F}+ zAB7M26S^+61uy0GxMZV^VXb|7l|nmh0%f(Snh)q;G4~vM@R8QKHXNKQU^|b+5K^IP zm-wdC;n;N5d_V__x#!peM_DE>=3v9JsY5ogn{bg_8!gvvRcRMI@*%jpZ?7?MbgsN? z@{mHexp<|}MRINK%d6RpDow*|-^?Cq?ePor2|XTnlLk$xzexyI$%DPT97B_C8fN=u z_9HM-?6V8D{fKZ1gQ@gQ_`xhk-ojl^Z<_r-HN|CNZo0wN&z7T87)+&a!VhLS@&?`W z{3cGafA<2P50CjfPxTwO{y+JCfzPJ?@IhXM7Lf_J?chrB6gap_En*ev&EKHg9`4yo zIjH)tjiO#g>$%5uJEY?*>{`yaeF{*y#v+?n2_tYhw$-d&3N(rzg-cLt8*oS+x9Ah?VmWHu zDW2kRphjREX^o5B5BH;R399xQ2A?*LFp?oo8q}!UC9pl^Io$H0Q_NZq@1f4r0IW5z zppy+vu)%i1A<3})2^_yVUq@)nPhLYCriKM2sYf=?Pf0i=DX?}l0+(a$R^4Cw$HqbRYQ=p?OG$n44$Y9B5(B=1CH|iBYrmT$eiuwn-QXRT<2kM(S^v^s18JJ`XOT z$ttPAbQ0PG3T>sH7?z_NCZ2?mP?e$2Ud{#5LZ{%N&>al^_W@Fu(BvSgQPjSm(5?g@ zE=M&C9KAT+L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5~YYr^ZCH}>dP7SeCtp|J5)57s8#+l>mizbN~PV M07*qoM6N<$g5B3_;{X5v literal 0 HcmV?d00001 diff --git a/data/pcsenior.raw b/data/pcsenior.raw new file mode 100644 index 0000000000000000000000000000000000000000..7407186287e9c78122822817b4d60517fdc563b2 GIT binary patch literal 2160 zcmb`IL9U}X5QYn}@MeTBkPg@Is;~2Qvj*`ZJDXt#H^>=gHDVQ6ngjF+8i81_126sb z(s=%YB%Rm&dNk^33nBBxDOdfjDii&p5!s?_c0{Q#Qka|3JqZV{tGzBwDs0}{^{0<_ zUX*4R-MM03FI}S2gfepJaa->;9ulu7<{@~Jo+3w)CDCYdhwhPE=5mRTb~X=o;MmGT z*@8buPWKi*@1$X`L=(hmFtqu@JfY40F4@EW78mp1-r>(1XG3pB_U7yVe(0ms!pYjF z(qjU1k|+}{j5Yw)UQ3S&LP&|8rSC^OR4T0~OB5#HYg}sRZERFgyN<3rlU|aVdz&8p zYwZJF?RaqGnMZCgDv;B{W8aP_HttJrGg6^b!_nebaKtMk3;tTEFm0Uufir1jUwZZ@ zt~T!2AL-$e#*U?vqtg)rwBQ^U=HGB}<=E)W_?mKW@K1k0=Wz5vE}{1W9Gg#zqGH}`6coA^xxPc0_`-NzUoS}4-IGC* zBNkLgF)_!{BR3ACiMy2x2YkNEqm z|Ba%=P_*cC(8@LE$fOJW7Cl5 z5x5PV{f=8S&)L`+H&p4N+qEu^%yHj^c|l#QynRKz)Zl&)-$Y literal 0 HcmV?d00001 diff --git a/src/display.rs b/src/display.rs index fec2670..38806b7 100644 --- a/src/display.rs +++ b/src/display.rs @@ -2,14 +2,15 @@ use linux_embedded_hal::I2cdev; use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306, mode::BufferedGraphicsMode}; use display_interface::DisplayError; use embedded_graphics::{ - mono_font::{ascii, MonoTextStyleBuilder, MonoTextStyle}, + image::ImageRaw, + mono_font::{ascii, MonoTextStyleBuilder, MonoFont, MonoTextStyle, DecorationDimensions, mapping::StrGlyphMapping}, pixelcolor::BinaryColor, prelude::*, text::Text }; use profont::PROFONT_12_POINT; -const PROFONT12: MonoTextStyle<'_, BinaryColor> = MonoTextStyleBuilder::new() +const OLD_PROFONT12: MonoTextStyle<'_, BinaryColor> = MonoTextStyleBuilder::new() .font(&PROFONT_12_POINT) .text_color(BinaryColor::On) .build(); @@ -24,6 +25,27 @@ const FONT_5X8: MonoTextStyle<'_, BinaryColor> = MonoTextStyleBuilder::new() .text_color(BinaryColor::On) .build(); +const GLYPH_MAPPING: StrGlyphMapping = StrGlyphMapping::new(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~°", '?' as usize - ' ' as usize); + +const PCSENIOR12: MonoFont = MonoFont { + image: ImageRaw::new( + include_bytes!("../data/pcsenior.raw"), + 192, + ), + character_size: Size::new(12, 15), + character_spacing: 0, + baseline: 11, + underline: DecorationDimensions::new(13, 1), + strikethrough: DecorationDimensions::new(15 / 2, 1), + glyph_mapping: &GLYPH_MAPPING, +}; + +const PROFONT12: MonoTextStyle<'_, BinaryColor> = MonoTextStyleBuilder::new() + .font(&PCSENIOR12) + .text_color(BinaryColor::On) + .build(); + + type Display = Ssd1306, DisplaySize128x32, BufferedGraphicsMode>; pub struct PoeDisplay {