loaders: PNG: Handle gamma on 16bpp conversion
[gfxprim.git] / libs / text / GP_Font.c
blobff5f5c20d5f735028df8af94885f0eab5cbdc4ac
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
23 #include <stdlib.h>
24 #include "GP_Font.h"
26 #include "GP_DefaultFont.h"
28 uint32_t GP_GetGlyphCount(GP_CharSet charset)
30 switch (charset) {
31 case GP_CHARSET_7BIT:
32 return 0x7f - 0x20 + 1;
33 break;
34 default:
35 return 0;
39 GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c)
41 int i;
43 switch (font->charset) {
44 case GP_CHARSET_7BIT:
45 if (c < 0x20 || c > 0x7f)
46 return NULL;
47 i = c - ' ';
48 break;
49 default:
50 return NULL;
53 uint32_t offset;
55 if (font->glyph_offsets[0] == 0)
56 offset = font->glyph_offsets[i];
57 else
58 offset = font->glyph_offsets[0] * i;
60 return (GP_GlyphBitmap*)(font->glyphs + offset);
63 void GP_FontFaceFree(GP_FontFace *self)
65 if (!self)
66 return;
68 free(self->glyphs);
69 free(self);