File: [jp.NetBSD.org] / othersrc / mgl / mgl2 / lib / font_engine.c (download)
Revision 1.7, Sat Sep 9 03:34:03 2000 UTC (23 years, 6 months ago) by suz
Branch: MAIN
CVS Tags: HEAD, BEFORE_KEYMAP, ALPHA_020_PRE6, ALPHA_020_PRE4, ALPHA_020_PRE3, ALPHA_020_PRE2, ALPHA_020_PRE, ALPHA_020, ALPHA_019p3, ALPHA_019, ALPHA_018p9, ALPHA_018p8, ALPHA_018p7, ALPHA_018p6, ALPHA_018p5, ALPHA_018p4, ALPHA_018p3, ALPHA_018p2, ALPHA_018p10 Changes since 1.6: +47 -0
lines
alpha 018p2
|
/*
* MGL -- MobileGear Graphic Library -
* Copyright (C) 1998, 1999
* Koji Suzuki (suz@at.sakura.ne.jp)
* Yukihiko Sano (yukihiko@yk.rim.or.jp)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY KOJI SUZUKI AND YUKIHIKO SANO ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include "mgl2.h"
void set_font(int size,int type) {
mgl_fe->_set_font(current_screen,size,type);
}
int load_font(char *fname, int width, int height) {
return mgl_fe->_load_font(fname,width,height);
}
void draw_font(int x, int y, int code, int dir) {
mgl_fe->_draw_font(current_screen,x,y,code,dir);
}
/* x,y から、str の文字列を描画します。
注意) x,y は、文字の左上の座標です。
*/
void draw_string(int x, int y, char *str, int dir) {
int code;
int d = 0;
while (*str) {
d = 0;
if (*str & 0x80) {
if (*(unsigned char *)str == 0x8e) {
code = (*str++ << 8) & 0xffff;
code |= *str++ & 0xff;
mgl_fe->_draw_font(current_screen,x,y,code,dir);
d = pen_font->width/2;
}else{
code = (*str++ << 8) & 0xffff;
code |= *str++ & 0xff;
mgl_fe->_draw_font(current_screen,x,y,code,dir);
d = pen_font->width;
}
} else {
mgl_fe->_draw_font(current_screen,x,y,*str++ & 0xff,dir);
d += pen_font->width/2;
}
switch(dir) {
case DIR_NORTH:
x += d;
break;
case DIR_WEST:
y -= d;
break;
case DIR_SOUTH:
x -= d;
break;
case DIR_EAST:
y += d;
}
}
return;
}
void mgl2_set_font(struct screen *s,int size,int type) {
mgl_fe->_set_font(s,size,type);
}
void mgl2_draw_font(struct screen *s,int x, int y, int code, int dir) {
mgl_fe->_draw_font(s,x,y,code,dir);
}
void mgl2_draw_string(struct screen *s,int x, int y, char *str, int dir) {
int code;
int d = 0;
while (*str) {
d = 0;
if (*str & 0x80) {
if (*(unsigned char *)str == 0x8e) {
code = (*str++ << 8) & 0xffff;
code |= *str++ & 0xff;
mgl_fe->_draw_font(s,x,y,code,dir);
d = s->_pen_font.width/2;
}else{
code = (*str++ << 8) & 0xffff;
code |= *str++ & 0xff;
mgl_fe->_draw_font(s,x,y,code,dir);
d = s->_pen_font.width;
}
} else {
mgl_fe->_draw_font(s,x,y,*str++ & 0xff,dir);
d += s->_pen_font.width/2;
}
switch(dir) {
case DIR_NORTH:
x += d;
break;
case DIR_WEST:
y -= d;
break;
case DIR_SOUTH:
x -= d;
break;
case DIR_EAST:
y += d;
}
}
return;
}