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