src/util/gui/font.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef GUI_FONT_H
7#define GUI_FONT_H
8
9#include "util/common.h"
10
11struct GUIFont;
12struct GUIFont* GUIFontCreate(void);
13void GUIFontDestroy(struct GUIFont*);
14
15enum GUITextAlignment {
16 GUI_TEXT_LEFT = 0,
17 GUI_TEXT_CENTER,
18 GUI_TEXT_RIGHT
19};
20
21struct GUIFontGlyphMetric {
22 int width;
23 int height;
24 struct {
25 int top;
26 int right;
27 int bottom;
28 int left;
29 } padding;
30};
31
32unsigned GUIFontHeight(const struct GUIFont*);
33unsigned GUIFontGlyphWidth(const struct GUIFont*, uint32_t glyph);
34unsigned GUIFontSpanWidth(const struct GUIFont*, const char* text);
35
36ATTRIBUTE_FORMAT(printf, 6, 7)
37void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUITextAlignment, uint32_t color, const char* text, ...);
38void GUIFontPrint(const struct GUIFont*, int x, int y, enum GUITextAlignment, uint32_t color, const char* text);
39void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint32_t glyph);
40
41#endif