Skip to content

Commit

Permalink
Fix error caused by font-kit 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloxaf committed Dec 10, 2019
1 parent 5d239a0 commit 9cccd13
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "silicon"
version = "0.2.6"
version = "0.3.0"
description = "Create beautiful image of your code"
authors = ["Aloxaf <[email protected]>"]
categories = ["command-line-utilities"]
Expand Down
8 changes: 2 additions & 6 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl FontCollection {
)
.unwrap();
let x = delta_x as i32 + raster_rect.origin.x;
let y = height as i32 - raster_rect.size.height - raster_rect.origin.y;
let y = height as i32 + raster_rect.origin.y;
delta_x += Self::get_glyph_width(font, id, imfont.size);

PositionedGlyph {
Expand Down Expand Up @@ -301,11 +301,7 @@ impl PositionedGlyph {
fn draw<O: FnMut(i32, i32, f32)>(&self, offset: i32, mut o: O) {
let mut canvas = Canvas::new(&self.raster_rect.size.to_u32(), Format::A8);

let origin = Point2D::new(
-self.raster_rect.origin.x,
self.raster_rect.size.height + self.raster_rect.origin.y,
)
.to_f32();
let origin = Point2D::new(-self.raster_rect.origin.x, -self.raster_rect.origin.y).to_f32();

// don't rasterize whitespace(https://github.com/pcwalton/font-kit/issues/7)
if canvas.size != Size2D::new(0, 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl ImageFormatter {
}
}

// TODO: &mut ?
// TODO: use &T instead of &mut T ?
pub fn format(&mut self, v: &[Vec<(Style, &str)>], theme: &Theme) -> DynamicImage {
if self.line_number {
self.line_number_chars = ((v.len() as f32).log10() + 1.0).floor() as u32;
Expand Down

0 comments on commit 9cccd13

Please sign in to comment.