## Miscellaneous Miscellaneous — Potentially useful functions |

## Functions

void | chafa_calc_canvas_geometry ()

## Description

Miscellaneous functions that may be useful to Chafa users.

## Functions

### chafa_calc_canvas_geometry ()

    void
    chafa_calc_canvas_geometry (gint src_width,
                                gint src_height,
                                gint *dest_width_inout,
                                gint *dest_height_inout,
                                gfloat font_ratio,
                                gboolean zoom,
                                gboolean stretch);

Calculates an optimal geometry for a ChafaCanvas given the width and height of an input image, maximum width and height of the canvas, font ratio, zoom and stretch preferences.

`src_width` and `src_height` must both be zero or greater.

`dest_width_inout` and `dest_height_inout` must point to integers containing the maximum dimensions of the canvas in character cells. These will be replaced by the calculated values, which may be zero if one of the input dimensions is zero. If one or both of the input parameters is negative, they will be treated as unspecified and calculated based on the remaining parameters and aspect ratio.

`font_ratio` is the font's width divided by its height. 0.5 is a typical value.

#### Parameters

src_width | Width of source |
src_height | Height of source |
dest_width_inout | Inout location for width of destination |
dest_height_inout | Inout location for height of destination |
font_ratio | Target font's width to height ratio |
zoom | `TRUE` to upscale image to fit maximum dimensions, `FALSE` otherwise |
stretch | `TRUE` to ignore aspect of source, `FALSE` otherwise |

## Types and Values