-
Notifications
You must be signed in to change notification settings - Fork 2
/
font.c
50 lines (50 loc) · 1.19 KB
/
font.c
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
// Copyright 2020, Alisa Bedard
#include "font.h"
#ifdef JBWM_USE_XFT
#include <X11/Xft/Xft.h>
#endif//JBWM_USE_XFT
#include "config.h"
#include <stdbool.h>
#include "util.h"
static struct JBWMFont {
#ifdef JBWM_USE_XFT
XftFont * font;
#else//!JBWM_USE_XFT
XFontStruct * font;
#endif//JBWM_USE_XFT
short ascent,descent,height;
} jbwm_font;
void jbwm_open_font(Display * d)
{
static bool already_created;
if(!already_created){
#ifdef JBWM_USE_XFT
jbwm_font.font = XftFontOpenName(d, DefaultScreen(d), JBWM_FONT);
#else//!JBWM_USE_XFT
jbwm_font.font = XLoadQueryFont(d, JBWM_FONT);
#endif//JBWM_USE_XFT
if (!jbwm_font.font)
jbwm_error(JBWM_FONT);
#ifdef JBWM_USE_XFT
jbwm_font.ascent=jbwm_font.font->ascent;
jbwm_font.descent=jbwm_font.font->descent;
#else//!JBWM_USE_XFT
jbwm_font.ascent=jbwm_font.font->max_bounds.ascent;
jbwm_font.descent=jbwm_font.font->max_bounds.descent;
#endif//JBWM_USE_XFT
jbwm_font.height=jbwm_font.ascent+jbwm_font.descent;
already_created=true;
}
}
void * jbwm_get_font(void)
{
return jbwm_font.font;
}
uint8_t jbwm_get_font_ascent(void)
{
return jbwm_font.ascent;
}
uint8_t jbwm_get_font_height(void)
{
return jbwm_font.height;
}