src/drv_comic.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. VF_Init_Driver_Comic
  2. comic_create
  3. comic_close
  4. release_mem
  5. comic_get_metric1
  6. comic_get_fontbbx1
  7. comic_get_bitmap1
  8. comic_get_outline
  9. comic_get_metric2
  10. comic_get_fontbbx2
  11. comic_get_bitmap2
  12. comic_get_font_prop
  13. comic_query_font_type
  14. font_mapping
  15. debug_on

   1 /*
   2  * drv_comic.c - A font driver for font composing like japanese comics.
   3  * by Hirotsugu Kakugawa
   4  *
   5  * 24 Feb 1997  First version.
   6  * 26 Feb 1997  Added 'query_font_type'.
   7  *  6 Aug 1997  VFlib 3.3  Changed API.
   8  *  3 Feb 1998  VFlib 3.4  Changed API.
   9  *  1 Sep 1998  Added capabilities symbol-font, alpha-numeric-font,
  10  *              hirakana-font, katakana-font, greek-font, cyrillic-font,
  11  *              and keisen-font.
  12  * 24 Nov 1998  Added get_fontbbx1() and get_fontbbx2().
  13  *  9 Dec 1999  Fixed a bug in debug_on().
  14  *
  15  */
  16 /*
  17  * Copyright (C) 1997-1998  Hirotsugu Kakugawa. 
  18  * All rights reserved.
  19  *
  20  * This file is part of the VFlib Library.  This library is free
  21  * software; you can redistribute it and/or modify it under the terms of
  22  * the GNU Library General Public License as published by the Free
  23  * Software Foundation; either version 2 of the License, or (at your
  24  * option) any later version.  This library is distributed in the hope
  25  * that it will be useful, but WITHOUT ANY WARRANTY; without even the
  26  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  27  * PURPOSE.  See the GNU Library General Public License for more details.
  28  * You should have received a copy of the GNU Library General Public
  29  * License along with this library; if not, write to the Free Software
  30  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  31  */
  32 
  33 /* MEMO:
  34  *  "kanji-font" cabability:
  35  *       a font entry name for Kanji font.
  36  *  "kana-font"  cabability:
  37  *       a font entry name for Kana, Alphabets, Numerals font.
  38  *
  39  *  This driver assumes character set is JIS X-0208 1990, and 
  40  *  encoding is JIS style.  A glyph for a character whose code point
  41  *  is CODE_POINT is determinted by the code point value:
  42  *    (1) Case (CODE_POINT < 0x3021):
  43  *         --- A glyph for a character of CODE_POINT of a font 
  44  *             given by "kana-font" capability.
  45  *    (2) Otherwise:
  46  *         --- A glyph for a character of CODE_POINT of a font 
  47  *             given by "kanji-font" capability.
  48  *  Note that character set and encoding of font entries given 
  49  *  by "kanji-font" and "kana-font" capabilties must be JIS X 0208 
  50  *  and JIS style.
  51  */
  52 
  53 #include  "config.h"
  54 #include  <stdio.h>
  55 #include  <stdlib.h>
  56 #ifdef HAVE_UNISTD_H
  57 #  include <unistd.h>
  58 #endif
  59 #include  <ctype.h>
  60 #include  "VFlib-3_6.h"
  61 #include  "VFsys.h"
  62 #include  "vflibcap.h"
  63 #include  "cache.h"
  64 #include  "sexp.h"
  65 #include  "str.h"
  66 #include  "path.h"
  67 #include  "comic.h"
  68 
  69 #define  I_KANJI      0
  70 #define  I_KANA       1
  71 #define  I_SYMBOL     2
  72 #define  I_ALNUM      3
  73 #define  I_HIRAKANA   4
  74 #define  I_KATAKANA   5
  75 #define  I_GREEK      6
  76 #define  I_CYRILLIC   7
  77 #define  I_KEISEN     8
  78 #define  I_N          9
  79 
  80 
  81 struct s_font_comic {
  82   char     *font_name;
  83   double   point_size;
  84   double   pixel_size;
  85   double   mag;
  86   double   dpi_x, dpi_y;
  87   int      sub_fid[I_N];
  88   SEXP     props;
  89 };
  90 typedef struct s_font_comic  *FONT_COMIC;
  91 
  92 
  93 Private SEXP_STRING  default_point_size;
  94 Private double       v_default_point_size;
  95 Private SEXP_STRING  default_pixel_size;
  96 Private double       v_default_pixel_size;
  97 Private SEXP_STRING  default_dpi;
  98 Private double       v_default_dpi_x, v_default_dpi_y;
  99 Private SEXP_ALIST   default_properties;
 100 Private SEXP_ALIST   default_variables;
 101 Private SEXP_STRING  default_debug_mode;
 102 
 103 
 104 Private int         comic_create(VF_FONT,char*,char*,int,SEXP);
 105 Private int         comic_close(VF_FONT);
 106 Private int         comic_get_metric1(VF_FONT,long,VF_METRIC1,
 107                                       double,double);
 108 Private int         comic_get_metric2(VF_FONT,long,VF_METRIC2,
 109                                       double,double);
 110 Private int         comic_get_fontbbx1(VF_FONT,double,double,
 111                                        double*,double*,double*,double*);
 112 Private int         comic_get_fontbbx2(VF_FONT,double,double, 
 113                                        int*,int*,int*,int*);
 114 Private VF_BITMAP   comic_get_bitmap1(VF_FONT,long,double,double);
 115 Private VF_BITMAP   comic_get_bitmap2(VF_FONT,long,double,double);
 116 Private VF_OUTLINE  comic_get_outline(VF_FONT,long,double,double);
 117 Private char*       comic_get_font_prop(VF_FONT,char*);
 118 Private int         comic_query_font_type(VF_FONT,long);
 119 Private void        release_mem(FONT_COMIC);
 120 Private int         font_mapping(FONT_COMIC,long);
 121 Private int         debug_on(char type);
 122 
 123 
 124 Public int
 125 VF_Init_Driver_Comic(void)
     /* [<][>][^][v][top][bottom][index][help] */
 126 {
 127   struct s_capability_table  ct[10];
 128   int  z;
 129 
 130   z = 0;
 131   /* VF_CAPE_POINT_SIZE */
 132   ct[z].cap = VF_CAPE_POINT_SIZE;      ct[z].type = CAPABILITY_STRING;
 133   ct[z].ess = CAPABILITY_OPTIONAL;     ct[z++].val = &default_point_size;
 134   /* VF_CAPE_PIXEL_SIZE */
 135   ct[z].cap = VF_CAPE_PIXEL_SIZE;      ct[z].type = CAPABILITY_STRING;
 136   ct[z].ess = CAPABILITY_OPTIONAL;     ct[z++].val = &default_pixel_size;
 137   /* VF_CAPE_DPI */
 138   ct[z].cap = VF_CAPE_DPI;             ct[z].type = CAPABILITY_STRING;
 139   ct[z].ess = CAPABILITY_OPTIONAL;     ct[z++].val = &default_dpi;
 140   /* VF_CAPE_PROPERTIES */
 141   ct[z].cap = VF_CAPE_PROPERTIES;      ct[z].type = CAPABILITY_ALIST;
 142   ct[z].ess = CAPABILITY_OPTIONAL;     ct[z++].val = &default_properties;
 143   /* VF_CAPE_VARIABLE_VALUES */
 144   ct[z].cap = VF_CAPE_VARIABLE_VALUES; ct[z].type = CAPABILITY_ALIST;
 145   ct[z].ess = CAPABILITY_OPTIONAL;     ct[z++].val = &default_variables;
 146   /* VF_CAPE_DEBUG */
 147   ct[z].cap = VF_CAPE_DEBUG;           ct[z].type = CAPABILITY_STRING;
 148   ct[z].ess = CAPABILITY_OPTIONAL;     ct[z++].val = &default_debug_mode;
 149   /* end */
 150   ct[z].cap = NULL; ct[z].type = 0; ct[z].ess = 0; ct[z++].val = NULL;
 151 
 152 
 153   if (vf_cap_GetParsedClassDefault(FONTCLASS_NAME_COMIC, ct, NULL, NULL) 
 154       == VFLIBCAP_PARSED_ERROR)
 155     return -1;
 156 
 157   v_default_point_size = -1;
 158   if (default_point_size != NULL)
 159     v_default_point_size = atof(vf_sexp_get_cstring(default_point_size));
 160 
 161   v_default_pixel_size = -1;
 162   if (default_pixel_size != NULL)
 163     v_default_pixel_size = atof(vf_sexp_get_cstring(default_pixel_size));
 164 
 165   v_default_dpi_x  = -1;
 166   v_default_dpi_y  = -1;
 167   if (default_dpi != NULL)
 168     v_default_dpi_x = v_default_dpi_y = atof(vf_sexp_get_cstring(default_dpi));
 169 
 170   VF_InstallFontDriver(FONTCLASS_NAME_COMIC, 
 171                        (DRIVER_FUNC_TYPE)comic_create);
 172 
 173   return 0;
 174 }
 175 
 176 
 177 Private int
 178 comic_create(VF_FONT font, char *font_class,
     /* [<][>][^][v][top][bottom][index][help] */
 179              char *font_name, int implicit, SEXP entry)
 180 {
 181   FONT_COMIC  font_comic;
 182   SEXP        cap_ch[I_N];
 183   SEXP        cap_point, cap_pixel;
 184   SEXP        cap_mag, cap_dpi, cap_props;
 185   int         i;
 186   struct s_capability_table  ct[20];
 187   int  z;
 188 
 189   z = 0;
 190   /* VF_CAPE_FONT_CLASS */
 191   ct[z].cap = VF_CAPE_FONT_CLASS;          ct[z].type = CAPABILITY_STRING;
 192   ct[z].ess = CAPABILITY_ESSENTIAL;        ct[z++].val = NULL;
 193   /* VF_CAPE_COMIC_KANJI_FONT */
 194   ct[z].cap = VF_CAPE_COMIC_KANJI_FONT;    ct[z].type = CAPABILITY_STRING;
 195   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_KANJI];
 196   /* VF_CAPE_COMIC_KANA_FONT */
 197   ct[z].cap = VF_CAPE_COMIC_KANA_FONT;     ct[z].type = CAPABILITY_STRING;
 198   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_KANA];
 199   /* VF_CAPE_COMIC_SYMBOL_FONT */
 200   ct[z].cap = VF_CAPE_COMIC_SYMBOL_FONT;   ct[z].type = CAPABILITY_STRING;
 201   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_SYMBOL];
 202   /* VF_CAPE_COMIC_ALNUM_FONT */
 203   ct[z].cap = VF_CAPE_COMIC_ALNUM_FONT;    ct[z].type = CAPABILITY_STRING;
 204   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_ALNUM];
 205   /* VF_CAPE_COMIC_HIRAKANA_FONT */
 206   ct[z].cap = VF_CAPE_COMIC_HIRAKANA_FONT; ct[z].type = CAPABILITY_STRING;
 207   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_HIRAKANA];
 208   /* VF_CAPE_COMIC_KATAKANA_FONT */
 209   ct[z].cap = VF_CAPE_COMIC_KATAKANA_FONT; ct[z].type = CAPABILITY_STRING;
 210   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_KATAKANA];
 211   /* VF_CAPE_COMIC_GREEK_FONT */
 212   ct[z].cap = VF_CAPE_COMIC_GREEK_FONT;    ct[z].type = CAPABILITY_STRING;
 213   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_GREEK];
 214   /* VF_CAPE_COMIC_CYRILLIC_FONT */
 215   ct[z].cap = VF_CAPE_COMIC_CYRILLIC_FONT; ct[z].type = CAPABILITY_STRING;
 216   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_CYRILLIC];
 217   /* VF_CAPE_COMIC_KEISEN_FONT */
 218   ct[z].cap = VF_CAPE_COMIC_KEISEN_FONT;   ct[z].type = CAPABILITY_STRING;
 219   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_ch[I_KEISEN];
 220   /* VF_CAPE_POINT_SIZE */
 221   ct[z].cap = VF_CAPE_POINT_SIZE;          ct[z].type = CAPABILITY_STRING;
 222   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_point;
 223   /* VF_CAPE_PIXEL_SIZE */
 224   ct[z].cap = VF_CAPE_PIXEL_SIZE;          ct[z].type = CAPABILITY_STRING;
 225   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_pixel;
 226   /* VF_CAPE_DPI */
 227   ct[z].cap = VF_CAPE_DPI;                 ct[z].type = CAPABILITY_STRING;
 228   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_dpi;
 229   /* VF_CAPE_MAG */
 230   ct[z].cap = VF_CAPE_MAG;                 ct[z].type = CAPABILITY_STRING;
 231   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_mag;
 232   /* VF_CAPE_PROPERTIES */
 233   ct[z].cap = VF_CAPE_PROPERTIES;          ct[z].type = CAPABILITY_ALIST;
 234   ct[z].ess = CAPABILITY_OPTIONAL;         ct[z++].val = &cap_props;
 235   /* end */
 236   ct[z].cap = NULL; ct[z].type = 0; ct[z].ess = 0; ct[z++].val = NULL;
 237 
 238 
 239   /* No support for implicit fonts */
 240   if (implicit == 1)  
 241     return -1;
 242 
 243   /* Only supports explicit fonts */
 244   if (vf_cap_GetParsedFontEntry(entry, font_name, ct, default_variables, NULL) 
 245       == VFLIBCAP_PARSED_ERROR)
 246     return -1;
 247 
 248   font->font_type       = -1;  /* Use comic_query_font_type() */
 249   font->get_metric1     = comic_get_metric1;
 250   font->get_metric2     = comic_get_metric2;
 251   font->get_fontbbx1    = comic_get_fontbbx1;
 252   font->get_fontbbx2    = comic_get_fontbbx2;
 253   font->get_bitmap1     = comic_get_bitmap1;
 254   font->get_bitmap2     = comic_get_bitmap2;
 255   font->get_outline     = comic_get_outline;
 256   font->get_font_prop   = comic_get_font_prop;
 257   font->query_font_type = comic_query_font_type;
 258   font->close           = comic_close;
 259 
 260   ALLOC_IF_ERR(font_comic, struct s_font_comic){
 261     vf_error = VF_ERR_NO_MEMORY;
 262     return -1;
 263   }
 264   if ((font_comic->font_name = vf_strdup(font_name)) == NULL){
 265     vf_error = VF_ERR_NO_MEMORY;
 266     vf_free(font_comic);
 267     return -1;
 268   }
 269 
 270   font_comic->point_size   = v_default_point_size;
 271   font_comic->pixel_size   = v_default_pixel_size;
 272   font_comic->dpi_x        = v_default_dpi_x;
 273   font_comic->dpi_y        = v_default_dpi_y;
 274   font_comic->mag          = 1.0;
 275   for (i = 0; i < I_N; i++)
 276     font_comic->sub_fid[i] = -1;
 277   font_comic->props        = NULL;
 278 
 279   if (implicit == 0){
 280     if (cap_point != NULL)
 281       font_comic->point_size = atof(vf_sexp_get_cstring(cap_point));
 282     if (cap_pixel != NULL)
 283       font_comic->pixel_size = atof(vf_sexp_get_cstring(cap_pixel));
 284     if (cap_dpi != NULL){
 285       font_comic->dpi_x = atof(vf_sexp_get_cstring(cap_dpi));
 286       font_comic->dpi_y = atof(vf_sexp_get_cstring(cap_dpi));
 287     }
 288     if (cap_props != NULL)
 289       font_comic->props = cap_props;
 290   }
 291 
 292   if (font->mode == 1){
 293     for (i = 0; i < I_N; i++){
 294       if ((cap_ch[i] != NULL)
 295           && ((font_comic->sub_fid[i]
 296                = VF_OpenFont1(vf_sexp_get_cstring(cap_ch[i]), 
 297                               font_comic->dpi_x, font_comic->dpi_y,
 298                               font_comic->point_size, 
 299                               font->mag_x * font_comic->mag, 
 300                               font->mag_y * font_comic->mag)) < 0)){
 301         goto CANT_OPEN;
 302       }
 303     }
 304   } else if (font->mode == 2){
 305     for (i = 0; i < I_N; i++){
 306       if ((cap_ch[i] != NULL)
 307           && ((font_comic->sub_fid[i]
 308                = VF_OpenFont2(vf_sexp_get_cstring(cap_ch[i]), 
 309                               font_comic->pixel_size, 
 310                               font->mag_x * font_comic->mag, 
 311                               font->mag_y * font_comic->mag)) < 0)){
 312         goto CANT_OPEN;
 313       }
 314     }
 315   } else {
 316     fprintf(stderr, "VFlib: internal error in comic_create()\n");
 317     abort();
 318   }
 319 
 320   font->private = font_comic;
 321   for (i = 0; i < I_N; i++){
 322     if (cap_ch[i] != NULL)
 323       vf_sexp_free(&cap_ch[i]);
 324   }
 325   vf_sexp_free4(&cap_point, &cap_pixel, &cap_mag, &cap_dpi);
 326   return 0;
 327 
 328 
 329 CANT_OPEN:
 330   for (i = 0; i < I_N; i++){
 331     if (cap_ch[i] != NULL)
 332       vf_sexp_free(&cap_ch[i]);
 333   }
 334   vf_sexp_free4(&cap_point, &cap_pixel, &cap_mag, &cap_dpi);
 335   vf_error = VF_ERR_NO_FONT_ENTRY;
 336   release_mem(font_comic);
 337   return -1;
 338 }
 339 
 340 
 341 Private int
 342 comic_close(VF_FONT font)
     /* [<][>][^][v][top][bottom][index][help] */
 343 {
 344   release_mem((FONT_COMIC)(font->private));
 345 
 346   return 0; 
 347 }
 348 
 349 
 350 Private void
 351 release_mem(FONT_COMIC font_comic)
     /* [<][>][^][v][top][bottom][index][help] */
 352 {
 353   int  i;
 354 
 355   if (font_comic != NULL){
 356     vf_free(font_comic->font_name);
 357     vf_sexp_free1(&font_comic->props);
 358     for (i = 0; i < I_N; i++){
 359       if (font_comic->sub_fid[i] >= 0)
 360         VF_CloseFont(font_comic->sub_fid[i]);
 361     }
 362     vf_free(font_comic);
 363   }
 364 }
 365 
 366 
 367 Private int
 368 comic_get_metric1(VF_FONT font, long code_point, VF_METRIC1 metric,
     /* [<][>][^][v][top][bottom][index][help] */
 369                   double mag_x, double mag_y)
 370 {
 371   FONT_COMIC  font_comic;
 372   int            fid;
 373   
 374   if (metric == NULL){
 375     fprintf(stderr, "VFlib internal error: in comic_get_metric1()\n");
 376     abort();
 377   }
 378 
 379   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 380     fprintf(stderr, "VFlib internal error in comic class.\n");
 381     abort();
 382   }
 383   if ((fid = font_mapping(font_comic, code_point)) < 0)
 384     return -1;
 385 
 386   VF_GetMetric1(fid, code_point, metric, mag_x, mag_y);
 387 
 388   return 0;
 389 }
 390 
 391 
 392 Private int
 393 comic_get_fontbbx1(VF_FONT font, double mag_x, double mag_y,
     /* [<][>][^][v][top][bottom][index][help] */
 394                    double *w_p, double *h_p, double *xoff_p, double *yoff_p)
 395 {
 396   FONT_COMIC  font_comic;
 397   int         i;
 398   double      w, h, xoff, yoff;
 399   
 400   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 401     fprintf(stderr, "VFlib internal error in comic class.\n");
 402     abort();
 403   }
 404 
 405   *w_p = *h_p = *xoff_p = *yoff_p = 0;
 406   w = h = xoff = yoff = 0;
 407   for (i = 0; i < I_N; i++){
 408     if (font_comic->sub_fid[i] < 0)
 409       continue;
 410     if (VF_GetFontBoundingBox1(font_comic->sub_fid[i],
 411                                mag_x, mag_y, &w, &h, &xoff, &yoff) < 0)
 412       continue;
 413     if (w > *w_p)
 414       *w_p = w;
 415     if (h > *h_p)
 416       *h_p = h;
 417     if (xoff < *xoff_p)
 418       *xoff_p = xoff;
 419     if (yoff > *yoff_p)
 420       *yoff_p = yoff;
 421   }
 422 
 423   return 0;
 424 }
 425 
 426 Private VF_BITMAP
 427 comic_get_bitmap1(VF_FONT font, long code_point,
     /* [<][>][^][v][top][bottom][index][help] */
 428                   double mag_x, double mag_y)
 429 {
 430   FONT_COMIC  font_comic;
 431   int            fid;
 432 
 433   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 434     fprintf(stderr, "VFlib internal error in comic class.\n");
 435     abort();
 436   }
 437   if ((fid = font_mapping(font_comic, code_point)) < 0)
 438     return NULL;
 439 
 440   return VF_GetBitmap1(fid, code_point, mag_x, mag_y);
 441 }
 442 
 443 
 444 Private VF_OUTLINE
 445 comic_get_outline(VF_FONT font, long code_point,
     /* [<][>][^][v][top][bottom][index][help] */
 446                   double mag_x, double mag_y)
 447 {
 448   FONT_COMIC  font_comic;
 449   int            fid;
 450 
 451   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 452     fprintf(stderr, "VFlib internal error in comic class.\n");
 453     abort();
 454   }
 455   if ((fid = font_mapping(font_comic, code_point)) < 0)
 456     return NULL;
 457 
 458   return VF_GetOutline(fid, code_point, mag_x, mag_y);
 459 }
 460 
 461 
 462 Private int
 463 comic_get_metric2(VF_FONT font, long code_point, VF_METRIC2 metric, 
     /* [<][>][^][v][top][bottom][index][help] */
 464                   double mag_x, double mag_y)
 465 {
 466   FONT_COMIC  font_comic;
 467   int            fid;
 468 
 469   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 470     fprintf(stderr, "VFlib internal error in comic class.\n");
 471     abort();
 472   }
 473   if ((fid = font_mapping(font_comic, code_point)) < 0)
 474     return -1;
 475 
 476   VF_GetMetric2(fid, code_point, metric, mag_x, mag_y);
 477 
 478   return 0;
 479 }
 480 
 481 Private int
 482 comic_get_fontbbx2(VF_FONT font, double mag_x, double mag_y,
     /* [<][>][^][v][top][bottom][index][help] */
 483                    int*w_p, int *h_p, int *xoff_p, int *yoff_p)
 484 {
 485   FONT_COMIC  font_comic;
 486   int         w, h, xoff, yoff;
 487   int         i;
 488   
 489   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 490     fprintf(stderr, "VFlib internal error in comic class.\n");
 491     abort();
 492   }
 493 
 494   *w_p = *h_p = *xoff_p = *yoff_p = 0;
 495   w = h = xoff = yoff = 0;
 496   for (i = 0; i < I_N; i++){
 497     if (font_comic->sub_fid[i] < 0)
 498       continue;
 499     if (VF_GetFontBoundingBox2(font_comic->sub_fid[i],
 500                                mag_x, mag_y, &w, &h, &xoff, &yoff) < 0)
 501       continue;
 502     if (w > *w_p)
 503       *w_p = w;
 504     if (h > *h_p)
 505       *h_p = h;
 506     if (xoff < *xoff_p)
 507       *xoff_p = xoff;
 508     if (yoff > *yoff_p)
 509       *yoff_p = yoff;
 510   }
 511 
 512   return 0;
 513 }
 514 
 515 
 516 Private VF_BITMAP
 517 comic_get_bitmap2(VF_FONT font, long code_point, 
     /* [<][>][^][v][top][bottom][index][help] */
 518                   double mag_x, double mag_y)
 519 {
 520   FONT_COMIC  font_comic;
 521   int            fid;
 522 
 523   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 524     fprintf(stderr, "VFlib internal error in comic class.\n");
 525     abort();
 526   }
 527   if ((fid = font_mapping(font_comic, code_point)) < 0)
 528     return NULL;
 529 
 530   return VF_GetBitmap2(fid, code_point, mag_x, mag_y);
 531 }
 532 
 533 
 534 Private char*
 535 comic_get_font_prop(VF_FONT font, char *prop_name)
     /* [<][>][^][v][top][bottom][index][help] */
 536 {
 537   FONT_COMIC  font_comic;
 538   int            fid;
 539 
 540   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 541     fprintf(stderr, "VFlib internal error in comic class.\n");
 542     abort();
 543   }
 544   /* Get prop for Kanji font, not Kana font */
 545   if ((fid = font_mapping(font_comic, (long)0x3021)) < 0)
 546     return NULL;
 547 
 548   return VF_GetFontProp(fid, prop_name);
 549 }
 550 
 551 
 552 Private int
 553 comic_query_font_type(VF_FONT font, long code_point)
     /* [<][>][^][v][top][bottom][index][help] */
 554 {
 555   FONT_COMIC  font_comic;
 556   int         fid;
 557 
 558   if ((font_comic = (FONT_COMIC)font->private) == NULL){
 559     fprintf(stderr, "VFlib internal error in comic class.\n");
 560     abort();
 561   }
 562   if ((fid = font_mapping(font_comic, code_point)) < 0)
 563     return -1;
 564 
 565   return VF_QueryFontType(fid, code_point);
 566 }
 567 
 568 
 569 Private int
 570 font_mapping(FONT_COMIC font_comic, long code_point)
     /* [<][>][^][v][top][bottom][index][help] */
 571 {
 572   int   code_hi;
 573   int   fid, alt;
 574 
 575   code_hi = code_point / 0x100;
 576 
 577   if ((code_hi < 0x21) || (0x78 < code_hi)){
 578     vf_error = VF_ERR_ILL_CODE_POINT;
 579     return -1;
 580   } else {
 581     switch (code_hi){
 582     default: 
 583       alt = -1;
 584       fid = font_comic->sub_fid[I_KANJI];    break;
 585     case 0x21:
 586     case 0x22:
 587       alt = font_comic->sub_fid[I_KANA];
 588       fid = font_comic->sub_fid[I_SYMBOL];   break;
 589     case 0x23:
 590       alt = font_comic->sub_fid[I_KANA];
 591       fid = font_comic->sub_fid[I_ALNUM];    break;
 592     case 0x24:
 593       alt = font_comic->sub_fid[I_KANA];
 594       fid = font_comic->sub_fid[I_HIRAKANA]; break;
 595     case 0x25:
 596       alt = font_comic->sub_fid[I_KANA];
 597       fid = font_comic->sub_fid[I_KATAKANA]; break;
 598     case 0x26:
 599       alt = font_comic->sub_fid[I_KANA];
 600       fid = font_comic->sub_fid[I_GREEK];    break;
 601     case 0x27:
 602       alt = font_comic->sub_fid[I_KANA];
 603       fid = font_comic->sub_fid[I_CYRILLIC]; break;
 604     case 0x28:
 605       alt = font_comic->sub_fid[I_KANA];
 606       fid = font_comic->sub_fid[I_KEISEN];   break;
 607     }
 608     if (fid < 0)
 609       fid = alt;
 610   }
 611 
 612   if (debug_on('m'))
 613     printf("VFlib Japanese Comic:  Code Point: 0x%lx, FID: %d\n",
 614            code_point,  fid);
 615 
 616   return fid;
 617 }
 618 
 619 
 620 Private int
 621 debug_on(char type)
     /* [<][>][^][v][top][bottom][index][help] */
 622 {
 623   char  *p;
 624 
 625   if (default_debug_mode == NULL)
 626     return FALSE;
 627   if ((p = vf_sexp_get_cstring(default_debug_mode)) == NULL)
 628     return FALSE;
 629   
 630   while (*p != '\0'){
 631     if (*p == type)
 632       return TRUE;
 633     p++;
 634   }
 635 
 636   while (*p != '\0'){
 637     if (*p == '*')
 638       return TRUE;
 639     p++;
 640   }
 641 
 642   return FALSE;
 643 }
 644 
 645 
 646 /*EOF*/

/* [<][>][^][v][top][bottom][index][help] */