libcss
Loading...
Searching...
No Matches
Functions
unit.c File Reference
#include <libcss/stylesheet.h>
#include "utils/utils.h"
#include "propget.h"
#include "unit.h"

Functions

css_fixed css_unit_font_size_len2pt (const css_computed_style *style, const css_unit_ctx *ctx, const css_fixed length, const css_unit unit)
 
css_fixed css_unit_len2px_mq (const css_unit_ctx *ctx, const css_fixed length, const css_unit unit)
 
css_fixed css_unit_len2css_px (const css_computed_style *style, const css_unit_ctx *ctx, const css_fixed length, const css_unit unit)
 
css_fixed css_unit_len2device_px (const css_computed_style *style, const css_unit_ctx *ctx, const css_fixed length, const css_unit unit)
 
css_error css_unit_compute_absolute_font_size (const css_hint_length *ref_length, const css_computed_style *root_style, css_fixed font_size_default, css_hint *size)
 
css_fixed css_unit_angle2deg (const css_unit unit, const css_fixed angle)
 

Function Documentation

◆ css_unit_angle2deg()

css_fixed css_unit_angle2deg ( const css_unit  unit,
const css_fixed  angle 
)

Convert any angle to degrees.

It is invalid to call this with a unit which isn't of UNIT_ANGLE

Parameters
[in]unitThe unit the angle is in
[in]angleThe angle to convert
Returns
the angle in degrees

◆ css_unit_compute_absolute_font_size()

css_error css_unit_compute_absolute_font_size ( const css_hint_length ref_length,
const css_computed_style root_style,
css_fixed  font_size_default,
css_hint size 
)

Convert relative font size units to absolute units.

Parameters
[in]ref_lengthReference font-size length or NULL.
[in]root_styleRoot element style or NULL.
[in]font_size_defaultClient default font size in CSS pixels.
[in,out]sizeThe length to convert.
Returns
CSS_OK on success, or appropriate error otherwise.

◆ css_unit_font_size_len2pt()

css_fixed css_unit_font_size_len2pt ( const css_computed_style style,
const css_unit_ctx ctx,
const css_fixed  length,
const css_unit  unit 
)

Convert a length to points (pt).

Parameters
[in]styleStyle to perform conversion for or NULL.
[in]ctxLength unit conversion context.
[in]lengthLength to convert.
[in]unitCurrent unit of length.
Returns
A length in points.

◆ css_unit_len2css_px()

css_fixed css_unit_len2css_px ( const css_computed_style style,
const css_unit_ctx ctx,
const css_fixed  length,
const css_unit  unit 
)

Convert a length to CSS pixels.

Parameters
[in]styleStyle to perform conversion for or NULL.
[in]ctxLength unit conversion context.
[in]lengthLength to convert.
[in]unitCurrent unit of length.
Returns
A length in CSS pixels.

◆ css_unit_len2device_px()

css_fixed css_unit_len2device_px ( const css_computed_style style,
const css_unit_ctx ctx,
const css_fixed  length,
const css_unit  unit 
)

Convert a length to device pixels.

Parameters
[in]styleStyle to perform conversion for or NULL.
[in]ctxLength unit conversion context.
[in]lengthLength to convert.
[in]unitCurrent unit of length.
Returns
A length in device pixels.

◆ css_unit_len2px_mq()

css_fixed css_unit_len2px_mq ( const css_unit_ctx ctx,
const css_fixed  length,
const css_unit  unit 
)

Convert a length to CSS pixels for a media query context.

Parameters
[in]ctxDocument unit conversion context.
[in]lengthLength to convert.
[in]unitCurrent unit of length.
Returns
A length in CSS pixels.