lite-xl/lib/font_renderer/font_renderer.h

62 lines
1.6 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
// Mirrors stbtt_bakedchar.
2020-06-02 14:47:06 +02:00
typedef struct {
unsigned short x0, y0, x1, y1;
float xoff, yoff, xadvance;
#ifdef FONT_RENDERER_DEBUG
int ybaseline;
#endif
2020-06-02 14:47:06 +02:00
} GlyphBitmapInfo;
struct FontRendererImpl;
typedef struct FontRendererImpl 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;
} FontRendererColor;
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
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-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);
#ifdef __cplusplus
}
#endif
#endif