mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-15 19:24:59 +08:00
db06460208
The full log is at https://github.com/RTGUI/RTGUI/commits/merge_1 and it's difficult to merge the new tree commit by commit. I also converted all the file into unix eol so there are many fake diff. Big changes are noted in rtgui/doc/road_map.txt and rtgui/doc/attention.txt. Keep an eye on them if you want to migrate your old code. Note that the work is still in progress and the bsp is not prepared in trunk so far. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2092 bbd45198-f89e-11dd-88c7-29a3b14d5316
115 lines
2.8 KiB
C
115 lines
2.8 KiB
C
/*
|
|
* File : font.h
|
|
* This file is part of RT-Thread RTOS
|
|
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
|
*
|
|
* The license and distribution terms for this file may be
|
|
* found in the file LICENSE in this distribution or at
|
|
* http://www.rt-thread.org/license/LICENSE
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2009-10-16 Bernard first version
|
|
*/
|
|
#ifndef __RTGUI_FONT_H__
|
|
#define __RTGUI_FONT_H__
|
|
|
|
#include <rtgui/rtgui.h>
|
|
#include <rtgui/list.h>
|
|
|
|
struct rtgui_font;
|
|
struct rtgui_dc;
|
|
struct rtgui_rect;
|
|
|
|
struct rtgui_font_engine
|
|
{
|
|
/* font engine function */
|
|
void (*font_init)(struct rtgui_font* font);
|
|
void (*font_load)(struct rtgui_font* font);
|
|
|
|
void (*font_draw_text)(struct rtgui_font* font, struct rtgui_dc* dc, const char* text,
|
|
rt_ubase_t len, struct rtgui_rect* rect);
|
|
void (*font_get_metrics)(struct rtgui_font* font, const char* text, struct rtgui_rect* rect);
|
|
};
|
|
|
|
/*
|
|
* bitmap font engine
|
|
*/
|
|
struct rtgui_font_bitmap
|
|
{
|
|
const rt_uint8_t* bmp; /* bitmap font data */
|
|
const rt_uint8_t* char_width; /* each character width, NULL for fixed font */
|
|
const rt_uint32_t* offset; /* offset for each character */
|
|
|
|
rt_uint16_t width; /* font width */
|
|
rt_uint16_t height; /* font height */
|
|
|
|
rt_uint8_t first_char;
|
|
rt_uint8_t last_char;
|
|
};
|
|
extern const struct rtgui_font_engine bmp_font_engine;
|
|
|
|
#include <rtgui/tree.h>
|
|
SPLAY_HEAD(cache_tree, hz_cache);
|
|
struct hz_cache
|
|
{
|
|
SPLAY_ENTRY(hz_cache) hz_node;
|
|
|
|
rt_uint16_t hz_id;
|
|
};
|
|
|
|
struct rtgui_hz_file_font
|
|
{
|
|
struct cache_tree cache_root;
|
|
rt_uint16_t cache_size;
|
|
|
|
/* font size */
|
|
rt_uint16_t font_size;
|
|
rt_uint16_t font_data_size;
|
|
|
|
/* file descriptor */
|
|
int fd;
|
|
|
|
/* font file name */
|
|
const char* font_fn;
|
|
};
|
|
extern const struct rtgui_font_engine rtgui_hz_file_font_engine;
|
|
|
|
struct rtgui_font
|
|
{
|
|
/* font name */
|
|
char* family;
|
|
|
|
/* font height */
|
|
rt_uint16_t height;
|
|
|
|
/* refer count */
|
|
rt_uint32_t refer_count;
|
|
|
|
/* font engine */
|
|
const struct rtgui_font_engine* engine;
|
|
|
|
/* font private data */
|
|
void* data;
|
|
|
|
/* the font list */
|
|
rtgui_list_t list;
|
|
};
|
|
typedef struct rtgui_font rtgui_font_t;
|
|
|
|
void rtgui_font_system_init(void);
|
|
void rtgui_font_system_add_font(struct rtgui_font* font);
|
|
void rtgui_font_system_remove_font(struct rtgui_font* font);
|
|
struct rtgui_font* rtgui_font_default(void);
|
|
void rtgui_font_set_defaut(struct rtgui_font* font);
|
|
|
|
struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height);
|
|
void rtgui_font_derefer(struct rtgui_font* font);
|
|
|
|
/* draw a text */
|
|
void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
|
int rtgui_font_get_string_width(struct rtgui_font* font, const char* text);
|
|
void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, struct rtgui_rect* rect);
|
|
|
|
#endif
|