Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pango/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,17 @@ status = "generate"
manual = true
[[object.function]]
name = "shape_with_flags"
# ivanlid length computation on a Option<str>, it should fallback to 0.
# invalid length computation on a Option<str>, 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"
Expand Down
25 changes: 1 addition & 24 deletions pango/src/auto/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -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")]
Expand Down
15 changes: 15 additions & 0 deletions pango/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Loading