Bladeren bron

wallet: cleanup FFI mess for font stuff

darkfi 2 jaren geleden
bovenliggende
commit
5b8b609797
5 gewijzigde bestanden met toevoegingen van 34 en 21 verwijderingen
  1. 8 17
      bin/darkwallet/Cargo.toml
  2. 1 1
      bin/darkwallet/Makefile
  3. 2 2
      bin/darkwallet/src/app.rs
  4. 22 0
      bin/darkwallet/src/main.rs
  5. 1 1
      bin/darkwallet/src/ui/text.rs

+ 8 - 17
bin/darkwallet/Cargo.toml

@@ -8,26 +8,18 @@ edition = "2021"
 [workspace]
 
 [dependencies]
-#miniquad = "0.4.0-alpha"
-#miniquad = { git = "https://github.com/not-fl3/miniquad" }
-miniquad = { git = "https://github.com/narodnik/miniquad.git" }
-#harfbuzz_rs = { git = "https://github.com/narodnik/harfbuzz_rs.git", features = ["freetype"] }
+miniquad = { git = "https://github.com/not-fl3/miniquad" }
+#harfbuzz = "0.6.0"
 harfbuzz_rs = { git = "https://github.com/narodnik/hbrs2.git", features = ["freetype"] }
-freetype-rs = { git = "https://github.com/narodnik/freetype-rs.git" }
-#harfbuzz = { version = "0.6.0", features = ["bundled"] }
-#harfbuzz_rs = "2.0.1"
-#freetype-rs = "0.36.0"
-freetype-sys = "0.20.1"
+freetype-rs = { version = "0.37", features = ["bundled"] }
 image = "0.25.1"
 log = "0.4.21"
 glam = "0.27.0"
 #zmq = "0.10.0"
 #async_zmq = "0.4.0"
 zeromq = { version = "*", default-features = false, features = ["async-std-runtime", "all-transport"] }
-#darkfi-serial = { path = "../../src/serial" }
-darkfi-serial = { git = "https://codeberg.org/darkrenaissance/darkfi.git" }
+darkfi-serial = { git = "https://codeberg.org/darkrenaissance/darkfi" }
 thiserror = "1.0.61"
-# Only for async Mutex
 smol = "2.0.0"
 atomic_float = "1.0.0"
 async-channel = "2.3.1"
@@ -37,14 +29,11 @@ async-lock = "3.4.0"
 futures = "0.3.30"
 async-recursion = "1.1.1"
 colored = "2.1.0"
-
 #rustpython-vm = "0.3.1"
 
-#[patch."https://github.com/narodnik/harfbuzz_rs.git"]
-#freetype-rs = { path = "/tmp/freetype-rs/" }
-
 [patch.crates-io]
-freetype-rs = { git = "https://github.com/narodnik/freetype-rs.git" }
+freetype-rs = { git = "https://github.com/narodnik/freetype-rs" }
+freetype-sys = { git = "https://github.com/narodnik/freetype-sys" }
 
 [target.'cfg(target_os = "android")'.dependencies]
 android_logger = "0.13.3"
@@ -64,6 +53,8 @@ workspace = true
 [package.metadata.android]
 package_name = "darkfi.darkwallet"
 label = "DarkWallet"
+res = "res"
+icon = "@mipmap/ic_launcher"
 
 [[package.metadata.android.permission]]
 name = "android.permission.INTERNET"

+ 1 - 1
bin/darkwallet/Makefile

@@ -2,7 +2,7 @@ default:
 	cargo lrun
 
 android:
-	docker run -v $(shell pwd):/root/dw -v /tmp/miniquad:/tmp/miniquad -w /root/dw -t apk cargo quad-apk build
+	docker run -v $(shell pwd):/root/dw -w /root/dw -t apk cargo quad-apk build
 	adb uninstall darkfi.darkwallet
 	adb install target/android-artifacts/debug/apk/darkwallet.apk
 	reset

+ 2 - 2
bin/darkwallet/src/app.rs

@@ -295,8 +295,8 @@ impl App {
         prop.set_f32(3, 200.).unwrap();
         node.set_property_f32("baseline", 40.).unwrap();
         node.set_property_f32("font_size", 60.).unwrap();
-        //node.set_property_str("text", "anon1🍆").unwrap();
-        node.set_property_str("text", "anon1").unwrap();
+        node.set_property_str("text", "anon1🍆").unwrap();
+        //node.set_property_str("text", "anon1").unwrap();
         let prop = node.get_property("color").unwrap();
         prop.set_f32(0, 0.).unwrap();
         prop.set_f32(1, 1.).unwrap();

+ 22 - 0
bin/darkwallet/src/main.rs

@@ -67,6 +67,28 @@ fn main() {
         simplelog::CombinedLogger::init(vec![term_logger]).expect("logger");
     }
 
+    {
+        use freetype as ft;
+
+        let ftlib = ft::Library::init().unwrap();
+        let font_data = include_bytes!("../NotoColorEmoji.ttf") as &[u8];
+        let face = ftlib.new_memory_face2(font_data, 0).unwrap();
+        assert!(face.has_fixed_sizes());
+        face.select_size(0).unwrap();
+
+        let mut flags = ft::face::LoadFlag::DEFAULT;
+        if face.has_color() {
+            flags |= ft::face::LoadFlag::COLOR;
+        }
+
+        let glyph_id = 657;
+        // FIXME: glyph 884 hangs on android
+        // For now just avoid using emojis on android
+        debug!("load_glyph {}", glyph_id);
+        face.load_glyph(glyph_id, flags).unwrap();
+        debug!("load_glyph {} [done]", glyph_id);
+    }
+
     let ex = Arc::new(smol::Executor::new());
     let sg = Arc::new(Mutex::new(SceneGraph::new()));
 

+ 1 - 1
bin/darkwallet/src/ui/text.rs

@@ -82,7 +82,7 @@ impl Text {
         let mut mesh = MeshBuilder::new();
         let mut glyph_pos_iter = GlyphPositionIter::new(font_size_val, &glyphs, baseline_y);
         for (uv_rect, glyph_rect) in atlas.uv_rects.into_iter().zip(glyph_pos_iter) {
-            mesh.draw_outline(&glyph_rect, COLOR_BLUE, 2.);
+            //mesh.draw_outline(&glyph_rect, COLOR_BLUE, 2.);
             mesh.draw_box(&glyph_rect, COLOR_WHITE, &uv_rect);
         }