GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_text_style.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos
4 * <jiri.bluebear.dluhos@gmail.com>
5 *
6 * Copyright (C) 2009-2011 Cyril Hrubis <metan@ucw.cz>
7 */
8
9#ifndef TEXT_GP_TEXTSTYLE_H
10#define TEXT_GP_TEXTSTYLE_H
11
12#include <text/gp_font.h>
13
14extern const gp_font_face gp_default_font;
15
16/*
17 * This structure describes how a text should be rendered.
18 * It includes a font, and its various variants and transformations.
19 */
20typedef struct gp_text_style {
21 const gp_font_face *font;
22
23 /* Spacing between pixels (0 is the default, no spacing). */
24 int pixel_xspace, pixel_yspace;
25
26 /* Multiplier of pixel width/height (1 is default). */
27 int pixel_xmul, pixel_ymul;
28
29 /* Extra spacing (in pixels) between characters. */
30 int char_xspace;
31} gp_text_style;
32
33#define GP_DEFAULT_TEXT_STYLE { \
34 .font = &gp_default_font, \
35 .pixel_xspace = 0, \
36 .pixel_yspace = 0, \
37 .pixel_xmul = 1, \
38 .pixel_ymul = 1, \
39 .char_xspace = 0 \
40}
41
42static inline void gp_text_style_normal(gp_text_style *style, const gp_font_face *font, int mul)
43{
44 style->pixel_xspace = 0;
45 style->pixel_yspace = 0;
46 style->pixel_xmul = mul;
47 style->pixel_ymul = mul;
48 style->font = font;
49}
50
51/*
52 * Creates a bold variant of a bitmap font on the expense of slower rendering.
53 */
54static inline void gp_text_style_embold(gp_text_style *style, const gp_font_face *font, int mul)
55{
56 style->pixel_xspace = -1;
57 style->pixel_yspace = -1;
58 style->pixel_xmul = mul + 1;
59 style->pixel_ymul = mul + 1;
60 style->font = font;
61}
62
63#endif /* TEXT_GP_TEXTSTYLE_H */