134 extern const struct st_fontset *
const *
const font_list[];
137 static int font_dmode;
142 now_fontset = (
struct st_fontset *)*font_list[0];
152 now_fontset = fontset;
174 while(font_list[i]) {
190 return (*font_list[num])->name;
204 DTFPRINTF(0x01,
"name = %s\n", name);
206 while(font_list[i]) {
207 DTPRINTF(0x01,
"Fined %s\n", (*font_list[i])->name);
208 if(
strcomp((
unsigned char *)name, (
unsigned char *)((*font_list[i])->name)) == 0) {
214 SYSERR_PRINT(
"Cannot find fontname \"%s\"\n", name);
252 static void draw_nofont(
short x,
short y,
struct st_font *ft)
268 static struct st_font *get_fontdata(
unsigned short code)
273 ft = now_fontset->
font;
275 #ifdef GSC_FONTS_ENABLE_KANJI // $gsc 漢字フォントの描画を有効にする 276 if(now_fontset->
w_font != 0) {
279 ft = now_fontset->
font;
287 static signed char *get_char_bitmap(
unsigned short code,
struct st_font *ft)
289 signed char *fontp = 0;
290 int cseg = (code >> 8);
292 int lcode = (code & 0xff);
293 unsigned int **indexp, *
index;
296 DTPRINTF(0x01,
"SEG : %d %04X\n", cseg, code);
298 indexp = (
unsigned int **)ft->
index;
299 index = indexp[cseg];
300 DTPRINTF(0x01,
"INDEX : %p\n", index);
308 DTPRINTF(0x01,
"START : %08X\n", start);
309 DTPRINTF(0x01,
"END : %08X\n", end);
311 if((lcode < start) || (lcode > end)) {
314 offset = index[lcode - start + 2];
315 DTPRINTF(0x01,
"OFFSET : %08X\n", offset);
316 if(offset != 0xffffffff) {
317 fontp = &(ft->
bitmap[offset]);
326 #define MAX_FONT_WIDTH 40 327 #define MAX_FONT_HEIGHT 40 329 static unsigned char font_bitmap[(MAX_FONT_WIDTH/8) * MAX_FONT_HEIGHT];
331 static unsigned char *create_font_bitmap(
signed char *fdata,
short fwidth,
short fheight)
338 unsigned char *ddata, *sdata;
344 dwidth = (short)(*(fdata + 0));
345 width = (short)(*(fdata + 1));
346 height = (short)(*(fdata + 2));
347 ox = (short)(*(fdata + 3));
348 oy = (short)(*(fdata + 4));
350 if((fwidth == width) && (ox == 0) && (oy == 0)) {
351 DTPRINTF(0x01,
"No need to create font bitmap data\n");
352 return (
unsigned char *)(fdata + 5);
355 ddata = &font_bitmap[0];
356 sdata = (
unsigned char *)(fdata + 5);
357 slbytes = (width+7)/8;
358 dlbytes = (dwidth+7)/8;
360 DTPRINTF(0x01,
"Font height %d\n", fheight);
361 DTPRINTF(0x01,
"dwidth : %d\n", dwidth);
362 DTPRINTF(0x01,
"width : %d\n", width);
363 DTPRINTF(0x01,
"height : %d\n", height);
364 DTPRINTF(0x01,
"slbytes: %d\n", slbytes);
365 DTPRINTF(0x01,
"dlbytes: %d\n", dlbytes);
366 DTPRINTF(0x01,
"ox : %d\n", ox);
367 DTPRINTF(0x01,
"oy : %d\n", oy);
369 top = fheight-height-oy;
370 DTPRINTF(0x01,
"TOP : %d\n", top);
373 for(i=0; i<(top * dlbytes); i++) {
380 unsigned char *dp, *sp;
387 for(j=0; j<slbytes; j++) {
390 *(dp + (ox/8)) |= ((*sp) >> (ox & 7));
392 *(dp + (ox/8) + 1) = ((*sp) << (8 - (ox & 7)));
395 short aox = (0 - ox);
396 *(dp + (aox/8)) |= ((*sp) << (aox & 7));
398 *(dp + (aox/8) + 1) = ((*sp) >> (8 - (aox & 7)));
412 if((top+height) < fheight) {
413 int count = (fheight-(top+
height)) * dlbytes;
414 for(i=0; i<count; i++) {
420 XDUMP(0x02, (
unsigned char *)(fdata + 5), slbytes * height);
421 XDUMP(0x02, font_bitmap, dlbytes * fheight);
433 unsigned short draw_char(
short x,
short y,
unsigned short ch)
440 DTFPRINTF(0x02,
"CH : %04X\n", ch);
443 unsigned char str[4] = {0, 0, 0, 0};
445 DTPRINTF(0x01,
"CH : \"%s\"\n", str);
449 ft = get_fontdata(ch);
454 DTPRINTF(0x02,
"start - end : %04X - %04X\n", ft->
start, ft->
end);
456 ip = get_char_bitmap(ch, ft);
458 DTPRINTF(0x04,
"No font ch 0x%04x\n", ch);
459 draw_nofont(x, y, ft);
460 return (
unsigned short)ft->
width;
463 dwidth = (short)(*(ip + 0));
465 fp = create_font_bitmap(ip, ft->
width, ft->
height);
484 return (
unsigned short)dwidth;
501 #ifdef GSC_FONTS_ENABLE_KANJI 503 DTFPRINTF(0x02,
"0x%04X\n", (
int)code);
524 int fwidth = 0, dwidth = 0;
528 #ifdef GSC_FONTS_ENABLE_KANJI 530 DTFPRINTF(0x02,
"0x%04X\n", (
int)code);
536 if((dwidth + fwidth) <= width) {
546 DTFPRINTF(0x01,
"dwidth=%d width=%d\n", dwidth, width);
556 DTPRINTF(0x01,
"BOX X=%d Y=%d W=%d H=%d\n",
565 void draw_wstr(
short x,
short y,
ushort *wstr)
569 while((*wstr) != 0) {
571 DTFPRINTF(0x02,
"0x%04X\n", code);
591 int str_w = 0, str_h = 0;
598 DTPRINTF(0x02,
"STR_W= %d, STR_H= %d\n", str_w, str_h);
614 SYSERR_PRINT(
"Unknow hattr %d\n", hattr);
632 SYSERR_PRINT(
"Unknow vattr %d\n", vattr);
636 DTPRINTF(0x02,
"DX= %d, DY= %d\n", x, y);
652 unsigned short rt = 0;
654 ft = get_fontdata(ch);
658 ip = get_char_bitmap(ch, ft);
662 rt = (
unsigned short)(*(ip+0));
665 DTPRINTF(0x01,
"FWIDTH %d\n", (
int)rt);
686 DTFPRINTF(0x02,
"0x%04X\n", (
int)code);
695 return (
unsigned short)wlen;
unsigned char get_draw_mode(void)
描画モードを取得する
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
int fontset_count(void)
登録されているフォントセットの数を取得する
unsigned short dwidth
1文字のビットマップデータのバイト数
char name[MAX_FONTNAMELEN]
フォントセット名
#define FONT_VATTR_BOTTOM
下寄せ
struct st_surface sur
面の大きさ
unsigned short str_width(unsigned char *str)
カレントフォントセットの文字列幅を取得する
#define GRP_DRAWMODE_NORMAL
Draw the foreground with fore color. Draw the background with back color.
struct st_fontset * get_fontptr_by_name(char *name)
フォントセットのポインタを取得する
#define FONT_FIXEDWIDTH
全フォントを固定幅で描画
struct st_position pos
左上頂点の位置
unsigned short draw_char(short x, short y, unsigned short ch)
文字を描画する
unsigned int get_forecolor(void)
描画の色を取得する
#define FONT_VATTR_CENTER
中心
#define FONT_VATTR_TOP
上寄せ
struct st_fontset * set_font_by_name(char *name)
カレントフォントセットをフォント名で設定する
#define GRP_DRAWMODE_REVERSE
Draw the foreground with back color. Draw the background with fore color.
struct st_fontset * get_fontset(void)
描画に使用されているフォントセット(カレントフォントセット)取得する
unsigned short height
1文字の高さ(ピクセル数)
void draw_line(short x, short y, short xe, short ye)
直線を描画する
void draw_rect(struct st_rect *rect)
矩形を描画する
void draw_str(short x, short y, uchar *str)
文字列を描画する
void set_fontset(struct st_fontset *fontset)
描画に使用するフォントセット(カレントフォントセット)を設定する
int strcomp(const uchar *s1, const uchar *s2)
文字列比較
void draw_bitdata(short px, short py, short width, short height, unsigned char *data, short dw)
ビットデータを描画する
void draw_fill_rect(struct st_rect *rect)
塗りつぶした矩形を描画する
void draw_box(struct st_box *box)
四角を描画する
void draw_str_in_box(struct st_box *box, int hattr, int vattr, unsigned char *str)
四角形内に文字列を描画する
#define FONT_HATTR_CENTER
中心
void set_draw_mode(unsigned char mode)
描画モードを設定する
void set_forecolor(unsigned int color)
描画の色を設定する
void draw_fill_box(struct st_box *box)
塗りつぶした四角を描画する
unsigned int * index
文字コードとビットマップデータのバイト位置の対応データ
int utf16code_to_utf8code(uchar *utf8code, ushort utf16code)
UTF-16 文字から UTF-8 文字へ変換
struct st_font * w_font
全角フォントデータポインタ
const char * fontset_name(int num)
フォント名を取得する
struct st_font * font
半角フォントデータポインタ
#define FONT_HATTR_RIGHT
右寄せ
unsigned short start
開始文字コード
unsigned short width
1文字の幅(ピクセル数)
unsigned short end
終了文字コード
unsigned short ushort
2バイト(UTF-16)文字
unsigned short font_width(unsigned short ch)
カレントフォントセットの文字幅を取得する
void set_font_drawmode(int mode)
フォント描画モードを設定する
#define FONT_HATTR_LEFT
左寄せ
int utf8code_to_utf16code(ushort *utf16code, uchar *utf8code)
UTF-8 文字から UTF-16 文字へ変換
void draw_fixed_width_str(short x, short y, uchar *str, short width)
固定幅で文字列を描画する
unsigned short font_height(void)
カレントフォントセットの文字高さを取得する
signed char * bitmap
各文字フォントのビットマップデータ