-
-
Notifications
You must be signed in to change notification settings - Fork 24
Conversation
@RazrFalcon can you test if this works? |
Damn, you did it before me! You're too efficient! |
Neither do I. I'm still learning. How can I build this branch? |
Strange. I've tried this code: let attr_list = pango::AttrList::new();
let attr = pango::functions::attr_underline_new(pango::Underline::Single).unwrap();
attr_list.insert(&attr);
layout.set_attributes(Some(&attr_list)); and I got:
|
I was afraid of this: no to_glib_full for Boxed. |
Updated |
It works! |
Also a warning:
|
Don't worry about warnings in generated code. ;) |
@RazrFalcon can you link your current code, I try extract example from it. |
@GuillaumeGomez, @sdroege Please, check manual functions in |
@EPashkin I will try to create a minimal example tomorrow. Current code is from my project. |
@EPashkin: Unfortunately, there aren't many ways to avoid rust running the destructor once the variable goes out of scope. For me, it's good enough and the code is really easy to understand so there's no point (from my point of view) in trying to find something else for the moment. Good job. |
Cargo.toml [package]
name = "pango-test"
version = "0.1.0"
[dependencies.pango]
# git = "https://github.com/gtk-rs/pango"
# custom branch
path = "../pango"
[dependencies.pangocairo]
# git = "https://github.com/RazrFalcon/pangocairo-rs"
# with updated dependencies
path = "../pangocairo"
[dependencies.cairo-rs]
git = "https://github.com/gtk-rs/cairo"
features = ["png"] main.rs extern crate pango;
extern crate cairo;
extern crate pangocairo;
use std::fs;
use pango::LayoutExt;
use pangocairo::{PangoContextExt, CairoContextExt};
fn main() {
let s = cairo::ImageSurface::create(cairo::Format::ARgb32, 200, 200);
let cr = cairo::Context::new(&s);
cr.set_source_rgba(1.0, 1.0, 1.0, 1.0);
cr.paint();
let pc = cr.create_pango_context();
pc.set_resolution(300.0);
cr.update_pango_context(&pc);
let mut font = pango::FontDescription::new();
font.set_family("Verdana");
font.set_size(14 * pango::SCALE);
let layout = pango::Layout::new(&pc);
layout.set_font_description(Some(&font));
layout.set_text("Text", -1);
let attr_list = pango::AttrList::new();
let attr = pango::functions::attr_underline_new(pango::Underline::Single).unwrap();
attr_list.insert(attr);
layout.set_attributes(Some(&attr_list));
cr.move_to(10.0, 0.0);
cr.set_source_rgba(1.0, 0.0, 0.0, 1.0);
cr.update_pango_layout(&layout);
cr.show_pango_layout(&layout);
cr.pango_layout_path(&layout);
cr.stroke();
let mut buffer = fs::File::create("out.png").unwrap();
s.write_to_png(&mut buffer).unwrap();
} Hope it would help. |
@RazrFalcon Thanks, I tested getter/setters on it. |
@EPashkin You need pangocairo to draw text on something. I don't know is it possible to draw text using only pango. It's just a layout engine after all. |
@EPashkin Also |
You can use |
I want something like: Or |
Yes, I can do it in this PR. |
Good. |
Updated |
Seems this ready to merge |
I agree. Thanks! |
impl AttrList { | ||
pub fn change(&self, attr: Attribute) { | ||
unsafe { | ||
ffi::pango_attr_list_change(self.to_glib_none().0, attr.to_glib_none().0 as *mut _); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly why I'd like to have https://github.com/gtk-rs/glib/issues/176 :)
Looks good to me too |
Closes #83