Skip to content

Commit

Permalink
pango: Fix LayoutLine::x_ranges() bindings
Browse files Browse the repository at this point in the history
The returned array has 2*n_ranges elements, not just n_ranges.

Fixes #1563
  • Loading branch information
sdroege committed Nov 8, 2024
1 parent 056106e commit 96aa7b0
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 96aa7b0

Please sign in to comment.