add font size support
This commit is contained in:
parent
f9deacf0bc
commit
1c61e5659c
|
@ -34,7 +34,7 @@ Force docking without asking the window manager. This is needed if the window ma
|
||||||
|
|
||||||
=item B<-f> I<font>
|
=item B<-f> I<font>
|
||||||
|
|
||||||
Comma separated list of fonts, bar supports a maximum of two fonts.
|
Font face. Size can be specified as <font>:<size>
|
||||||
|
|
||||||
=item B<-p>
|
=item B<-p>
|
||||||
|
|
||||||
|
|
26
bar.c
26
bar.c
|
@ -74,6 +74,7 @@ static bool topbar = true;
|
||||||
static int bw = -1, bh = -1, bx = 0, by = 0;
|
static int bw = -1, bh = -1, bx = 0, by = 0;
|
||||||
static int bu = 1; /* Underline height */
|
static int bu = 1; /* Underline height */
|
||||||
static char *mfont = NULL;
|
static char *mfont = NULL;
|
||||||
|
static double mfont_size = 10.0;
|
||||||
static uint32_t fgc, bgc;
|
static uint32_t fgc, bgc;
|
||||||
static area_stack_t astack;
|
static area_stack_t astack;
|
||||||
|
|
||||||
|
@ -517,6 +518,7 @@ monitor_new (int x, int y, int width, int height)
|
||||||
ret->cr = cairo_create(ret->surface);
|
ret->cr = cairo_create(ret->surface);
|
||||||
|
|
||||||
cairo_select_font_face (ret->cr, mfont? mfont: "fixed", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
cairo_select_font_face (ret->cr, mfont? mfont: "fixed", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||||
|
cairo_set_font_size(ret->cr, mfont_size);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -937,8 +939,28 @@ parse_font_list (char *str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tok = strtok(str, ",");
|
tok = strtok(str, ",");
|
||||||
if (tok)
|
if (tok) {
|
||||||
mfont = tok;
|
mfont = tok; // font face
|
||||||
|
|
||||||
|
// if a colon is found
|
||||||
|
tok = strtok(mfont, ":");
|
||||||
|
if(tok) {
|
||||||
|
// treat the string before the colon as the font face
|
||||||
|
mfont = tok; // font face
|
||||||
|
|
||||||
|
// if characters exist after the colon
|
||||||
|
tok = strtok(NULL, ":");
|
||||||
|
if(tok) {
|
||||||
|
double candidate_size;
|
||||||
|
candidate_size = atof(tok);
|
||||||
|
// and the size is non-zero
|
||||||
|
if(candidate_size != 0) {
|
||||||
|
// treat the rest of the string as the font size
|
||||||
|
mfont_size = candidate_size; // font size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user