pangocairo/auto/functions.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::{prelude::*, translate::*};
7
8/// Gets the resolution for the context.
9///
10/// See [`context_set_resolution()`][crate::context_set_resolution()]
11/// ## `context`
12/// a [`pango::Context`][crate::pango::Context], from a pangocairo font map
13///
14/// # Returns
15///
16/// the resolution in "dots per inch". A negative value will
17/// be returned if no resolution has previously been set.
18#[doc(alias = "pango_cairo_context_get_resolution")]
19pub fn context_get_resolution(context: &pango::Context) -> f64 {
20 unsafe { ffi::pango_cairo_context_get_resolution(context.to_glib_none().0) }
21}
22
23//#[doc(alias = "pango_cairo_context_get_shape_renderer")]
24//pub fn context_get_shape_renderer(context: &pango::Context, data: /*Unimplemented*/Option<Basic: Pointer>) -> /*Unimplemented*/Fn(&cairo::Context, /*Ignored*/pango::AttrShape, bool) {
25// unsafe { TODO: call ffi:pango_cairo_context_get_shape_renderer() }
26//}
27
28/// Sets the font options used when rendering text with this context.
29///
30/// These options override any options that [`update_context()`][crate::update_context()]
31/// derives from the target surface.
32/// ## `context`
33/// a [`pango::Context`][crate::pango::Context], from a pangocairo font map
34/// ## `options`
35/// a [`cairo::FontOptions`][crate::cairo::FontOptions], or [`None`] to unset
36/// any previously set options. A copy is made.
37#[doc(alias = "pango_cairo_context_set_font_options")]
38pub fn context_set_font_options(context: &pango::Context, options: Option<&cairo::FontOptions>) {
39 unsafe {
40 ffi::pango_cairo_context_set_font_options(
41 context.to_glib_none().0,
42 options.to_glib_none().0,
43 );
44 }
45}
46
47/// Sets the resolution for the context.
48///
49/// This is a scale factor between points specified in a `PangoFontDescription`
50/// and Cairo units. The default value is 96, meaning that a 10 point font will
51/// be 13 units high. (10 * 96. / 72. = 13.3).
52/// ## `context`
53/// a [`pango::Context`][crate::pango::Context], from a pangocairo font map
54/// ## `dpi`
55/// the resolution in "dots per inch". (Physical inches aren't actually
56/// involved; the terminology is conventional.) A 0 or negative value
57/// means to use the resolution from the font map.
58#[doc(alias = "pango_cairo_context_set_resolution")]
59pub fn context_set_resolution(context: &pango::Context, dpi: f64) {
60 unsafe {
61 ffi::pango_cairo_context_set_resolution(context.to_glib_none().0, dpi);
62 }
63}
64
65//#[doc(alias = "pango_cairo_context_set_shape_renderer")]
66//pub fn context_set_shape_renderer(context: &pango::Context, func: /*Unimplemented*/Fn(&cairo::Context, /*Ignored*/pango::AttrShape, bool), data: /*Unimplemented*/Option<Basic: Pointer>) {
67// unsafe { TODO: call ffi:pango_cairo_context_set_shape_renderer() }
68//}
69
70/// Creates a context object set up to match the current transformation
71/// and target surface of the Cairo context.
72///
73/// This context can then be
74/// used to create a layout using [`pango::Layout::new()`][crate::pango::Layout::new()].
75///
76/// This function is a convenience function that creates a context using
77/// the default font map, then updates it to @cr. If you just need to
78/// create a layout for use with @cr and do not need to access [`pango::Context`][crate::pango::Context]
79/// directly, you can use [`create_layout()`][crate::create_layout()] instead.
80/// ## `cr`
81/// a Cairo context
82///
83/// # Returns
84///
85/// the newly created [`pango::Context`][crate::pango::Context]
86#[doc(alias = "pango_cairo_create_context")]
87pub fn create_context(cr: &cairo::Context) -> pango::Context {
88 unsafe {
89 from_glib_full(ffi::pango_cairo_create_context(mut_override(
90 cr.to_glib_none().0,
91 )))
92 }
93}
94
95/// Creates a layout object set up to match the current transformation
96/// and target surface of the Cairo context.
97///
98/// This layout can then be used for text measurement with functions
99/// like [`Layout::size()`][crate::pango::Layout::size()] or drawing with functions like
100/// [`show_layout()`][crate::show_layout()]. If you change the transformation or target
101/// surface for @cr, you need to call [`update_layout()`][crate::update_layout()].
102///
103/// This function is the most convenient way to use Cairo with Pango,
104/// however it is slightly inefficient since it creates a separate
105/// [`pango::Context`][crate::pango::Context] object for each layout. This might matter in an
106/// application that was laying out large amounts of text.
107/// ## `cr`
108/// a Cairo context
109///
110/// # Returns
111///
112/// the newly created [`pango::Layout`][crate::pango::Layout]
113#[doc(alias = "pango_cairo_create_layout")]
114pub fn create_layout(cr: &cairo::Context) -> pango::Layout {
115 unsafe {
116 from_glib_full(ffi::pango_cairo_create_layout(mut_override(
117 cr.to_glib_none().0,
118 )))
119 }
120}
121
122/// Add a squiggly line to the current path in the specified cairo context that
123/// approximately covers the given rectangle in the style of an underline used
124/// to indicate a spelling error.
125///
126/// The width of the underline is rounded to an integer number of up/down
127/// segments and the resulting rectangle is centered in the original rectangle.
128/// ## `cr`
129/// a Cairo context
130/// ## `x`
131/// The X coordinate of one corner of the rectangle
132/// ## `y`
133/// The Y coordinate of one corner of the rectangle
134/// ## `width`
135/// Non-negative width of the rectangle
136/// ## `height`
137/// Non-negative height of the rectangle
138#[doc(alias = "pango_cairo_error_underline_path")]
139pub fn error_underline_path(cr: &cairo::Context, x: f64, y: f64, width: f64, height: f64) {
140 unsafe {
141 ffi::pango_cairo_error_underline_path(
142 mut_override(cr.to_glib_none().0),
143 x,
144 y,
145 width,
146 height,
147 );
148 }
149}
150
151/// Adds the glyphs in @glyphs to the current path in the specified
152/// cairo context.
153///
154/// The origin of the glyphs (the left edge of the baseline)
155/// will be at the current point of the cairo context.
156/// ## `cr`
157/// a Cairo context
158/// ## `font`
159/// a [`pango::Font`][crate::pango::Font] from a [`FontMap`][crate::FontMap]
160/// ## `glyphs`
161/// a [`pango::GlyphString`][crate::pango::GlyphString]
162#[doc(alias = "pango_cairo_glyph_string_path")]
163pub fn glyph_string_path(
164 cr: &cairo::Context,
165 font: &impl IsA<pango::Font>,
166 glyphs: &mut pango::GlyphString,
167) {
168 unsafe {
169 ffi::pango_cairo_glyph_string_path(
170 mut_override(cr.to_glib_none().0),
171 font.as_ref().to_glib_none().0,
172 glyphs.to_glib_none_mut().0,
173 );
174 }
175}
176
177/// Adds the text in [`pango::LayoutLine`][crate::pango::LayoutLine] to the current path in the
178/// specified cairo context.
179///
180/// The origin of the glyphs (the left edge of the line) will be
181/// at the current point of the cairo context.
182/// ## `cr`
183/// a Cairo context
184/// ## `line`
185/// a [`pango::LayoutLine`][crate::pango::LayoutLine]
186#[doc(alias = "pango_cairo_layout_line_path")]
187pub fn layout_line_path(cr: &cairo::Context, line: &pango::LayoutLine) {
188 unsafe {
189 ffi::pango_cairo_layout_line_path(mut_override(cr.to_glib_none().0), line.to_glib_none().0);
190 }
191}
192
193/// Adds the text in a [`pango::Layout`][crate::pango::Layout] to the current path in the
194/// specified cairo context.
195///
196/// The top-left corner of the [`pango::Layout`][crate::pango::Layout] will be at the
197/// current point of the cairo context.
198/// ## `cr`
199/// a Cairo context
200/// ## `layout`
201/// a Pango layout
202#[doc(alias = "pango_cairo_layout_path")]
203pub fn layout_path(cr: &cairo::Context, layout: &pango::Layout) {
204 unsafe {
205 ffi::pango_cairo_layout_path(mut_override(cr.to_glib_none().0), layout.to_glib_none().0);
206 }
207}
208
209/// Adds components of a [`pango::Layout`][crate::pango::Layout] to the current path
210/// in the specified cairo context.
211///
212/// The top-left corner of the [`pango::Layout`][crate::pango::Layout] will be at the
213/// current point of the cairo context.
214/// ## `cr`
215/// a Cairo context
216/// ## `layout`
217/// a Pango layout
218/// ## `components`
219/// the components to include
220#[cfg(feature = "v1_58")]
221#[cfg_attr(docsrs, doc(cfg(feature = "v1_58")))]
222#[doc(alias = "pango_cairo_layout_path_for_components")]
223pub fn layout_path_for_components(
224 cr: &cairo::Context,
225 layout: &pango::Layout,
226 components: pango::RenderComponent,
227) {
228 unsafe {
229 ffi::pango_cairo_layout_path_for_components(
230 mut_override(cr.to_glib_none().0),
231 layout.to_glib_none().0,
232 components.into_glib(),
233 );
234 }
235}
236
237/// Draw a squiggly line in the specified cairo context that approximately
238/// covers the given rectangle in the style of an underline used to indicate a
239/// spelling error.
240///
241/// The width of the underline is rounded to an integer
242/// number of up/down segments and the resulting rectangle is centered in the
243/// original rectangle.
244/// ## `cr`
245/// a Cairo context
246/// ## `x`
247/// The X coordinate of one corner of the rectangle
248/// ## `y`
249/// The Y coordinate of one corner of the rectangle
250/// ## `width`
251/// Non-negative width of the rectangle
252/// ## `height`
253/// Non-negative height of the rectangle
254#[doc(alias = "pango_cairo_show_error_underline")]
255pub fn show_error_underline(cr: &cairo::Context, x: f64, y: f64, width: f64, height: f64) {
256 unsafe {
257 ffi::pango_cairo_show_error_underline(
258 mut_override(cr.to_glib_none().0),
259 x,
260 y,
261 width,
262 height,
263 );
264 }
265}
266
267/// offset`.
268/// ## `cr`
269/// a Cairo context
270/// ## `text`
271/// the UTF-8 text that @glyph_item refers to
272/// ## `glyph_item`
273/// a [`pango::GlyphItem`][crate::pango::GlyphItem]
274#[doc(alias = "pango_cairo_show_glyph_item")]
275pub fn show_glyph_item(cr: &cairo::Context, text: &str, glyph_item: &mut pango::GlyphItem) {
276 unsafe {
277 ffi::pango_cairo_show_glyph_item(
278 mut_override(cr.to_glib_none().0),
279 text.to_glib_none().0,
280 glyph_item.to_glib_none_mut().0,
281 );
282 }
283}
284
285/// Draws the glyphs in @glyphs in the specified cairo context.
286///
287/// The origin of the glyphs (the left edge of the baseline) will
288/// be drawn at the current point of the cairo context.
289/// ## `cr`
290/// a Cairo context
291/// ## `font`
292/// a [`pango::Font`][crate::pango::Font] from a [`FontMap`][crate::FontMap]
293/// ## `glyphs`
294/// a [`pango::GlyphString`][crate::pango::GlyphString]
295#[doc(alias = "pango_cairo_show_glyph_string")]
296pub fn show_glyph_string(
297 cr: &cairo::Context,
298 font: &impl IsA<pango::Font>,
299 glyphs: &mut pango::GlyphString,
300) {
301 unsafe {
302 ffi::pango_cairo_show_glyph_string(
303 mut_override(cr.to_glib_none().0),
304 font.as_ref().to_glib_none().0,
305 glyphs.to_glib_none_mut().0,
306 );
307 }
308}
309
310/// Draws a [`pango::Layout`][crate::pango::Layout] in the specified cairo context.
311///
312/// The top-left corner of the [`pango::Layout`][crate::pango::Layout] will be drawn
313/// at the current point of the cairo context.
314/// ## `cr`
315/// a Cairo context
316/// ## `layout`
317/// a Pango layout
318#[doc(alias = "pango_cairo_show_layout")]
319pub fn show_layout(cr: &cairo::Context, layout: &pango::Layout) {
320 unsafe {
321 ffi::pango_cairo_show_layout(mut_override(cr.to_glib_none().0), layout.to_glib_none().0);
322 }
323}
324
325/// Draws a [`pango::LayoutLine`][crate::pango::LayoutLine] in the specified cairo context.
326///
327/// The origin of the glyphs (the left edge of the line) will
328/// be drawn at the current point of the cairo context.
329/// ## `cr`
330/// a Cairo context
331/// ## `line`
332/// a [`pango::LayoutLine`][crate::pango::LayoutLine]
333#[doc(alias = "pango_cairo_show_layout_line")]
334pub fn show_layout_line(cr: &cairo::Context, line: &pango::LayoutLine) {
335 unsafe {
336 ffi::pango_cairo_show_layout_line(mut_override(cr.to_glib_none().0), line.to_glib_none().0);
337 }
338}
339
340/// Updates a [`pango::Context`][crate::pango::Context] previously created for use with Cairo to
341/// match the current transformation and target surface of a Cairo
342/// context.
343///
344/// If any layouts have been created for the context, it's necessary
345/// to call [`Layout::context_changed()`][crate::pango::Layout::context_changed()] on those layouts.
346/// ## `cr`
347/// a Cairo context
348/// ## `context`
349/// a [`pango::Context`][crate::pango::Context], from a pangocairo font map
350#[doc(alias = "pango_cairo_update_context")]
351pub fn update_context(cr: &cairo::Context, context: &pango::Context) {
352 unsafe {
353 ffi::pango_cairo_update_context(
354 mut_override(cr.to_glib_none().0),
355 context.to_glib_none().0,
356 );
357 }
358}
359
360/// Updates the private [`pango::Context`][crate::pango::Context] of a [`pango::Layout`][crate::pango::Layout] created with
361/// [`create_layout()`][crate::create_layout()] to match the current transformation and target
362/// surface of a Cairo context.
363/// ## `cr`
364/// a Cairo context
365/// ## `layout`
366/// a [`pango::Layout`][crate::pango::Layout], from [`create_layout()`][crate::create_layout()]
367#[doc(alias = "pango_cairo_update_layout")]
368pub fn update_layout(cr: &cairo::Context, layout: &pango::Layout) {
369 unsafe {
370 ffi::pango_cairo_update_layout(mut_override(cr.to_glib_none().0), layout.to_glib_none().0);
371 }
372}