lite-xl/lib/font_renderer/font_renderer.h

71 lines
1.8 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-11 18:12:47 +02:00
struct FR_Impl;
typedef struct FR_Impl FontRenderer;
enum {
FONT_RENDERER_HINTING = 1 << 0,
FONT_RENDERER_KERNING = 1 << 1,
FONT_RENDERER_SUBPIXEL = 1 << 2,
};
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;
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
#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 *,
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);
#endif
2020-06-11 18:12:47 +02:00
void FR_Blend_Gamma_Subpixel(FontRenderer *font_renderer,
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);
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 18:12:47 +02:00
void FR_Bitmap_Free(FR_Bitmap *image);
#ifdef __cplusplus
}
#endif
#endif