mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
wallet: partially working emoji display
This commit is contained in:
@@ -450,8 +450,9 @@ def draw():
|
||||
False, False, 1, None, None, []
|
||||
)
|
||||
api.add_property(node_id, prop)
|
||||
api.set_property_str(node_id, "text", 0, "hihi 😁")
|
||||
#api.set_property_str(node_id, "text", 0, "hello! jelly 🍆")
|
||||
api.set_property_str(node_id, "text", 0, "hello! jelly")
|
||||
#api.set_property_str(node_id, "text", 0, "hello! jelly")
|
||||
|
||||
prop = Property(
|
||||
"color", PropertyType.FLOAT32, PropertySubType.COLOR,
|
||||
|
||||
@@ -33,9 +33,8 @@ def encode_varint(by, v):
|
||||
write_u64(by, v)
|
||||
|
||||
def encode_str(by, s):
|
||||
encode_varint(by, len(s))
|
||||
s_by = s.encode("utf-8")
|
||||
by += s_by
|
||||
data = s.encode("utf-8")
|
||||
encode_buf(by, data)
|
||||
|
||||
def encode_buf(by, buf):
|
||||
encode_varint(by, len(buf))
|
||||
|
||||
@@ -166,6 +166,7 @@ impl<'a> Stage<'a> {
|
||||
let (method_sender, method_recvr) = mpsc::sync_channel(100);
|
||||
|
||||
let font_data = include_bytes!("../Inter-Regular.otf") as &[u8];
|
||||
//let font_data = include_bytes!("../NotoColorEmoji.ttf") as &[u8];
|
||||
let ftlib = ft::Library::init().unwrap();
|
||||
let ft_face = ftlib.new_memory_face2(font_data, 0).unwrap();
|
||||
|
||||
@@ -648,6 +649,8 @@ impl<'a> RenderContext<'a> {
|
||||
self.ctx.apply_uniforms_from_bytes(uniforms_data.as_ptr(), uniforms_data.len());
|
||||
|
||||
self.ft_face.set_char_size(font_size as isize * 64, 0, 72, 72).unwrap();
|
||||
// emojis required a fixed size
|
||||
//self.ft_face.set_char_size(109 * 64, 0, 72, 72).unwrap();
|
||||
|
||||
let hb_font = harfbuzz_rs::Font::from_freetype_face(self.ft_face.clone());
|
||||
let buffer = harfbuzz_rs::UnicodeBuffer::new().add_str(&text);
|
||||
@@ -666,6 +669,8 @@ impl<'a> RenderContext<'a> {
|
||||
let glyph = self.ft_face.glyph();
|
||||
glyph.render_glyph(ft::RenderMode::Normal).unwrap();
|
||||
|
||||
// https://gist.github.com/jokertarot/7583938?permalink_comment_id=3327566#gistcomment-3327566
|
||||
|
||||
let bmp = glyph.bitmap();
|
||||
let buffer = bmp.buffer();
|
||||
let width = bmp.width();
|
||||
@@ -675,28 +680,43 @@ impl<'a> RenderContext<'a> {
|
||||
|
||||
//assert_eq!(bmp.pixel_mode().unwrap(), ft::bitmap::PixelMode::Bgra);
|
||||
//assert_eq!(bmp.pixel_mode().unwrap(), ft::bitmap::PixelMode::Lcd);
|
||||
assert_eq!(bmp.pixel_mode().unwrap(), ft::bitmap::PixelMode::Gray);
|
||||
//assert_eq!(bmp.pixel_mode().unwrap(), ft::bitmap::PixelMode::Gray);
|
||||
|
||||
//// Convert from BGRA to RGBA
|
||||
//for i in 0..(twidth*theight) {
|
||||
// let idx = i*4;
|
||||
// let b = tdata[idx];
|
||||
// let r = tdata[idx + 2];
|
||||
// tdata[idx] = r;
|
||||
// tdata[idx + 2] = b;
|
||||
//}
|
||||
// Add an alpha channel
|
||||
// Convert from greyscale to RGBA8
|
||||
let tdata: Vec<_> = buffer
|
||||
.iter()
|
||||
.flat_map(|coverage| {
|
||||
let r = (255. * color_r) as u8;
|
||||
let g = (255. * color_g) as u8;
|
||||
let b = (255. * color_b) as u8;
|
||||
let α = ((*coverage as f32) * color_a) as u8;
|
||||
vec![r, g, b, α]
|
||||
})
|
||||
.collect();
|
||||
let pixel_mode = bmp.pixel_mode().unwrap();
|
||||
let tdata = match pixel_mode {
|
||||
ft::bitmap::PixelMode::Bgra => {
|
||||
let mut tdata = vec![];
|
||||
tdata.resize((4 * width * height) as usize, 0);
|
||||
// Convert from BGRA to RGBA
|
||||
for i in 0..(width*height) as usize {
|
||||
let idx = i*4;
|
||||
let b = buffer[idx];
|
||||
let g = buffer[idx + 1];
|
||||
let r = buffer[idx + 2];
|
||||
let a = buffer[idx + 3];
|
||||
tdata[idx] = r;
|
||||
tdata[idx + 1] = g;
|
||||
tdata[idx + 2] = b;
|
||||
tdata[idx + 3] = a;
|
||||
}
|
||||
tdata
|
||||
}
|
||||
ft::bitmap::PixelMode::Gray => {
|
||||
// Convert from greyscale to RGBA8
|
||||
let tdata: Vec<_> = buffer
|
||||
.iter()
|
||||
.flat_map(|coverage| {
|
||||
let r = (255. * color_r) as u8;
|
||||
let g = (255. * color_g) as u8;
|
||||
let b = (255. * color_b) as u8;
|
||||
let α = ((*coverage as f32) * color_a) as u8;
|
||||
vec![r, g, b, α]
|
||||
})
|
||||
.collect();
|
||||
tdata
|
||||
}
|
||||
_ => panic!("unsupport pixel mode: {:?}", pixel_mode)
|
||||
};
|
||||
|
||||
let off_x = position.x_offset as f32 / 64.;
|
||||
let off_y = position.y_offset as f32 / 64.;
|
||||
|
||||
@@ -349,6 +349,16 @@ The more nodes users are required to run, the more difficult it will become to
|
||||
have a decentralized network, so we should find a way to reduce the burden for
|
||||
users to setup our infra.
|
||||
|
||||
### Usage Patterns
|
||||
|
||||
Wallets are clients talking to the node (remote).
|
||||
|
||||
* There's persistent nodes running some process to sync data from the network (darkfid downloading/verifying blockchain, event graph, ...)
|
||||
* There's scanning done by wallets on startup (check for recv'd payments, decrypt DMs, .etc)
|
||||
* Scanning downloads the updates from persistent nodes
|
||||
* Wallets can interact with nodes to push data to the network, or communicate with other nodes .etc
|
||||
* Wallet apps can talk with each other.
|
||||
|
||||
## References
|
||||
|
||||
* [Veil: Private Browsing Semantics Without Browser-side Assistance](https://mickens.seas.harvard.edu/files/mickens/files/veil.pdf)
|
||||
|
||||
Reference in New Issue
Block a user