Diff for /np2/x11/gtk2/gtk_font.c between versions 1.2 and 1.5

version 1.2, 2004/07/15 14:24:33 version 1.5, 2005/04/01 15:11:45
Line 12 Line 12
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    documentation and/or other materials provided with the distribution.
  * 3. The name of the author may not be used to endorse or promote products  
  *    derived from this software without specific prior written permission.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES   * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Line 227  fontmng_getsize(void *hdl, const char *s Line 225  fontmng_getsize(void *hdl, const char *s
         int width;          int width;
         int len;          int len;
   
         if ((fhdl == NULL) || (str == NULL))          if ((fhdl == NULL) || (str == NULL)) {
                 return FAILURE;                  return FAILURE;
           }
   
         width = 0;          width = 0;
         buf[2] = '\0';  
         for (;;) {          for (;;) {
                 buf[0] = *str++;                  while ((len = milstr_charsize(str)) != 0) {
                 if ((((buf[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c && *str != '\0') {                          memcpy(buf, str, len * sizeof(char));
                         buf[1] = *str++;                          buf[len] = '\0';
                         len = 2;                          getlength1(fhdl, &fdat, buf, len);
                 } else if (buf[0] >= 0xa1 && buf[1] <= 0xdf) {                          width += fdat.pitch;
                         buf[1] = buf[0];  
                         buf[0] = 0x8e;  
                         len = 1;  
                 } else if (buf[0]) {  
                         buf[1] = '\0';  
                         len = 1;  
                 } else {  
                         break;  
                 }                  }
                 getlength1(fhdl, &fdat, buf, len);  
                 width += fdat.pitch;  
         }          }
         if (pt) {          if (pt) {
                 pt->x = width;                  pt->x = width;
Line 267  fontmng_getdrawsize(void *hdl, const cha Line 255  fontmng_getdrawsize(void *hdl, const cha
         int len;          int len;
         int posx;          int posx;
   
         if ((hdl == NULL) || (str == NULL))          if ((hdl == NULL) || (str == NULL)) {
                 return FAILURE;                  return FAILURE;
           }
   
         width = 0;          width = 0;
         posx = 0;          posx = 0;
         buf[2] = '\0';  
         for (;;) {          for (;;) {
                 buf[0] = *str++;                  while ((len = milstr_charsize(str)) != 0) {
                 if ((((buf[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c && *str != '\0') {                          memcpy(buf, str, len * sizeof(char));
                         buf[1] = *str++;                          buf[len] = '\0';
                         len = 2;                          getlength1(fhdl, &fdat, buf, len);
                 } else if (buf[0] >= 0xa1 && buf[0] <= 0xdf) {                          width = posx + max(fdat.width, fdat.pitch);
                         buf[1] = buf[0];                          posx += fdat.pitch;
                         buf[0] = 0x8e;  
                         len = 1;  
                 } else if (buf[0]) {  
                         buf[1] = '\0';  
                         len = 1;  
                 } else {  
                         break;  
                 }                  }
                 getlength1(fhdl, &fdat, buf, len);  
                 width = posx + max(fdat.width, fdat.pitch);  
                 posx += fdat.pitch;  
         }          }
         if (pt) {          if (pt) {
                 pt->x = width;                  pt->x = width;
Line 312  fontmng_get(void *hdl, const char *str) Line 290  fontmng_get(void *hdl, const char *str)
                 return NULL;                  return NULL;
         }          }
   
         if (((((str[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) && (str[1] != '\0')) {          while ((len = milstr_charsize(str)) != 0) {
                 codecnv_sjis2euc(buf, 4, str, 2);                  memcpy(buf, str, len * sizeof(char));
                 len = 2;                  buf[len] = '\0';
         } else if ((UINT8)str[0] >= 0xa1 && (UINT8)str[0] <= 0xdf) {                  utf8 = g_locale_to_utf8(buf, -1, NULL, NULL, NULL);
                 buf[0] = 0x8e;                  if (utf8) {
                 buf[1] = str[0];                          getfont1(fhdl, fdat, utf8, len);
                 buf[2] = '\0';                          g_free(utf8);
                 len = 1;                  }
         } else {                  str += len;
                 buf[0] = str[0];  
                 buf[1] = '\0';  
                 len = 1;  
         }  
         utf8 = g_locale_to_utf8(buf, -1, NULL, NULL, NULL);  
         if (utf8) {  
                 getfont1(fhdl, fdat, utf8, len);  
                 g_free(utf8);  
                 return fdat;  
         }          }
         return NULL;          return fdat;
 }  }

Removed from v.1.2  
changed lines
  Added in v.1.5


RetroPC.NET-CVS <cvs@retropc.net>