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/// Draw a squiggly line in the specified cairo context that approximately
210/// covers the given rectangle in the style of an underline used to indicate a
211/// spelling error.
212///
213/// The width of the underline is rounded to an integer
214/// number of up/down segments and the resulting rectangle is centered in the
215/// original rectangle.
216/// ## `cr`
217/// a Cairo context
218/// ## `x`
219/// The X coordinate of one corner of the rectangle
220/// ## `y`
221/// The Y coordinate of one corner of the rectangle
222/// ## `width`
223/// Non-negative width of the rectangle
224/// ## `height`
225/// Non-negative height of the rectangle
226#[doc(alias = "pango_cairo_show_error_underline")]
227pub fn show_error_underline(cr: &cairo::Context, x: f64, y: f64, width: f64, height: f64) {
228 unsafe {
229 ffi::pango_cairo_show_error_underline(
230 mut_override(cr.to_glib_none().0),
231 x,
232 y,
233 width,
234 height,
235 );
236 }
237}
238
239/// Draws the glyphs in @glyph_item in the specified cairo context,
240///
241/// embedding the text associated with the glyphs in the output if the
242/// output format supports it (PDF for example), otherwise it acts
243/// similar to [`show_glyph_string()`][crate::show_glyph_string()].
244///
245/// The origin of the glyphs (the left edge of the baseline) will
246/// be drawn at the current point of the cairo context.
247///
248/// Note that @text is the start of the text for layout, which is then
249/// indexed by `glyph_item->item->offset`.
250/// ## `cr`
251/// a Cairo context
252/// ## `text`
253/// the UTF-8 text that @glyph_item refers to
254/// ## `glyph_item`
255/// a [`pango::GlyphItem`][crate::pango::GlyphItem]
256#[doc(alias = "pango_cairo_show_glyph_item")]
257pub fn show_glyph_item(cr: &cairo::Context, text: &str, glyph_item: &mut pango::GlyphItem) {
258 unsafe {
259 ffi::pango_cairo_show_glyph_item(
260 mut_override(cr.to_glib_none().0),
261 text.to_glib_none().0,
262 glyph_item.to_glib_none_mut().0,
263 );
264 }
265}
266
267/// Draws the glyphs in @glyphs in the specified cairo context.
268///
269/// The origin of the glyphs (the left edge of the baseline) will
270/// be drawn at the current point of the cairo context.
271/// ## `cr`
272/// a Cairo context
273/// ## `font`
274/// a [`pango::Font`][crate::pango::Font] from a [`FontMap`][crate::FontMap]
275/// ## `glyphs`
276/// a [`pango::GlyphString`][crate::pango::GlyphString]
277#[doc(alias = "pango_cairo_show_glyph_string")]
278pub fn show_glyph_string(
279 cr: &cairo::Context,
280 font: &impl IsA<pango::Font>,
281 glyphs: &mut pango::GlyphString,
282) {
283 unsafe {
284 ffi::pango_cairo_show_glyph_string(
285 mut_override(cr.to_glib_none().0),
286 font.as_ref().to_glib_none().0,
287 glyphs.to_glib_none_mut().0,
288 );
289 }
290}
291
292/// Draws a [`pango::Layout`][crate::pango::Layout] in the specified cairo context.
293///
294/// The top-left corner of the [`pango::Layout`][crate::pango::Layout] will be drawn
295/// at the current point of the cairo context.
296/// ## `cr`
297/// a Cairo context
298/// ## `layout`
299/// a Pango layout
300#[doc(alias = "pango_cairo_show_layout")]
301pub fn show_layout(cr: &cairo::Context, layout: &pango::Layout) {
302 unsafe {
303 ffi::pango_cairo_show_layout(mut_override(cr.to_glib_none().0), layout.to_glib_none().0);
304 }
305}
306
307/// Draws a [`pango::LayoutLine`][crate::pango::LayoutLine] in the specified cairo context.
308///
309/// The origin of the glyphs (the left edge of the line) will
310/// be drawn at the current point of the cairo context.
311/// ## `cr`
312/// a Cairo context
313/// ## `line`
314/// a [`pango::LayoutLine`][crate::pango::LayoutLine]
315#[doc(alias = "pango_cairo_show_layout_line")]
316pub fn show_layout_line(cr: &cairo::Context, line: &pango::LayoutLine) {
317 unsafe {
318 ffi::pango_cairo_show_layout_line(mut_override(cr.to_glib_none().0), line.to_glib_none().0);
319 }
320}
321
322/// Updates a [`pango::Context`][crate::pango::Context] previously created for use with Cairo to
323/// match the current transformation and target surface of a Cairo
324/// context.
325///
326/// If any layouts have been created for the context, it's necessary
327/// to call [`Layout::context_changed()`][crate::pango::Layout::context_changed()] on those layouts.
328/// ## `cr`
329/// a Cairo context
330/// ## `context`
331/// a [`pango::Context`][crate::pango::Context], from a pangocairo font map
332#[doc(alias = "pango_cairo_update_context")]
333pub fn update_context(cr: &cairo::Context, context: &pango::Context) {
334 unsafe {
335 ffi::pango_cairo_update_context(
336 mut_override(cr.to_glib_none().0),
337 context.to_glib_none().0,
338 );
339 }
340}
341
342/// Updates the private [`pango::Context`][crate::pango::Context] of a [`pango::Layout`][crate::pango::Layout] created with
343/// [`create_layout()`][crate::create_layout()] to match the current transformation and target
344/// surface of a Cairo context.
345/// ## `cr`
346/// a Cairo context
347/// ## `layout`
348/// a [`pango::Layout`][crate::pango::Layout], from [`create_layout()`][crate::create_layout()]
349#[doc(alias = "pango_cairo_update_layout")]
350pub fn update_layout(cr: &cairo::Context, layout: &pango::Layout) {
351 unsafe {
352 ffi::pango_cairo_update_layout(mut_override(cr.to_glib_none().0), layout.to_glib_none().0);
353 }
354}