aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 10:38:06 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 10:38:06 +0200
commitceb2880f91b79de5024b3884991419d74466dec6 (patch)
treec921ebbd77edfaff356a35906f2ac8b3e560785b
parent65745aff10ec35dfcae8e2909715156db6d653f2 (diff)
add font weights
-rw-r--r--drw.c6
-rw-r--r--swt.c19
2 files changed, 18 insertions, 7 deletions
diff --git a/drw.c b/drw.c
index 79f4ab1..0b780c6 100644
--- a/drw.c
+++ b/drw.c
@@ -172,10 +172,8 @@ font_cache_generate_box(FontCache *fontcache)
{
Font *font = get_font_with_charcode(fontcache, 0);
FT_Set_Pixel_Sizes(font->face, 0, fontcache->fontsize);
- fprintf(stderr, "fontsize: %i\n", fontcache->fontsize);
fontcache->box.width = (font->face->size->metrics.max_advance) >> 6;
fontcache->box.height = (font->face->size->metrics.height) >> 6;
- fprintf(stderr, "width: %i, height: %i\n", fontcache->box.width, fontcache->box.height);
}
@@ -300,6 +298,10 @@ get_font_with_charcode(FontCache *fontcache, uint_least32_t charcode)
for (; element; element = element->next) {
font = &(*element->family)[fontcache->fonttype];
+
+ if (!font->path)
+ continue;
+
if (!font->loaded) {
init_font(font);
font->loaded = 1;
diff --git a/swt.c b/swt.c
index 60d9e9a..10d4109 100644
--- a/swt.c
+++ b/swt.c
@@ -26,6 +26,8 @@ char *argv0;
#define TRUERED(x) (((x) & 0xff0000) >> 16)
#define TRUEGREEN(x) (((x) & 0xff00) >> 8)
#define TRUEBLUE(x) (((x) & 0xff))
+#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
+#define FONTMODE(mode) (mode & ATTR_ITALIC ? (mode & ATTR_BOLD ? FONT_BOLD_ITALIC : FONT_ITALIC) : (mode & ATTR_BOLD ? FONT_BOLD : FONT_NORMAL))
#define match_then_bind(obj, inter, ver) \
if (strcmp(interface, inter.name) == 0) { \
obj = wl_registry_bind(registry, name, &inter, ver);
@@ -166,6 +168,7 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
win.fontcache->box.height,
colors[og.bg]
);
+ win.fontcache->fonttype = FONTMODE(og.mode);
draw_char(
win.canvas,
win.fontcache,
@@ -182,6 +185,7 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
win.fontcache->box.height,
colors[g.fg]
);
+ win.fontcache->fonttype = FONTMODE(g.mode);
draw_char(
win.canvas,
win.fontcache,
@@ -206,6 +210,7 @@ void wdrawline(Line line, int x1, int y1, int x2) {
);
for (x = x1; x < x2; x++) {
+ win.fontcache->fonttype = FONTMODE(line[x].mode);
draw_rect(
win.canvas,
borderpx + x * win.fontcache->box.width,
@@ -294,8 +299,11 @@ wsetcursor(int cursor) {
}
-void wsetmode(int set, unsigned int flag) {
- fprintf(stderr, "SET MODE: %i, %u\n", set, flag);
+void wsetmode(int set, unsigned int flags) {
+ int mode = win.mode;
+ MODBIT(win.mode, set, flags);
+ if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE))
+ redraw();
}
@@ -310,8 +318,7 @@ void wsetsel(char *str) {
int wstartdraw() {
- return 1;
- //return IS_SET(MODE_VISIBLE);
+ return IS_SET(MODE_VISIBLE);
}
@@ -612,6 +619,7 @@ pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axi
void
setup()
{
+ win.mode = MODE_VISIBLE;
win.fontcache = create_font_cache(fonts, sizeof(fonts) / sizeof(FontPath), fontsize);
wloadcols();
client.kb.repeat.timer = timerfd_create(CLOCK_MONOTONIC, 0);
@@ -637,7 +645,8 @@ setup()
}
-void run()
+void
+run()
{
struct itimerspec spec = { 0 };
struct pollfd fds[3];