Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bdf-parser/src/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Glyph {
return None;
}

let bytes_per_row = (width + 7) / 8;
let bytes_per_row = width.div_ceil(8);
let byte_offset = x / 8;
let bit_mask = 0x80 >> (x % 8);

Expand Down
2 changes: 1 addition & 1 deletion bdf-parser/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Properties {
// Convert vector of properties into a HashMap
let properties = properties
.map(|p| p.iter().cloned().collect())
.unwrap_or_else(HashMap::new);
.unwrap_or_default();

Self { properties }
},
Expand Down
2 changes: 1 addition & 1 deletion eg-bdf-examples/examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use eg_bdf::{BdfGlyph, BdfTextStyle};
use eg_bdf::BdfTextStyle;
use embedded_graphics::{
mono_font::MonoTextStyle,
pixelcolor::Rgb888,
Expand Down
6 changes: 3 additions & 3 deletions eg-font-converter/src/eg_bdf_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl EgBdfOutput {
});

let comments = self.font.comments.iter().map(|comment| {
let comment = format!(" {}", comment);
let comment = format!(" {comment}");
quote!(
#[doc = #comment]
)
Expand Down Expand Up @@ -157,8 +157,8 @@ impl EgBdfOutput {
pub fn save<P: AsRef<Path>>(&self, output_directory: P) -> io::Result<()> {
let output_directory = output_directory.as_ref();

fs::write(self.font.rust_file_path(output_directory), &self.rust())?;
fs::write(self.font.data_file_path(output_directory), &self.data())?;
fs::write(self.font.rust_file_path(output_directory), self.rust())?;
fs::write(self.font.data_file_path(output_directory), self.data())?;

Ok(())
}
Expand Down
29 changes: 15 additions & 14 deletions eg-font-converter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
//! ```no_run
//! use eg_font_converter::{FontConverter, Mapping};
//!
//! fn main() {
//! let out_dir = std::env::var_os("OUT_DIR").unwrap();
//! let out_dir = std::env::var_os("OUT_DIR").unwrap();
//!
//! let font_6x10 = FontConverter::new("examples/6x10.bdf", "FONT_6X10_AZ")
//! .glyphs('A'..='Z')
//! .convert_mono_font()
//! .unwrap();
//! let font_6x10 = FontConverter::new("examples/6x10.bdf", "FONT_6X10_AZ")
//! .glyphs('A'..='Z')
//! .convert_mono_font()
//! .unwrap();
//!
//! font_6x10.save(&out_dir).unwrap();
//! }
//! font_6x10.save(&out_dir).unwrap();
//! ```
//!
//! And then use the [`include!`] macro to import the generated code into your project:
Expand Down Expand Up @@ -264,12 +262,13 @@ impl<'a> FontConverter<'a> {
let bdf = match &self.bdf {
FileOrData::File(file) => {
let data = std::fs::read(file)
.with_context(|| format!("couldn't read BDF file from {:?}", file))?;
.with_context(|| format!("couldn't read BDF file from {file:?}"))?;

ParserBdfFont::parse(&data).with_context(|| format!("couldn't parse BDF file"))?
ParserBdfFont::parse(&data)
.with_context(|| "couldn't parse BDF file".to_string())?
}
FileOrData::Data(data) => {
ParserBdfFont::parse(data).with_context(|| format!("couldn't parse BDF file"))?
ParserBdfFont::parse(data).with_context(|| "couldn't parse BDF file".to_string())?
}
};

Expand Down Expand Up @@ -439,7 +438,7 @@ impl Font {
}

fn data_file_path(&self, output_directory: &Path) -> PathBuf {
output_directory.join(&self.data_file())
output_directory.join(self.data_file())
}
}

Expand Down Expand Up @@ -518,8 +517,10 @@ pub enum Visibility {
PubIn(String),
}

impl ToString for Visibility {
fn to_string(&self) -> String {
impl Visibility {
// TODO: is Visibility even used anymore?
#[allow(unused)]
fn to_rust(&self) -> String {
match self {
Visibility::Private => "",
Visibility::Pub => "pub",
Expand Down
2 changes: 1 addition & 1 deletion eg-font-converter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn main() {
}

if let Err(e) = convert(&args) {
eprintln!("Error: {:#}", e);
eprintln!("Error: {e:#}");
std::process::exit(1);
}
}
8 changes: 4 additions & 4 deletions eg-font-converter/src/mono_font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl MonoFontOutput {

let glyphs_per_row = 16; //TODO: make configurable
let columns = glyphs_per_row; // TODO: allow smaller column count
let rows = (font.glyphs.len() + (glyphs_per_row - 1)) / glyphs_per_row;
let rows = font.glyphs.len().div_ceil(glyphs_per_row);

let character_size = bdf.bounding_box().size;
let character_spacing = 0;
Expand Down Expand Up @@ -149,7 +149,7 @@ impl MonoFontOutput {
};

let comments = self.font.comments.iter().map(|comment| {
let comment = format!(" {}", comment);
let comment = format!(" {comment}");
quote!(
#[doc = #comment]
)
Expand Down Expand Up @@ -193,8 +193,8 @@ impl MonoFontOutput {
pub fn save<P: AsRef<Path>>(&self, output_directory: P) -> io::Result<()> {
let output_directory = output_directory.as_ref();

fs::write(self.font.rust_file_path(output_directory), &self.rust())?;
fs::write(self.font.data_file_path(output_directory), &self.data())?;
fs::write(self.font.rust_file_path(output_directory), self.rust())?;
fs::write(self.font.data_file_path(output_directory), self.data())?;

Ok(())
}
Expand Down