diff --git a/README.pod b/README.pod index c1389fb..68aff9b 100644 --- a/README.pod +++ b/README.pod @@ -91,7 +91,7 @@ Set the text foreground color. The parameter I can be I<-> or a color in =item BI -Set the font used to draw the following text. The parameter I is a 1-based index of the font list supplied to bar. Any other value (for example I<->) resets the bar to normal behaviour (matching the first font that can be used for that character). If the selected font can't be used to draw a character, lemonbar will fall back to normal behaviour for that character. +Set the font used to draw the following text. The parameter I can either be I<-> or the 1-based index of the slot which contains the desired font. If the parameter is I<-> lemonbar resets to the normal behavior (matching the first font that can be used for the character). If the selected font can't be used to draw a character, lemonbar will fall back to normal behavior for that character =item BI diff --git a/lemonbar.c b/lemonbar.c index 66df6d8..4c992cc 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -641,13 +641,22 @@ parse (char *text) break; case 'T': - font_index = (int)strtoul(p, &ep, 10); - // User-specified 'font_index' ∊ (0,font_count] - // Otherwise just fallback to the automatic font selection - if (!font_index || font_index > font_count) + if (*p == '-') { //Reset to automatic font selection font_index = -1; - p = ep; - break; + p++; + break; + } else if (isdigit(*p)) { + font_index = (int)strtoul(p, &ep, 10); + // User-specified 'font_index' ∊ (0,font_count] + // Otherwise just fallback to the automatic font selection + if (!font_index || font_index > font_count) + font_index = -1; + p = ep; + break; + } else { + fprintf(stderr, "Invalid font slot \"%c\"\n", *p++); //Swallow the token + break; + } // In case of error keep parsing after the closing } default: