PangoCairo bindings for Rust.
MIT
DEPRECATED, use https://github.com/gtk-rs/gtk-rs-core repository instead!
License: MIT License
PangoCairo bindings for Rust.
MIT
Pangocairo show_layout
function gives the following error during runtime:
Pango-CRITICAL **: 18:11:02.823: pango_font_description_set_size: assertion 'size >= 0' failed
Code used:
...
let (width, height) = (1000, 1000);
let surface = ImageSurface::create(Format::ARgb32, width, height).expect("Can't create surface");
let cr = Context::new(&surface);
let mut fontdescription = pango::FontDescription::from_string("Sans");
fontdescription.set_size(16 * pango::SCALE);
let pangolayout = pangocairo::functions::create_layout(&cr).unwrap();
pangolayout.set_font_description(Some(&fontdescription));
pangolayout.set_text("the quick brown fox jumps over the lazy dog");
pangocairo::functions::show_layout(&cr, &pangolayout);
The exact C equivalent that does not produce the error:
...
PangoLayout *layout;
PangoFontDescription *desc;
layout = pango_cairo_create_layout (cr);
desc = pango_font_description_from_string ("Sans");
pango_font_description_set_size(desc, 16 * PANGO_SCALE);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text(layout, "the quick brown fox jumps over the lazy dog", -1);
pango_font_description_free(desc);
pango_cairo_show_layout(cr, layout);
I might just be doing this wrong, but I would like to clear the default font_map so that it can be reimported next time it is needed and pick up any new fonts that have been added. I see that I can set a new font_map with set_default, but it expects a font_map reference as input. See here:
https://github.com/gtk-rs/pangocairo/blob/master/src/auto/font_map.rs#L42
I'm new to rust, so I might be missing some way of getting it to work with the current code by casting ptr.null_mut() to a font_map. Seems very un-rusty. Would it be possible to allow this? Either by modifying set_default, or, maybe better, by adding a clear_default() method.
hey ๐
I'm trying to use https://github.com/servo/rust-fontconfig with pangocairo. I use pangocairo::FontMap::new_for_font_type(cairo::FontType::FontTypeFt)
to create a new PangoCairoFcFontMap
. And I need to use some functions from this interface, but no rust wrappers exist atm.
What's the best way to get them exposed? I am interested in this method specifically - https://github.com/GNOME/pango/blob/master/pango/pangofc-fontmap.c#L1928
I didn't check what exactly the problem is but calling pangocairo::FontMap::get_default()
from multiple threads at once seems to sometimes cause interesting crashes, probably due to initialization (maybe even one-time initialization) inside pangocairo not being thread-safe.
I don't know if the same applies to functions of pango itself too.
Just filing this now so I don't forget, it's a known problem with pango/pangocairo but I don't have the time to collect the details now.
When trying to combine this crate with e.g. https://github.com/sdroege/gobject-subclass, you get conflicts for the -sys
crates since in this one, you're specifying actual versions, unlike the other crates from gtk-rs.
error[E0432]: unresolved import `pangocairo::CairoContextExt`
error[E0432]: unresolved import `pangocairo::PangoContextExt`
error[E0599]: no method named `create_pango_context` found for type `&cairo::Context` in the current scope
error[E0599]: no method named `update_pango_context` found for type `&cairo::Context` in the current scope
error[E0599]: no method named `update_pango_layout` found for type `&cairo::Context` in the current scope
error[E0599]: no method named `show_pango_layout` found for type `&cairo::Context` in the current scope
error[E0599]: no method named `pango_layout_path` found for type `&cairo::Context` in the current scope
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.