2020-06-01 12:56:23 +02:00
|
|
|
#ifndef FONT_RENDERER_H
|
|
|
|
#define FONT_RENDERER_H
|
|
|
|
|
2020-06-02 14:47:06 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2020-06-01 12:56:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Mirrors stbtt_bakedchar.
|
2020-06-02 14:47:06 +02:00
|
|
|
typedef struct {
|
2020-06-01 12:56:23 +02:00
|
|
|
unsigned short x0, y0, x1, y1;
|
|
|
|
float xoff, yoff, xadvance;
|
2020-06-07 00:15:38 +02:00
|
|
|
#ifdef FONT_RENDERER_DEBUG
|
|
|
|
int ybaseline;
|
|
|
|
#endif
|
2020-06-02 14:47:06 +02:00
|
|
|
} GlyphBitmapInfo;
|
2020-06-01 12:56:23 +02:00
|
|
|
|
2020-06-02 17:18:52 +02:00
|
|
|
struct FontRendererImpl;
|
|
|
|
typedef struct FontRendererImpl FontRenderer;
|
2020-06-01 12:56:23 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
FONT_RENDERER_HINTING = 1 << 0,
|
|
|
|
FONT_RENDERER_KERNING = 1 << 1,
|
2020-06-06 19:05:45 +02:00
|
|
|
FONT_RENDERER_SUBPIXEL = 1 << 2,
|
2020-06-01 12:56:23 +02:00
|
|
|
};
|
|
|
|
|
2020-06-02 14:47:06 +02:00
|
|
|
typedef struct {
|
|
|
|
uint8_t r, g, b;
|
|
|
|
} FontRendererColor;
|
|
|
|
|
2020-06-02 17:18:52 +02:00
|
|
|
FontRenderer * FontRendererNew(unsigned int flags, float gamma);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
|
|
|
void FontRendererFree(FontRenderer *);
|
|
|
|
|
|
|
|
int FontRendererLoadFont(FontRenderer *, const char *filename);
|
|
|
|
|
|
|
|
int FontRendererGetFontHeight(FontRenderer *, float size);
|
|
|
|
|
|
|
|
int FontRendererBakeFontBitmap(FontRenderer *, int font_height,
|
|
|
|
void *pixels, int pixels_width, int pixels_height,
|
2020-06-04 16:29:28 +02:00
|
|
|
int first_char, int num_chars, GlyphBitmapInfo *glyph_info,
|
|
|
|
int subpixel_scale);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-02 17:18:52 +02:00
|
|
|
void FontRendererBlendGamma(FontRenderer *,
|
|
|
|
uint8_t *dst, int dst_stride,
|
2020-06-02 14:47:06 +02:00
|
|
|
uint8_t *src, int src_stride,
|
|
|
|
int region_width, int region_height,
|
|
|
|
FontRendererColor color);
|
2020-06-01 12:56:23 +02:00
|
|
|
|
2020-06-04 16:29:28 +02:00
|
|
|
void FontRendererBlendGammaSubpixel(FontRenderer *,
|
|
|
|
uint8_t *dst, int dst_stride,
|
|
|
|
uint8_t *src, int src_stride,
|
|
|
|
int region_width, int region_height,
|
|
|
|
FontRendererColor color);
|
|
|
|
|
2020-06-01 12:56:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|