lite-xl/lib/font_renderer/font_renderer.h

61 lines
1.5 KiB
C
Raw Normal View History

#ifndef FONT_RENDERER_H
#define FONT_RENDERER_H
2020-06-02 14:47:06 +02:00
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
2020-06-02 14:47:06 +02:00
typedef struct {
unsigned short x0, y0, x1, y1;
float xoff, yoff, xadvance;
2020-06-11 18:12:47 +02:00
} FR_Bitmap_Glyph_Metrics;
2020-06-11 18:12:47 +02:00
typedef struct FR_Bitmap FR_Bitmap;
2020-06-29 17:01:14 +02:00
#ifdef __cplusplus
class FR_Renderer;
#else
struct FR_Renderer;
typedef struct FR_Renderer FR_Renderer;
#endif
enum {
FR_HINTING = 1 << 0,
FR_KERNING = 1 << 1,
FR_SUBPIXEL = 1 << 2,
FR_PRESCALE_X = 1 << 3,
};
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
typedef struct {
int left, top, right, bottom;
2020-06-11 18:12:47 +02:00
} FR_Clip_Area;
FR_Renderer * FR_Renderer_New(unsigned int flags);
2020-06-11 23:19:08 +02:00
void FR_Renderer_Free(FR_Renderer *);
int FR_Load_Font(FR_Renderer *, const char *filename);
FR_Bitmap* FR_Bitmap_New(FR_Renderer *, int width, int height);
void FR_Bitmap_Free(FR_Bitmap *image);
int FR_Get_Font_Height(FR_Renderer *, float size);
FR_Bitmap * FR_Bake_Font_Bitmap(FR_Renderer *, int font_height,
int first_char, int num_chars, FR_Bitmap_Glyph_Metrics *glyph_info);
2020-06-11 23:19:08 +02:00
void FR_Blend_Glyph(FR_Renderer *font_renderer,
2020-06-11 18:12:47 +02:00
FR_Clip_Area *clip, int x, int y,
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);
int FR_Subpixel_Scale(FR_Renderer *);
#define FR_XADVANCE_TO_PIXELS(x, scale) (((x) + (scale) / 2) / (scale))
2020-06-04 16:29:28 +02:00
#ifdef __cplusplus
}
#endif
#endif