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
|
|
|
|
|
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-11 18:12:47 +02:00
|
|
|
} FR_Bitmap_Glyph_Metrics;
|
2020-06-01 12:56:23 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
typedef struct FR_Bitmap FR_Bitmap;
|
2020-06-11 16:39:11 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
struct FR_Impl;
|
|
|
|
typedef struct FR_Impl 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;
|
2020-06-11 18:12:47 +02:00
|
|
|
} FR_Color;
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-11 16:39:11 +02:00
|
|
|
typedef struct {
|
|
|
|
int left, top, right, bottom;
|
2020-06-11 18:12:47 +02:00
|
|
|
} FR_Clip_Area;
|
2020-06-11 16:39:11 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
FontRenderer * FR_New(unsigned int flags, float gamma);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
void FR_Free(FontRenderer *);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
int FR_Load_Font(FontRenderer *, const char *filename);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
int FR_Get_Font_Height(FontRenderer *, float size);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
int FR_Bake_Font_Bitmap(FontRenderer *, int font_height,
|
|
|
|
FR_Bitmap *image,
|
|
|
|
int first_char, int num_chars, FR_Bitmap_Glyph_Metrics *glyph_info,
|
2020-06-04 16:29:28 +02:00
|
|
|
int subpixel_scale);
|
2020-06-02 14:47:06 +02:00
|
|
|
|
2020-06-11 16:39:11 +02:00
|
|
|
#if 0
|
|
|
|
// FIXME: this function needs to be updated to match BlendGammaSubpixel.
|
2020-06-11 18:12:47 +02:00
|
|
|
void FR_Blend_Gamma(FontRenderer *,
|
2020-06-02 17:18:52 +02:00
|
|
|
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,
|
2020-06-11 18:12:47 +02:00
|
|
|
FR_Color color);
|
2020-06-11 16:39:11 +02:00
|
|
|
#endif
|
2020-06-01 12:56:23 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
void FR_Blend_Gamma_Subpixel(FontRenderer *font_renderer,
|
|
|
|
FR_Clip_Area *clip, int x, int y,
|
2020-06-11 16:39:11 +02:00
|
|
|
uint8_t *dst, int dst_width,
|
2020-06-11 18:12:47 +02:00
|
|
|
const FR_Bitmap *glyphs_bitmap,
|
|
|
|
const FR_Bitmap_Glyph_Metrics *glyph, FR_Color color);
|
2020-06-04 16:29:28 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
FR_Bitmap* FR_Bitmap_New(int width, int height, int subpixel_scale);
|
2020-06-11 17:52:00 +02:00
|
|
|
|
2020-06-11 18:12:47 +02:00
|
|
|
void FR_Bitmap_Free(FR_Bitmap *image);
|
2020-06-11 17:52:00 +02:00
|
|
|
|
2020-06-01 12:56:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|