nanogui@linuxhacker.org
drivers/genfont.c for HAVE BIG5 SUPPORT
/*
* Generalized low level routine to calc bounding box for text output.
* Handles both fixed and proportional fonts. Passed ascii string.
*/
void
gen gettextsize(PMWFONT pfont, const void *text, int cc,
MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase)
{
PMWCFONT pf = ((PMWCOREFONT)pfont)->cfont;
const unsigned char * str = text;
unsigned int c;
int width;
if(pf->width == NULL)
width = cc * pf->maxwidth;
else {
width = 0;
while(--cc >= 0) {
c = *str++;
+#if HAVE BIG5 SUPPORT
+ /* chinese big5 decoding*/
+ if (c >= 0xA1 && c <= 0xF9 && cc >= 1 &&
+ ((*str >= 0x40 && *str <= 0x7E) ||
+ (*str >= 0xA1 && *str <= 0xFE)) ) {
+ --cc;
+ ++str;
+ width += 12; /* FIXME*/
+ } else
+#endif
#if HAVE GB2312 SUPPORT
/* chinese gb2312 decoding*/
if (c >= 0xA1 && c < 0xF8 && cc >= 1 &&
*str >= 0xA1 && *str < 0xFF) {
--cc;
++str;
width += 12; /* FIXME*/
} else
#endif
if(c >= pf->firstchar && c < pf->firstchar+pf->size)
width += pf->width[c - pf->firstchar];
}
}
*pwidth = width;
*pheight = pf->height;
*pbase = pf->ascent;
}
/*
* Generalized low level routine to get the bitmap associated
* with a character. Handles fixed and proportional fonts.
*/
void
gen gettextbits(PMWFONT pfont, int ch, MWIMAGEBITS *retmap,
MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase)
{
PMWCFONT pf = ((PMWCOREFONT)pfont)->cfont;
int n, count, width;
MWIMAGEBITS * bits;
+#if HAVE BIG5 SUPPORT
+ /* decode chinese big5*/
+ int CH = ((unsigned int)ch) >> 8, CL = ((unsigned int)ch) & 0xFF;
+ if (CH >= 0xA1 && CH <= 0xF9 && ((CL >= 0x40 && CL <= 0x7E) || (CL >= 0xA1 && CL <=
0xFE)) )
+ {
+ int Pos;//!= ((CH - 0xA1) * 94 + (CL - 0xA1)) * 18;
+
+ int i;
+ extern unsigned char JMT BIG5 12X12 FONT BITMAP[];
+
+ int seq;
+ {
+ seq=0;
+ /* ladd=loby-(if(loby<127)?64:98) */
+ CL/*c2*/-=(CL/*c2*/<127?64:98);
+
+ /* hadd=(hiby-164)*157 */
+ if (CH/*c1*/>=0xa4)//standard font
+ {
+ seq=(((CH/*c1*/-164)*157)+CL/*c2*/);
+ if (seq>=5809) seq-=408;
+ }
+
+ /* hadd=(hiby-161)*157 */
+ if (CH/*c1*/<=0xa3)//special font
+ seq=(((CH/*c1*/-161)*157)+CL/*c2*/)+13094;
+ }
+ Pos=seq*18;
+
+ *pwidth = width = 12;
+ *pheight = 12;
+ *pbase = 0;
+
+ for (i = 0; i < 6; i++) {
+ unsigned char *DstBitmap = ((unsigned char *)retmap) + i * 4;
+ unsigned char *FontBitmap = JMT BIG5 12X12 FONT BITMAP +
+ Pos + i * 3;
+ DstBitmap[0] = FontBitmap[1];
+ DstBitmap[1] = FontBitmap[0];
+ DstBitmap[2] = FontBitmap[1] << 4;
+ DstBitmap[3] = FontBitmap[2];
+ }
+ return;
+ }
+#endif /* HAVE BIG5 SUPPORT*/
#if HAVE GB2312 SUPPORT
/* decode chinese gb2312*/
int CH = ((unsigned int)ch) >> 8, CL = ((unsigned int)ch) & 0xFF;
if (CH >= 0xA1 && CH < 0xF8 && CL >= 0xA1 && CL < 0xFF) {
int Pos = ((CH - 0xA1) * 94 + (CL - 0xA1)) * 18;
int i;
extern unsigned char GUO GB2312 12X12 FONT BITMAP[];
*pwidth = width = 12;
*pheight = 12;
*pbase = 0;
for (i = 0; i < 6; i++) {
unsigned char *DstBitmap = ((unsigned char *)retmap) + i * 4;
unsigned char *FontBitmap = GUO GB2312 12X12 FONT BITMAP +
Pos + i * 3;
DstBitmap[0] = FontBitmap[1];
DstBitmap[1] = FontBitmap[0];
DstBitmap[2] = FontBitmap[1] << 4;
DstBitmap[3] = FontBitmap[2];
}
return;
}
#endif /* HAVE GB2312 SUPPORT*/
/* if char not in font, map to first character by default*/
if(ch < pf->firstchar || ch >= pf->firstchar+pf->size)
ch = pf->firstchar;
ch -= pf->firstchar;
/* get font bitmap depending on fixed pitch or not*/
bits = pf->bits + (pf->offset? pf->offset[ch]: (pf->height * ch));
width = pf->width ? pf->width[ch] : pf->maxwidth;
count = MWIMAGE WORDS(width) * pf->height;
for(n=0; n<count; ++n)
*retmap++ = *bits++;
/* return width depending on fixed pitch or not*/
*pwidth = width;
*pheight = pf->height;
*pbase = pf->ascent;
}
drivers/genfont.c for HAVE BIG5 SUPPORT
/*
* Generalized low level routine to calc bounding
box for text output.
* Handles both fixed and proportional fonts.
Passed ascii string.
*/
void
gen gettextsize(PMWFONT pfont, const
void *text, int cc,
MWCOORD *pwidth, MWCOORD *pheight, MWCOORD
*pbase)
{
PMWCFONT pf =
((PMWCOREFONT)pfont)->cfont;
const unsigned char * str =
text;
unsigned
int c;
int width;
if(pf->width == NULL)
width = cc *
pf->maxwidth;
else {
width =
0;
while(--cc >= 0) {
c = *str++;
+#if
HAVE BIG5 SUPPORT
+ /* chinese big5
decoding*/
+ if (c >= 0xA1 && c <= 0xF9
&& cc >= 1 &&
+ ((*str >= 0x40
&& *str <= 0x7E) ||
+ (*str >= 0xA1
&& *str <= 0xFE)) )
{
+ --cc;
+ ++str;
+ width
+= 12; /* FIXME*/
+ } else
+#endif
#if
HAVE GB2312 SUPPORT
/* chinese gb2312
decoding*/
if (c >= 0xA1 && c < 0xF8
&& cc >= 1 &&
*str >= 0xA1
&& *str < 0xFF)
{
--cc;
++str;
width
+= 12; /* FIXME*/
}
else
#endif
if(c >=
pf->firstchar && c <
pf->firstchar+pf->size)
width += pf->width[c -
pf->firstchar];
}
}
*pwidth =
width;
*pheight = pf->height;
*pbase =
pf->ascent;
}
/*
* Generalized low level routine to get the bitmap
associated
* with a character. Handles fixed and proportional
fonts.
*/
void
gen gettextbits(PMWFONT pfont, int ch, MWIMAGEBITS
*retmap,
MWCOORD *pwidth, MWCOORD *pheight, MWCOORD
*pbase)
{
PMWCFONT pf =
((PMWCOREFONT)pfont)->cfont;
int n, count,
width;
MWIMAGEBITS * bits;
+#if HAVE BIG5 SUPPORT
+ /* decode chinese
big5*/
+ int CH = ((unsigned int)ch) >> 8, CL = ((unsigned int)ch)
& 0xFF;
+ if (CH >= 0xA1 && CH <= 0xF9 && ((CL
>= 0x40 && CL <= 0x7E) || (CL >= 0xA1 && CL <=
0xFE)) )
+ {
+ int Pos;//!= ((CH - 0xA1) *
94 + (CL - 0xA1)) * 18;
+
+ int i;
+
extern unsigned char JMT BIG5 12X12 FONT BITMAP[];
+
+ int
seq;
+ {
+ seq=0;
+ /* ladd=loby-(if(loby<127)?64:98)
*/
+ CL/*c2*/-=(CL/*c2*/<127?64:98);
+
+ /* hadd=(hiby-164)*157 */
+ if
(CH/*c1*/>=0xa4)//standard
font
+ {
+ seq=(((CH/*c1*/-164)*157)+CL/*c2*/);
+ if
(seq>=5809) seq-=408;
+ }
+
+ /* hadd=(hiby-161)*157 */
+ if
(CH/*c1*/<=0xa3)//special
font
+ seq=(((CH/*c1*/-161)*157)+CL/*c2*/)+13094;
+
}
+ Pos=seq*18;
+
+ *pwidth = width =
12;
+ *pheight = 12;
+
*pbase = 0;
+
+ for (i = 0; i < 6; i++)
{
+ unsigned char *DstBitmap = ((unsigned char *)retmap) + i
* 4;
+ unsigned char *FontBitmap = JMT BIG5 12X12 FONT BITMAP
+
+ Pos + i * 3;
+ DstBitmap[0] =
FontBitmap[1];
+ DstBitmap[1] =
FontBitmap[0];
+ DstBitmap[2] = FontBitmap[1] <<
4;
+ DstBitmap[3] = FontBitmap[2];
+
}
+ return;
+ }
+#endif /*
HAVE BIG5 SUPPORT*/
#if HAVE GB2312 SUPPORT
/* decode chinese
gb2312*/
int CH = ((unsigned int)ch) >> 8, CL = ((unsigned
int)ch) & 0xFF;
if (CH >= 0xA1 && CH < 0xF8
&& CL >= 0xA1 && CL < 0xFF) {
int Pos = ((CH - 0xA1) * 94 + (CL - 0xA1)) * 18;
int
i;
extern unsigned char
GUO GB2312 12X12 FONT BITMAP[];
*pwidth = width =
12;
*pheight = 12;
*pbase = 0;
for (i = 0; i < 6; i++)
{
unsigned char *DstBitmap = ((unsigned char *)retmap) + i
* 4;
unsigned char *FontBitmap = GUO GB2312 12X12 FONT BITMAP
+
Pos + i * 3;
DstBitmap[0] =
FontBitmap[1];
DstBitmap[1] =
FontBitmap[0];
DstBitmap[2] = FontBitmap[1] <<
4;
DstBitmap[3] = FontBitmap[2];
}
return;
}
#endif /*
HAVE GB2312 SUPPORT*/
/* if char not in font, map to first character by
default*/
if(ch < pf->firstchar || ch >=
pf->firstchar+pf->size)
ch = pf->firstchar;
ch -= pf->firstchar;
/* get font bitmap depending on fixed pitch or
not*/
bits = pf->bits + (pf->offset? pf->offset[ch]:
(pf->height * ch));
width = pf->width ? pf->width[ch] :
pf->maxwidth;
count = MWIMAGE WORDS(width) *
pf->height;
for(n=0; n<count; ++n)
*retmap++ =
*bits++;
/* return width depending on fixed pitch or
not*/
*pwidth = width;
*pheight =
pf->height;
*pbase =
pf->ascent;
}
["application/x-zip-compressed" not shown]