diff --git a/pango/Gir.toml b/pango/Gir.toml index 33f2ec581793..2998e9d05da8 100644 --- a/pango/Gir.toml +++ b/pango/Gir.toml @@ -112,8 +112,17 @@ status = "generate" manual = true [[object.function]] name = "shape_with_flags" - # ivanlid length computation on a Option, it should fallback to 0. + # invalid length computation on a Option, it should fallback to 0. manual = true + [[object.function]] + name = "shape" + # invalid length computation on Stash instead of str + manual = true + [[object.function]] + name = "shape_item" + # invalid length computation on Stash instead of str + # Needs PangoLogAttr bindings + ignore = true [[object]] name = "Pango.Attribute" diff --git a/pango/src/auto/functions.rs b/pango/src/auto/functions.rs index 560e19db95a9..0f60a789d07b 100644 --- a/pango/src/auto/functions.rs +++ b/pango/src/auto/functions.rs @@ -3,8 +3,7 @@ // DO NOT EDIT use crate::{ - ffi, Analysis, AttrIterator, AttrList, Context, Direction, GlyphString, Item, Stretch, Style, - Variant, Weight, + ffi, AttrIterator, AttrList, Context, Direction, Item, Stretch, Style, Variant, Weight, }; use glib::translate::*; @@ -245,28 +244,6 @@ pub fn quantize_line_geometry(thickness: &mut i32, position: &mut i32) { } } -#[doc(alias = "pango_shape")] -pub fn shape(text: &str, analysis: &Analysis) -> GlyphString { - let length = text.len() as _; - unsafe { - let mut glyphs = GlyphString::uninitialized(); - ffi::pango_shape( - text.to_glib_none().0, - length, - analysis.to_glib_none().0, - glyphs.to_glib_none_mut().0, - ); - glyphs - } -} - -//#[cfg(feature = "v1_50")] -//#[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))] -//#[doc(alias = "pango_shape_item")] -//pub fn shape_item(item: &mut Item, paragraph_text: Option<&str>, log_attrs: /*Ignored*/Option<&mut LogAttr>, flags: ShapeFlags) -> GlyphString { -// unsafe { TODO: call ffi:pango_shape_item() } -//} - //#[cfg(feature = "v1_44")] //#[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))] //#[doc(alias = "pango_tailor_break")] diff --git a/pango/src/functions.rs b/pango/src/functions.rs index 77f1668bada1..9452a3515ffc 100644 --- a/pango/src/functions.rs +++ b/pango/src/functions.rs @@ -42,6 +42,21 @@ pub fn shape_full( } } +#[doc(alias = "pango_shape")] +pub fn shape(item_text: &str, analysis: &Analysis, glyphs: &mut GlyphString) { + let item_length = item_text.len() as i32; + unsafe { + // The function does not take null-terminated strings when a length is provided. + // Using to_glib_none() on &str will copy the string unnecessarily. + ffi::pango_shape( + item_text.as_ptr() as *const c_char, + item_length, + analysis.to_glib_none().0, + glyphs.to_glib_none_mut().0, + ); + } +} + #[cfg(feature = "v1_44")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))] #[doc(alias = "pango_shape_with_flags")]