Skip to content

Commit

Permalink
Merge pull request #1564 from sdroege/pango-layoutline-xranges
Browse files Browse the repository at this point in the history
pango: Fix `LayoutLine::x_ranges()` bindings
  • Loading branch information
sdroege authored Nov 5, 2024
2 parents 27de993 + 0028a7a commit cc97e01
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions pango/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ status = "generate"
[[object.function]]
name = "x_to_index"
manual = true
[[object.function]]
name = "get_x_ranges"
manual = true

[[object]]
name = "Pango.Matrix"
Expand Down
17 changes: 0 additions & 17 deletions pango/src/auto/layout_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,6 @@ impl LayoutLine {
unsafe { ffi::pango_layout_line_get_start_index(self.to_glib_none().0) }
}

#[doc(alias = "pango_layout_line_get_x_ranges")]
#[doc(alias = "get_x_ranges")]
pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32> {
unsafe {
let mut ranges = std::ptr::null_mut();
let mut n_ranges = std::mem::MaybeUninit::uninit();
ffi::pango_layout_line_get_x_ranges(
self.to_glib_none().0,
start_index,
end_index,
&mut ranges,
n_ranges.as_mut_ptr(),
);
FromGlibContainer::from_glib_full_num(ranges, n_ranges.assume_init() as _)
}
}

#[doc(alias = "pango_layout_line_index_to_x")]
pub fn index_to_x(&self, index_: i32, trailing: bool) -> i32 {
unsafe {
Expand Down
17 changes: 17 additions & 0 deletions pango/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,21 @@ impl LayoutLine {
is_inside,
}
}

#[doc(alias = "pango_layout_line_get_x_ranges")]
#[doc(alias = "get_x_ranges")]
pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32> {
unsafe {
let mut ranges = std::ptr::null_mut();
let mut n_ranges = std::mem::MaybeUninit::uninit();
ffi::pango_layout_line_get_x_ranges(
self.to_glib_none().0,
start_index,
end_index,
&mut ranges,
n_ranges.as_mut_ptr(),
);
FromGlibContainer::from_glib_full_num(ranges, 2 * n_ranges.assume_init() as usize)
}
}
}

0 comments on commit cc97e01

Please sign in to comment.