Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Jan 7, 2025
1 parent ee6f9b0 commit 3a5ebf7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 91 deletions.
92 changes: 14 additions & 78 deletions Cargo.lock

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

7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ gtk4 = { version = "0.9.5", features = ["v4_6"] }
font-kit = "0.14.2"
cairo-rs = { version = "0.19.4", features = ["use_glib", "freetype"] }
pangocairo = "0.20.7"
harfbuzz_rs = "2.0.1"
harfbuzz-sys = "0.5.0"


#[patch.crates-io]
#cairo = { version = "0.0.4" }
freetype-rs = "0.36.0"
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Installing from a fresh new system: (ubuntu 22.04LTS)

### install main tools

```
sudo apt install git curl
```

### install rust

```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

you might need to restart your shell to get the correct paths. Check if `cargo` seems to work.

### install compilation tools

```
sudo apt install gcc g++ pkg-config
```


### install the project's dependencies

```
sudo apt install libglib2.0-0 libglib2.0-dev libpango1.0-dev libgdk-pixbuf2.0-dev libgtk-4-dev
```

### install the project

```
git clone https://github.com/gosub-io/poc-font-manager.git
cd poc-font-manager
```

### build the project binaries:

````
cargo build --workspace
````
14 changes: 7 additions & 7 deletions src/bin/generate-svg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use freetype::Face;
use cairo::freetype::Face;
use fontmanager::font_manager::{FontManager, FontStyle};

// const TEST_STRING1: &str = "A B C D E\n \u{EA84} a b c d e";
Expand Down Expand Up @@ -30,7 +30,7 @@ fn main() {
let manager = FontManager::new();

let info = manager.find(vec!["Nimbus Sans Narrow"], FontStyle::Normal);
let face = manager.load(info.unwrap()).unwrap();
let face = manager.load(&info.unwrap()).unwrap();
char_to_svg(face, TEST_STRING);
}

Expand All @@ -57,7 +57,7 @@ fn char_to_svg(face: Face, content: &str) {
continue;
}

face.load_char(c as usize, freetype::face::LoadFlag::NO_SCALE).unwrap();
face.load_char(c as usize, cairo::freetype::face::LoadFlag::NO_SCALE).unwrap();

let glyph = face.glyph();
let metrics = glyph.metrics();
Expand Down Expand Up @@ -94,13 +94,13 @@ fn char_to_svg(face: Face, content: &str) {
}


fn draw_curve(curve: freetype::outline::Curve) {
fn draw_curve(curve: cairo::freetype::outline::Curve) {
match curve {
freetype::outline::Curve::Line(pt) => println!("L {} {}", pt.x, -pt.y),
freetype::outline::Curve::Bezier2(pt1, pt2) => {
cairo::freetype::outline::Curve::Line(pt) => println!("L {} {}", pt.x, -pt.y),
cairo::freetype::outline::Curve::Bezier2(pt1, pt2) => {
println!("Q {} {} {} {}", pt1.x, -pt1.y, pt2.x, -pt2.y)
}
freetype::outline::Curve::Bezier3(pt1, pt2, pt3) => println!(
cairo::freetype::outline::Curve::Bezier3(pt1, pt2, pt3) => println!(
"C {} {} {} {} {} {}",
pt1.x, -pt1.y, pt2.x, -pt2.y, pt3.x, -pt3.y
),
Expand Down

0 comments on commit 3a5ebf7

Please sign in to comment.