diff options
| -rw-r--r-- | drw.c | 28 | ||||
| -rw-r--r-- | swt.c | 9 |
2 files changed, 23 insertions, 14 deletions
@@ -202,9 +202,14 @@ create_font_family(FontPath fontpath) FontFamily *fontfamily = malloc(sizeof(FontFamily)); for (i = 0; i < FONT_TYPE_SIZE; ++i) { + (*fontfamily)[i].path = 0; + (*fontfamily)[i].loaded = 0; + (*fontfamily)[i].face = 0; + (*fontfamily)[i].library = 0; + (*fontfamily)[i].stroke = 0; + if (fontpath[i]) { (*fontfamily)[i].path = fontpath[i]; - (*fontfamily)[i].loaded = 0; } } @@ -232,17 +237,19 @@ init_font(Font *font) error = FT_Init_FreeType(&font->library); if (error) - die("cannot init library"); + die("cannot init library:"); error = FT_New_Face(font->library, font->path, 0, &font->face); if (error) - die("cannot open face"); + die("cannot open face:"); error = FT_Select_Charmap(font->face, ft_encoding_unicode); if (error) - die("cannot set unicode"); + die("cannot set unicode:"); FT_Stroker_New(font->library, &font->stroke); + + font->loaded = 1; } @@ -306,10 +313,8 @@ get_font_with_charcode(FontCache *fontcache, uint_least32_t charcode) if (!font->path) continue; - if (!font->loaded) { + if (!font->loaded) init_font(font); - font->loaded = 1; - } glyph_index = FT_Get_Char_Index(font->face, charcode); @@ -317,9 +322,10 @@ get_font_with_charcode(FontCache *fontcache, uint_least32_t charcode) return font; } - font = fontcache->first->family[fontcache->fonttype]; - init_font(font); - font->loaded = 1; + font = &(*fontcache->first->family)[fontcache->fonttype]; + if (!font->loaded) + init_font(font); + return font; } @@ -337,9 +343,11 @@ draw_char(Canvas *canvas, FontCache *fontcache, uint_least32_t charcode, unsigne FT_BitmapGlyph bg; FT_Glyph glyph; + font = get_font_with_charcode(fontcache, charcode); FT_Set_Pixel_Sizes(font->face, 0, fontcache->fontsize); + if (boldstokemode && fontcache->fonttype == FONT_BOLD) { FT_Stroker_Set(font->stroke, fontcache->fontsize * 2, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, fontcache->fontsize * 2); @@ -72,7 +72,7 @@ static int execshortcut(); static char *kmap(); static void buffer_release(void *data, struct wl_buffer *buffer); static void draw_frame(); -static uint32_t get_color(int i); +static uint32_t get_color(uint32_t i); static void draw_glyph(Glyph g, int x, int y); static void commit_surface(); static void surface_configure(void *data, struct xdg_surface *surface, uint32_t serial); @@ -216,10 +216,11 @@ paste() uint32_t -get_color(int i) +get_color(uint32_t i) { - if (!BETWEEN(i, 0, sizeof(colors) / sizeof(uint32_t))) - return colors[defaultbg]; + if (!BETWEEN(i, 0, sizeof(colors) / sizeof(uint32_t))) { + return i; + } return colors[i]; } |