Back to index

tetex-bin  3.0
font_routines.c
Go to the documentation of this file.
00001 /* font_routines.c: Data structures for virtual font support
00002 
00003 This file is part of Omega,
00004 which is based on the web2c distribution of TeX,
00005 
00006 Copyright (c) 1994--2001 John Plaice and Yannis Haralambous
00007 
00008 Omega is free software; you can redistribute it and/or modify
00009 it under the terms of the GNU General Public License as published by
00010 the Free Software Foundation; either version 2 of the License, or
00011 (at your option) any later version.
00012 
00013 Omega is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Omega; if not, write to the Free Software Foundation, Inc.,
00020 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00021 
00022 */
00023 
00024 #include "cpascal.h"
00025 #include "manifests.h"
00026 #include "dvi.h"
00027 #include "error_routines.h"
00028 #include "list_routines.h"
00029 #include "font_routines.h"
00030 #include "char_routines.h"
00031 #include "header_routines.h"
00032 #include "print_routines.h"
00033 #include "out_routines.h"
00034 #include "omfonts.h"
00035 
00036 #define BLOCK 256
00037 
00038 font *font_table = NULL;
00039 unsigned font_table_size = 0;
00040 unsigned no_fonts = 0;
00041 font *cur_font = NULL;
00042 unsigned cur_font_index = 0;
00043 
00044 unsigned vtitle_length = 0;
00045 unsigned vf_check_sum = 0;
00046 unsigned vf_design_size = 0;
00047 
00048 void
00049 font_table_init(void)
00050 {
00051     font_table_size = BLOCK;
00052     font_table = (font *) xmalloc(font_table_size);
00053     no_fonts = 0;
00054 }
00055 
00056 void
00057 font_no_incr(void)
00058 {
00059     if (no_fonts == font_table_size) {
00060        font_table_size += BLOCK;
00061        font_table = (font *) xrealloc(font_table, font_table_size);
00062     }
00063     no_fonts++;
00064 }
00065 
00066 void
00067 clear_map_font(int font_number)
00068 {
00069     if (cur_font==NULL) internal_error_0("clear_map_font");
00070     cur_font->font_number = font_number;
00071     cur_font->font_name = NULL;
00072     cur_font->font_area = NULL;
00073     cur_font->font_at = 0;
00074     cur_font->font_checksum = 0;
00075     cur_font->font_dsize = 10*UNITY;
00076     cur_font->font_at_defined = FALSE;
00077     cur_font->font_checksum_defined = FALSE;
00078     cur_font->font_dsize_defined = FALSE;
00079     cur_font->ovf_packet = NULL;
00080     cur_font->ovf_packet_length = 0;
00081 }
00082 
00083 void
00084 init_map_font(int font_number)
00085 {
00086     unsigned i=0;
00087 
00088     while (i<no_fonts) {
00089         if (font_number == font_table[i].font_number) {
00090              warning_1("MAPFONT index (D %d) previously defined; "
00091               "old definition ignored", font_number);
00092             cur_font = &font_table[i];
00093             if (cur_font->font_area != NULL) 
00094                 free(cur_font->font_area);
00095             if (cur_font->font_name != NULL) 
00096                 free(cur_font->font_name);
00097             if (cur_font->ovf_packet != NULL) 
00098                 free(cur_font->ovf_packet);
00099             clear_map_font(font_number);
00100             break;
00101         }
00102         i++;
00103     }
00104     if (i==no_fonts) {
00105         font_no_incr();
00106         cur_font = &font_table[i];
00107         clear_map_font(font_number);
00108     }
00109     packet_table_init();
00110     append_command(DVI_FNT_DEF_1, i);
00111     cur_font_index = i;
00112     cur_font = &font_table[i];
00113     cur_font->ovf_packet = cur_packet;
00114     cur_font->ovf_packet_length = packet_ptr;
00115     packet_table_end();
00116 
00117 }
00118 
00119 void
00120 set_font_name(string name)
00121 {
00122     if (cur_font==NULL) {
00123         internal_error_0("set_font_name");
00124     }
00125     if (cur_font->font_name != NULL) {
00126         warning_0("FONTNAME previously defined; old value ignored");
00127         free(cur_font->font_name);
00128         cur_font->font_name=NULL;
00129     }
00130     cur_font->font_name = name;
00131 }
00132 
00133 void
00134 set_font_area(string area)
00135 {
00136     if (cur_font==NULL) {
00137         internal_error_0("set_font_area");
00138     }
00139     if (cur_font->font_area != NULL) {
00140         warning_0("FONTAREA previously defined; old value ignored");
00141         free(cur_font->font_area);
00142         cur_font->font_area=NULL;
00143     }
00144     cur_font->font_area = area;
00145 }
00146 
00147 void
00148 set_font_check_sum(unsigned cs)
00149 {
00150     if (cur_font==NULL) {
00151         internal_error_0("set_font_check_sum");
00152     }
00153     if (cur_font->font_checksum_defined != FALSE) {
00154         warning_0("FONTCHECKSUM previously defined; old value ignored");
00155     }
00156     cur_font->font_checksum = cs;
00157     cur_font->font_checksum_defined = TRUE;
00158 }
00159 
00160 void
00161 set_font_at(fix at)
00162 {
00163     if (cur_font==NULL) {
00164         internal_error_0("set_font_at");
00165     }
00166     if (cur_font->font_at_defined != FALSE) {
00167         warning_0("FONTAT previously defined; old value ignored");
00168     }
00169     cur_font->font_at = at;
00170     cur_font->font_at_defined = TRUE;
00171 }
00172 
00173 void
00174 set_font_design_size(fix ds)
00175 {
00176     if (cur_font==NULL) {
00177         internal_error_0("set_font_design_size");
00178     }
00179     if (cur_font->font_dsize_defined != FALSE) {
00180         warning_0("FONTDSIZE previously defined; old value ignored");
00181     }
00182     cur_font->font_dsize = ds;
00183     cur_font->font_dsize_defined = TRUE;
00184 }
00185 
00186 string vtitle = NULL;
00187 
00188 void
00189 set_vtitle(string title)
00190 {
00191     if (vtitle!=NULL) {
00192         warning_0("VTITLE previously defined; old value ignored");
00193         free(vtitle); vtitle = NULL;
00194     }
00195     vtitle = title;
00196 }
00197 
00198 unsigned packet_table_size = 0;
00199 unsigned char *packet_table = NULL;
00200 unsigned char *cur_packet = NULL;
00201 unsigned packet_ptr = 0;
00202 
00203 void
00204 packet_table_init(void)
00205 {
00206     packet_table_size = BLOCK;
00207     packet_table = (unsigned char *) xmalloc(packet_table_size);
00208     packet_ptr = 0;
00209     cur_packet = packet_table;
00210 }
00211 
00212 void
00213 packet_ptr_incr(void)
00214 {
00215     if (packet_ptr == packet_table_size) {
00216         packet_table_size += BLOCK;
00217         packet_table = (unsigned char *)
00218                        xrealloc(packet_table, packet_table_size);
00219     }
00220     packet_ptr++;
00221 }
00222 
00223 void
00224 append_to_packet(unsigned val)
00225 {
00226     packet_ptr_incr();
00227     packet_table[packet_ptr-1] = val & 0xff;
00228 }
00229 
00230 void
00231 init_map(void)
00232 {
00233     move_table_init();
00234     packet_table_init();
00235 }
00236 
00237 void
00238 end_map(void)
00239 {
00240     current_character->ovf_packet = cur_packet;
00241     current_character->ovf_packet_length = packet_ptr;
00242     packet_table_end();
00243 }
00244 
00245 void
00246 append_command_2(unsigned cmd_0, unsigned max_n,
00247                  unsigned cmd_1, unsigned actual)
00248 {
00249     if ((actual < 0) || (actual > 0x7fffffff))
00250         internal_error_1("append_command (actual=%d)", actual);
00251     if ((cmd_0 + actual) <= max_n)
00252         append_to_packet(cmd_0 + actual);
00253     else
00254         append_command(cmd_1, actual);
00255 }
00256 
00257 void
00258 append_command(unsigned cmd_1, unsigned actual)
00259 {
00260     if ((cmd_1 != DVI_SET_1) && (cmd_1 != DVI_FNT_1) &&
00261         (cmd_1 != DVI_FNT_DEF_1) && (cmd_1 != DVI_XXX_1)) {
00262         internal_error_1("append_command (cmd_1=%d)", cmd_1);
00263     }
00264     if (actual < 0x100) {
00265         append_to_packet(cmd_1);
00266         append_to_packet(actual);
00267     } else if (actual < 0x10000) {
00268         append_to_packet(cmd_1 + 1);
00269         append_to_packet(actual >> 8);
00270         append_to_packet(actual & 0xff);
00271     } else if (actual < 0x1000000) {
00272         append_to_packet(cmd_1 + 2);
00273         append_to_packet(actual >> 16);
00274         append_to_packet((actual >> 8) & 0xff);
00275         append_to_packet(actual & 0xff);
00276     } else {
00277         append_to_packet(cmd_1 + 3);
00278 /* BUG: Should deal with negative numbers */
00279         append_to_packet((actual >> 24) & 0xff);
00280         append_to_packet((actual >> 16) & 0xff);
00281         append_to_packet((actual >> 8) & 0xff);
00282         append_to_packet(actual & 0xff);
00283     }
00284     
00285 }
00286 
00287 unsigned char *ovf_ptr=NULL;
00288 
00289 int
00290 ovf_get_arg(unsigned char **ptr, unsigned k, boolean is_signed)
00291 {
00292     int a, b;
00293 
00294     if (k>4) internal_error_1("ovf_get_arg (k=%d)", k);
00295     a = b = (int) ((**ptr) & 0xff);
00296     (*ptr)++;
00297     if ((is_signed==TRUE) || (k==4)) { /* 4-byte numbers are signed */
00298        if (b > 0x7f) { a = a - 0x100; }
00299     }
00300     while (k>1) {
00301        b = (**ptr) & 0xff;
00302        (*ptr)++;
00303        a = 0x100 * a + b;
00304        k--;
00305     }
00306     return a;
00307 }
00308 
00309 void
00310 input_command(unsigned *cmd, int *actual)
00311 {
00312     unsigned the_cmd = *ovf_ptr & 0xff;
00313 
00314     ovf_ptr++;
00315     if ((the_cmd>=DVI_SET_CHAR_0) && (the_cmd<=DVI_SET_CHAR_127)) {
00316        (*cmd)=DVI_SET_1;
00317        (*actual) = the_cmd;
00318     } else if ((the_cmd>=DVI_SET_1) && (the_cmd<=DVI_SET_4)) {
00319        (*cmd)=DVI_SET_1; 
00320        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_SET_1 + 1, FALSE);
00321     } else if ((the_cmd>=DVI_FNT_NUM_0) && (the_cmd<=DVI_FNT_NUM_63)) {
00322        (*cmd)=DVI_FNT_1;
00323        (*actual) = the_cmd - DVI_FNT_NUM_0;
00324     } else if ((the_cmd>=DVI_FNT_1) && (the_cmd<=DVI_FNT_4)) {
00325        (*cmd)=DVI_FNT_1;
00326        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_FNT_1 + 1, FALSE);
00327     } else if ((the_cmd>=DVI_FNT_DEF_1) && (the_cmd<=DVI_FNT_DEF_4)) {
00328        (*cmd)=DVI_FNT_DEF_1;
00329        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_FNT_DEF_1 + 1, FALSE);
00330     } else if ((the_cmd>=DVI_XXX_1) && (the_cmd<=DVI_XXX_4)) {
00331        (*cmd)=DVI_XXX_1;
00332        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_XXX_1 + 1, FALSE);
00333     } else if ((the_cmd>=DVI_RIGHT_1) && (the_cmd<=DVI_RIGHT_4)) {
00334        (*cmd)=DVI_RIGHT_1;
00335        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_RIGHT_1 + 1, TRUE);
00336     } else if ((the_cmd>=DVI_DOWN_1) && (the_cmd<=DVI_DOWN_4)) {
00337        (*cmd)=DVI_DOWN_1;
00338        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_DOWN_1 + 1, TRUE);
00339     } else if ((the_cmd>=DVI_W_1) && (the_cmd<=DVI_W_4)) {
00340        (*cmd)=DVI_W_1;
00341        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_W_1 + 1, TRUE);
00342     } else if ((the_cmd>=DVI_X_1) && (the_cmd<=DVI_X_4)) {
00343        (*cmd)=DVI_X_1;
00344        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_X_1 + 1, TRUE);
00345     } else if ((the_cmd>=DVI_Y_1) && (the_cmd<=DVI_Y_4)) {
00346        (*cmd)=DVI_Y_1;
00347        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_Y_1 + 1, TRUE);
00348     } else if ((the_cmd>=DVI_Z_1) && (the_cmd<=DVI_Z_4)) {
00349        (*cmd)=DVI_Z_1;
00350        (*actual) = ovf_get_arg(&ovf_ptr, the_cmd - DVI_Z_1 + 1, TRUE);
00351     }
00352 }
00353 
00354 
00355 void
00356 append_to_packet_fix(unsigned cmd, fix fval)
00357 {
00358     unsigned k;
00359     unsigned negative=FALSE;
00360     int t;
00361 
00362     if (design_units != UNITY)
00363         fval = zround(((double)fval) / ((double)design_units) * 1048576.0);
00364     if (fval<0) {
00365         negative = TRUE;
00366         fval = -1 - fval;
00367     }
00368     if (cmd == 0) {
00369         k = 4; t = 0x1000000;
00370     } else {
00371         t = 0x7f; k = 1;
00372         while (fval>t) {
00373             t = (t<<8) | 0xff; k++;
00374         }
00375         append_to_packet(cmd+k-1); t = t/0x80 + 1;
00376     }
00377     do {
00378         if (negative == TRUE) {
00379             append_to_packet(0xff - fval/t);
00380             fval = (fval/t)*t + t-1-fval;
00381             negative = FALSE;
00382         } else {
00383             append_to_packet((fval/t) & 0xff);
00384         }
00385         k--; t = t >> 8; 
00386     } while (k != 0);
00387 }
00388 
00389 unsigned move_table_size = 0;
00390 move *move_table = NULL;
00391 move *cur_move = NULL;
00392 unsigned move_ptr = 0;
00393 
00394 void
00395 move_table_init(void)
00396 {
00397     if (move_table == NULL) {
00398         move_table_size = BLOCK;
00399         move_table = (move *) xmalloc(move_table_size);
00400      }
00401     move_ptr = 0;
00402     cur_move = move_table;
00403     cur_move->h = 0; cur_move->v = 0;
00404 }
00405 
00406 void
00407 packet_table_end(void)
00408 {
00409     cur_packet = NULL;
00410     packet_ptr = 0;
00411     packet_table_size = 0;
00412 }
00413 
00414 
00415 void
00416 move_ptr_decr(void)
00417 {
00418     if (move_ptr==0)
00419         internal_error_0("move_ptr_incr");
00420     move_ptr--;
00421     cur_move = &move_table[move_ptr];
00422 }
00423 
00424 void
00425 move_ptr_incr(void)
00426 {
00427     if (move_ptr == move_table_size) {
00428        move_table_size += BLOCK;
00429        move_table = (move *) xrealloc(move_table, move_table_size);
00430     }
00431     move_ptr++;
00432     cur_move = &move_table[move_ptr];
00433 }
00434 
00435 unsigned
00436 get_hex(unsigned char c)
00437 {
00438     if ((c>='0') || (c<='9')) return(c-'0');
00439     if ((c>='A') || (c<='F')) return(c-'A'+10);
00440     internal_error_1("get_hex (a=%c)", c);
00441 }
00442 
00443 void
00444 set_select_font(unsigned f)
00445 {
00446     append_command_2(DVI_FNT_NUM_0, DVI_FNT_NUM_63, DVI_FNT_1, f);
00447 }
00448 
00449 void
00450 set_set_char(unsigned c)
00451 {
00452     if (cur_font==NULL) {
00453         warning_1("Character (H %X) cannot be typeset in undefined font", c);
00454     } else {
00455         append_command_2(DVI_SET_CHAR_0, DVI_SET_CHAR_127, DVI_SET_1, c);
00456     }
00457 }   
00458 
00459 void
00460 set_set_rule(fix height, fix width)
00461 {
00462     append_to_packet(DVI_SET_RULE);
00463     append_to_packet_fix(0, height);
00464     append_to_packet_fix(0, width);
00465 }
00466 
00467 void
00468 set_move(unsigned direction, fix fval)
00469 {
00470     if (cur_move == NULL) {
00471         internal_error_0("set_move");
00472     }
00473     if (direction == M_LEFT) {
00474         fval = -fval;
00475         direction = M_RIGHT;
00476     } else if (direction == M_UP) {
00477         fval = -fval;
00478         direction = M_DOWN;
00479     }
00480     if (direction == M_RIGHT) { /* horizontal movement */
00481         if (cur_move->h == 0) {
00482             cur_move->wfix = fval; cur_move->h++;
00483             append_to_packet_fix(DVI_W_1, fval);
00484         } else if (fval == cur_move->wfix) {
00485             append_to_packet(DVI_W_0);
00486         } else if (cur_move->h == 1) {
00487             cur_move->xfix = fval; cur_move->h++;
00488             append_to_packet_fix(DVI_X_1, fval);
00489         } else if (fval == cur_move->xfix) {
00490             append_to_packet(DVI_X_0);
00491         } else {
00492             append_to_packet_fix(DVI_RIGHT_1, fval);
00493         }
00494     } else {                  /* vertical movement */
00495         if (cur_move->v == 0) {
00496             cur_move->yfix = fval; cur_move->v++;
00497             append_to_packet_fix(DVI_Y_1, fval);
00498         } else if (fval == cur_move->yfix) {
00499             append_to_packet(DVI_Y_0);
00500         } else if (cur_move->v == 1) {
00501             cur_move->zfix = fval; cur_move->v++;
00502             append_to_packet_fix(DVI_Z_1, fval);
00503         } else if (fval == cur_move->zfix) {
00504             append_to_packet(DVI_Z_0);
00505         } else {
00506             append_to_packet_fix(DVI_DOWN_1, fval);
00507         }
00508     }
00509 }
00510 
00511 void
00512 set_push(void)
00513 {
00514     append_to_packet(DVI_PUSH);
00515     move_ptr_incr();
00516     cur_move->h = 0;
00517     cur_move->v = 0;
00518 }
00519 
00520 void
00521 set_pop(void)
00522 {
00523     append_to_packet(DVI_POP);
00524     move_ptr_decr();
00525 }
00526 
00527 void
00528 set_special(string special_string)
00529 {
00530     unsigned len = strlen(special_string);
00531     unsigned i=0;
00532 
00533     append_command(DVI_XXX_1, len);
00534     for (i=0; i<len; i++) {
00535         append_to_packet(special_string[i]);
00536     }
00537 }
00538 
00539 void
00540 set_special_hex(string special_hex_string)
00541 {
00542     unsigned len = strlen(special_hex_string);
00543     unsigned i=0;
00544 
00545     append_command(DVI_XXX_1, len/2);
00546     for (i=0; i<len; i+=2) {
00547         append_to_packet(get_hex(special_hex_string[i])*16+
00548                          get_hex(special_hex_string[i+1]));
00549     }
00550 }
00551 
00552 unsigned file_ovf_count = 0;
00553 
00554 void
00555 out_ovf(unsigned i)
00556 {
00557     fputc(i,file_ovf);
00558     file_ovf_count++;
00559 }
00560 
00561 void
00562 out_ovf_4(unsigned i)
00563 {
00564     fputc(i>>24,        file_ovf);
00565     fputc((i>>16)&0xff, file_ovf);
00566     fputc((i>>8)&0xff,  file_ovf);
00567     fputc(i&0xff,       file_ovf);
00568     file_ovf_count += 4;
00569 }
00570 
00571 void
00572 output_ovf_fonts(void)
00573 {
00574     unsigned i, j, k1, k2;
00575 
00576     for (i=0; i<no_fonts; i++) {
00577         cur_font = font_table+i;
00578         for (j=0; j<cur_font->ovf_packet_length; j++)
00579             out_ovf(cur_font->ovf_packet[j]);
00580         out_ovf_4(cur_font->font_checksum);
00581         out_ovf_4(cur_font->font_at);
00582         out_ovf_4((unsigned int)cur_font->font_dsize);
00583         if (cur_font->font_area != NULL) {
00584             k2 = strlen(cur_font->font_area);
00585             out_ovf(k2);
00586         } else {
00587             k2 = 0; out_ovf(0);
00588         }
00589         if (cur_font->font_name != NULL) {
00590             k1 = strlen(cur_font->font_name);
00591             out_ovf(k1);
00592         } else {
00593             k1 = 4; out_ovf(4);
00594         }
00595         if (cur_font->font_area != NULL) {
00596             for (j=0; j<k2; j++)
00597                 out_ovf(cur_font->font_area[j]);
00598         }
00599         if (cur_font->font_name != NULL) {
00600             for (j=0; j<k1; j++)
00601                 out_ovf(cur_font->font_name[j]);
00602         } else {
00603             out_ovf('N'); out_ovf('U'); out_ovf('L'); out_ovf('L');
00604         }
00605     }
00606 }
00607 
00608 void
00609 output_ovf_file(void)
00610 {
00611     unsigned i, k;
00612 
00613     out_ovf(DVI_PRE); out_ovf(VF_ID);
00614     /* Check for vtitle==NULL by Joel Riou <joel.riou@normalesup.org> */
00615     k = vtitle ? strlen(vtitle) : 0; out_ovf(k);
00616     for (i=0; i<k; i++) out_ovf(vtitle[i]);
00617     out_ovf_4(check_sum); out_ovf_4(design_size);
00618     output_ovf_fonts();
00619     output_ovf_chars();
00620     do {
00621         out_ovf(DVI_POST);
00622     } while ((file_ovf_count % 4) != 0);
00623 }
00624 
00625 void
00626 in_ovf_4(int *value)
00627 {
00628     *value = (((*ovf_ptr)    & 0xff) << 24) |
00629              (((*(ovf_ptr+1)) & 0xff) << 16) |
00630              (((*(ovf_ptr+2)) & 0xff) <<  8) |
00631               ((*(ovf_ptr+3)) & 0xff);
00632     ovf_ptr += 4;
00633 }
00634 
00635 void
00636 in_ovf_unsigned_4(unsigned *value)
00637 {
00638     *value = (((*ovf_ptr)    & 0xff) << 24) |
00639              (((*(ovf_ptr+1)) & 0xff) << 16) |
00640              (((*(ovf_ptr+2)) & 0xff) <<  8) |
00641               ((*(ovf_ptr+3)) & 0xff);
00642     ovf_ptr += 4;
00643 }
00644 
00645 void
00646 in_ovf_3(int *value)
00647 {
00648     *value = (((*ovf_ptr) & 0xff) << 16) |
00649              (((*(ovf_ptr+1)) & 0xff) <<  8) |
00650               ((*(ovf_ptr+2)) & 0xff);
00651     ovf_ptr += 3;
00652 }
00653 
00654 void
00655 in_ovf(int *value)
00656 {
00657     *value = (*ovf_ptr) & 0xff;
00658     ovf_ptr ++;
00659 }
00660 
00661 void
00662 input_ovf_file(void)
00663 {
00664     ovf_ptr = ovf;
00665     if ((*ovf_ptr & 0xff) != DVI_PRE)
00666        fatal_error_0("Not a VF or OVF file; first byte should be 247");
00667     ovf_ptr++;
00668     if ((*ovf_ptr & 0xff) != VF_ID)
00669        fatal_error_0("Not a VF or OVF file; second byte should be 202");
00670     ovf_ptr++;
00671     vtitle_length = *ovf_ptr & 0xff;
00672     ovf_ptr++;
00673     vtitle = (char *) xmalloc(vtitle_length+1);
00674     strncpy(vtitle, (const char *)ovf_ptr, vtitle_length);
00675     vtitle[vtitle_length] = '\0';
00676     ovf_ptr += vtitle_length;
00677     print_vtitle(vtitle);
00678     in_ovf_unsigned_4(&vf_check_sum);
00679     in_ovf_unsigned_4(&vf_design_size);
00680 }
00681 
00682 
00683 void
00684 input_ovf_fonts(void)
00685 {
00686     int cur_font_area_length;
00687     int cur_font_name_length;
00688     char *cur_font_name;
00689     char *cur_font_area;
00690     unsigned cur_font_check_sum;
00691     int cur_font_at;
00692     int cur_font_dsize;
00693     unsigned cmd;
00694 
00695     font_table_init();
00696     while (((*ovf_ptr & 0xff) >= DVI_FNT_DEF_1) &&
00697            ((*ovf_ptr & 0xff) <= DVI_FNT_DEF_4)) {
00698       cur_font_index = no_fonts;
00699       cur_font = &(font_table[cur_font_index]);
00700       font_no_incr();
00701       input_command(&cmd, &(cur_font->font_number));
00702       print_map_font(cur_font->font_number);
00703       in_ovf_unsigned_4(&cur_font_check_sum);
00704       cur_font_at = ovf_get_arg(&ovf_ptr, 4, FALSE);
00705       cur_font_dsize = ovf_get_arg(&ovf_ptr, 4, FALSE);
00706       in_ovf(&cur_font_area_length);
00707       in_ovf(&cur_font_name_length);
00708       cur_font_area = NULL;
00709       if (cur_font_area_length != 0) {
00710           cur_font_area = (char *)xmalloc(cur_font_area_length+1);
00711           strncpy(cur_font_area, (const char *)ovf_ptr, cur_font_area_length);
00712           cur_font_area[cur_font_area_length] = '\0';
00713           ovf_ptr += cur_font_area_length;
00714           print_font_area(cur_font_area);
00715       }
00716       cur_font_name = NULL;
00717       if (cur_font_name_length != 0) {
00718           cur_font_name = (char *)xmalloc(cur_font_name_length+1);
00719           strncpy(cur_font_name, (const char *)ovf_ptr, cur_font_name_length);
00720           cur_font_name[cur_font_name_length] = '\0';
00721           ovf_ptr += cur_font_name_length;
00722           print_font_name(cur_font_name);
00723       }
00724       print_font_check_sum(cur_font_check_sum);
00725       print_font_at(cur_font_at);
00726       print_font_design_size(cur_font_dsize);
00727       right();
00728     }
00729 }
00730 
00731 void
00732 input_ovf_chars(void)
00733 {
00734     int pl,cc,wd;
00735 
00736     while ((*ovf_ptr & 0xff) <= VF_LONG_CHAR) {
00737         if ((*ovf_ptr & 0xff) == VF_LONG_CHAR) {
00738             ovf_ptr++;
00739             in_ovf_4(&pl);
00740             in_ovf_4(&cc);
00741             in_ovf_4(&wd);
00742         } else {
00743             in_ovf(&pl);
00744             in_ovf(&cc);
00745             in_ovf_3(&wd);
00746         }
00747         ensure_existence(cc);
00748         current_secondary_character->ovf_packet_length = pl;
00749         current_secondary_character->ovf_packet = ovf_ptr;
00750         ovf_ptr += pl;
00751     }
00752     while (ovf_ptr < (ovf+length_ovf)) {
00753         if ((*ovf_ptr & 0xff) != DVI_POST)
00754             fatal_error_0("Not a VF or OVF file; final bytes should be 248");
00755         ovf_ptr++;
00756     }
00757 }