nanogui: engine/devfont.c for HAVE_BIG5_SUPPORT


Previous by date: 17 Aug 2000 04:31:06 -0000 Re: config for HAVE_BIG5_SUPPORT, 曾昭明
Next by date: 17 Aug 2000 04:31:06 -0000 nanox/srvmain.c for HAVE_BIG5_SUPPORT, 曾昭明
Previous in thread:
Next in thread:

Subject: engine/devfont.c for HAVE_BIG5_SUPPORT
From: ####@####.####
Date: 17 Aug 2000 04:31:06 -0000
Message-Id: <00d501c00804$9aa0e160$1b0448c0@gv.com.tw>

/*
 * Draw ascii text using COREFONT type font.
 */
void
corefont_drawtext(PMWFONT pfont, PSD psd, MWCOORD x, MWCOORD y,
 const void *text, int cc, int flags)
{
 const unsigned char *str = text;
 MWCOORD  width;   /* width of text area */
 MWCOORD  height;   /* height of text area */
 MWCOORD  base;   /* baseline of text*/
 MWCOORD  startx, starty;
      /* bitmap for characters */
 MWIMAGEBITS bitmap[MAX_CHAR_HEIGHT*MAX_CHAR_WIDTH/MWIMAGE_BITSPERIMAGE];

 pfont->fontprocs->GetTextSize(pfont, str, cc, &width, &height, &base);
 
 if(flags & MWTF_BASELINE)
  y -= base;
 else if(flags & MWTF_BOTTOM)
  y -= (height - 1);
 startx = x;
 starty = y + base;

 switch (GdClipArea(psd, x, y, x + width - 1, y + height - 1)) {
 case CLIP_VISIBLE:
  /*
   * For size considerations, there's no low-level text
   * draw, so we've got to draw all text
   * with per-point clipping for the time being
  if (gr_usebg)
   psd->FillRect(psd, x, y, x + width - 1, y + height - 1,
    gr_background);
  psd->DrawText(psd, x, y, str, cc, gr_foreground, pfont);
  GdFixCursor(psd);
  return;
  */
  break;

 case CLIP_INVISIBLE:
  return;
 }

 /* Get the bitmap for each character individually, and then display
  * them using clipping for each one.
  */
 while (--cc >= 0 && x < psd->xvirtres) {
  unsigned int ch = *str++;
+#if HAVE_BIG5_SUPPORT
+  /* chinese big5 decoding*/
+  if (ch >= 0xA1 && ch <= 0xF9 && cc >= 1 &&
+   ((*str >= 0x40 && *str <= 0x7E) ||
+    (*str >= 0xA1 && *str <= 0xFE)) ) {
+    ch = (ch << 8) | *str++;
+    --cc;
+  }
+#endif
#if HAVE_GB2312_SUPPORT
  /* chinese gb2312 decoding*/
  if (ch >= 0xA1 && ch < 0xF8 && cc >= 1 &&
   *str >= 0xA1 && *str < 0xFF) {
    ch = (ch << 8) | *str++;
    --cc;
  }
#endif
  pfont->fontprocs->GetTextBits(pfont, ch, bitmap, &width,
   &height, &base);

  /* note: change to bitmap*/
  GdBitmap(psd, x, y, width, height, bitmap);
  x += width;
 }

 if (pfont->fontattr & MWTF_UNDERLINE)
  GdLine(psd, startx, starty, x, starty, FALSE);

 GdFixCursor(psd);
}



[Content type application/x-zip-compressed not shown. Download]

Previous by date: 17 Aug 2000 04:31:06 -0000 Re: config for HAVE_BIG5_SUPPORT, 曾昭明
Next by date: 17 Aug 2000 04:31:06 -0000 nanox/srvmain.c for HAVE_BIG5_SUPPORT, 曾昭明
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.