mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
main: -f,--font now accepts a list of fonts
This makes -f,--font behave just like the configuration file option 'font'; the first font in the list is the primary font, and the remaining fonts are fallback fonts used when a glyph cannot be found in the primary font.
This commit is contained in:
parent
933e165164
commit
f20b08db3d
2 changed files with 34 additions and 4 deletions
|
|
@ -13,8 +13,19 @@ execute (instead of the shell).
|
|||
# OPTIONS
|
||||
|
||||
*-f*,*--font*=_FONT_
|
||||
Font and style to use, in fontconfig format. See *FONT
|
||||
FORMAT*. Default: _monospace_.
|
||||
Comma separated list of fonts to use, in fontconfig format (see
|
||||
*FONT FORMAT*).
|
||||
|
||||
The first font is the primary font. The remaining fonts are
|
||||
fallback fonts that will be used whenever a glyph cannot be found
|
||||
in the primary font.
|
||||
|
||||
The fallback fonts are searched in the order they appear. If a
|
||||
glyph cannot be found in any of the fallback fonts, the dynamic
|
||||
fallback list from fontconfig (for the primary font) is
|
||||
searched.
|
||||
|
||||
Default: _monospace_.
|
||||
|
||||
*-g*,*--geometry*=_WIDTHxHEIGHT_
|
||||
Set initial window width and height.
|
||||
|
|
|
|||
23
main.c
23
main.c
|
|
@ -1,6 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
|
@ -397,7 +398,7 @@ print_usage(const char *prog_name)
|
|||
printf("Usage: %s [OPTION]...\n", prog_name);
|
||||
printf("\n");
|
||||
printf("Options:\n");
|
||||
printf(" -f,--font=FONT font name and style in fontconfig format (monospace)\n"
|
||||
printf(" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
|
||||
" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
|
||||
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
|
||||
" -v,--version show the version number and quit\n");
|
||||
|
|
@ -437,7 +438,25 @@ main(int argc, char *const *argv)
|
|||
|
||||
case 'f':
|
||||
tll_free_and_free(conf.fonts, free);
|
||||
tll_push_back(conf.fonts, strdup(optarg));
|
||||
//tll_push_back(conf.fonts, strdup(optarg));
|
||||
for (char *font = strtok(optarg, ","); font != NULL; font = strtok(NULL, ",")) {
|
||||
|
||||
/* Strip leading spaces */
|
||||
while (*font != '\0' && isspace(*font))
|
||||
font++;
|
||||
|
||||
/* Strip trailing spaces */
|
||||
char *end = font + strlen(font);
|
||||
assert(*end == '\0');
|
||||
end--;
|
||||
while (end > font && isspace(*end))
|
||||
*(end--) = '\0';
|
||||
|
||||
if (strlen(font) == 0)
|
||||
continue;
|
||||
|
||||
tll_push_back(conf.fonts, strdup(font));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'g': {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue