diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-07-17 17:49:27 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-07-17 17:49:27 (EDT) |
commit | e0a9d32f969a384dcace05531a244aa84bb06595 (patch) | |
tree | 85074db40ed4d25888af9a2f8d93cd7d8a800cb8 /src/font.c | |
parent | ebcbcbbb38bb9e8caee0197575bbe97f28e40b1d (diff) |
font_find(): New function
Diffstat (limited to 'src/font.c')
-rw-r--r-- | src/font.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/font.c b/src/font.c new file mode 100644 index 0000000..f110a23 --- /dev/null +++ b/src/font.c @@ -0,0 +1,56 @@ +/* + * Font lookup and rendering functions + * + * Copyright (C) 2019 Patrick McDermott + * + * This file is part of fbcon2png. + * + * fbcon2png is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * fbcon2png is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with fbcon2png. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "font.h" + +#include <string.h> + +#include <png.h> + +#include <linux/font.h> + +struct font { + const struct font_desc desc; +}; + +static const struct font_desc *fonts[] = { + &font_mplus_1mn_medium_10x14, + &font_mplus_1mn_regular_12x17, + &font_mplus_1mn_regular_14x19, + &font_mplus_1mn_regular_16x22, +}; + +struct font * +font_find(const char *name) +{ + size_t i; + + if (!name) { + return (struct font *) fonts[0]; + } + + for (i = 0; i < *(&fonts + 1) - fonts; ++i) { + if (strcmp(fonts[i]->name, name) == 0) { + return (struct font *) fonts[i]; + } + } + return (struct font *) fonts[0]; +} |