[Aleph] ovp2ovf, font_install_unicode and the Mac

Joël Riou joel.riou at normalesup.org
Sat Jul 16 18:01:05 CEST 2005


Le lundi  4 juillet 2005, Marc Wilhelm Küster a écrit :
>                                                                    Does
> anybody of you have by any chance access to either the old code or a Mac
> binary (or, even better, of course, the news that everything is fixed
> now in some ovp2ovf > 2.0)?

I also had such trouble with several versions of ovp2ovf. On FreeBSD 5.0,
it worked fine, then on FreeBSD 5.1, there was a bug that prevented ovp2ovf
from working at all, the reason was that font utilities had been completely
rewritten in C whereas previous versions were based on Knuth's vptovf in
Web. I filled a bug report on Debian since I had the same trouble on my
Linux box, and proposed a patch that fixed the most visible problems <URL:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=229184 >. This patch and
some others seem to have been applied in teTeX since that time. But there
are still some trouble, especially with huge fonts as a friend of mine
found when dealing with a Chinese font (for the anecdote, we were working
on the students' directory of our School, any student has a form in it with
some personal data and some fields are filled with quotations or motto, the
biggest part of which is in french or in english, the remaining part being
in some exotic languages : ancient greek, russian, chinese, japanese,
hindi, elfic... ; this is the reason why we used lambda/lamed). Here is the
mail that he sent to J. Plaice last year (the patch is attached to my mail) :

< Date: Wed, 26 May 2004 03:26:10 +0200
< From: Arthur Reutenauer <Arthur.Reutenauer at ens.fr>
< To: John Plaice <plaice at cse.unsw.edu.au>
< Cc: Joël Riou <Joel.Riou at normalesup.org>
< Subject: A patch for some bugs in omega's fonts utilities
< Message-ID: <20040526012609.GA13434 at bireme.ens.fr>
< 
< 	Hello,
< 
<   Here is a patch fixing a handful of bugs in omega fonts utilities
< (ofm2opl, ovp2ovf, etc.). Two of them have already been submitted to the
< Debian Bug Tracking System by Joël Riou and have apparently been
< forwarded to you (cf.
< http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=229184); the first bug
< in the aforementioned URL prevents *all* of the four programs linked to
< omfonts to work altogether on fonts with font level 0 (by reading the
< ofm level incorrectly and quitting on what it considers an error), which
< is very embarrassing. The other one consists in ovp2ovf segfaulting when
< presented with and ovp file where no VTITLE is defined; that is quite
< annoying too, although much less severe.
< 
<   The last bug is a very nasty one, and is to be found only when using
< ovp2ovf on a ovp file with many subfonts (at least half a dozen; see
< below): when reading on ovp file, the code in font_routines.c is
< supposed to reallocate memory for font_table as the number of subfonts
< encountered grows... but, the code actually checks if "no_fonts ==
< font_table_size" (line 59 of font_routines.c, in the tar bundle for
< omega-1.23.4), where no_fonts is the number of subfonts read so far, and
< font_table_size the size of the table, that is, no_fonts times BLOCK,
< which is 256 times more! So, font_table actually never gets reallocated
< (it only would with a virtual font containing at least 256 subfonts),
< and is a pointer to only 256 free bytes, the subsequent ones being
< likely to clash with some buffers and be written over (which they
< eventually are, and this led to segfaults because some of the pointers
< in font_table[i], for a sufficiently large i, held garbage).
< 
<   In tracking this last bug, I found out that you used the macro BLOCK
< (defined to 256 near the beginning of font_routines.c) when allocating
< for new space in font_table, which seemed unnecessarily big, since the
< size of the "font" structure is much less (30 bytes on Intel 386 Linux,
< 48 on Sparc Solaris 2.8). Actually, this is what made the code still
< working after having fixed the first bugs, since font_table, when
< initiated, held 256 free bytes, that were sufficient for a handful of
< subfonts (8, on my computer, working under Linux, where I debugged the
< program), and prevented the bug to appear for many virtual fonts
< -- Joël and I came accross it when working on a chinese font. So, I
< suggest that you change BLOCK to FONT_BLOCK, whose value should, of
< course, be sizeof(font), and to do a similar change for move_table. My
< patch take this in account.
< 
<   In conclusion, I would like to urge you to apply the patch, if
< possible (we already checked it quite intensively), and to upload the
< patched tar bundle, because having these quite essential programs so
< heavily bugged is very bad publicity for omega, I feel. At least the
< first bug has been mentioned many times on public mailing-lists, and it
< must have discouraged many people to try and use omega altogether, since
< it make all of its font utilities unusable.
< 
<   In looking forward to reading from you soon,
< 
< 	Yours sincerely,
< 
< 				Arthur Reutenauer
<

It seems reasonable that the bug Arthur's patch fixes is the same as the
one you encountered (bad memory access mentionned in your second mail). I
hope this helps.

Le lundi  4 juillet 2005, Marc Wilhelm Küster a écrit :
> Vincent Zoonekynd offers a binary version of the linux ovp2ovf 1.11 for
> download, but neither the source nor a binary for Mac OS X. I cannot
> find it on the web, either, nor do I have access to a TeXLive6 CD.

I do not know how TeXLive works, but you can find the source of ovp2ovf
(which is a function of the binary omfonts) inside teTeX <URL:
http://www.tug.org/teTeX/ >, the tetex-src.tar.gz file is 12M long. Then
the source files of omfonts are in tetex-src-x.y/texk/web2c/omegafonts/.

-- 
Joël Riou

-------------- next part --------------
diff -urNp orig/font_routines.c patch/font_routines.c
--- orig/font_routines.c	Tue May 25 21:18:57 2004
+++ patch/font_routines.c	Wed May 26 00:32:50 2004
@@ -34,6 +34,8 @@ along with Omega; if not, write to the F
 #include "omfonts.h"
 
 #define BLOCK 256
+#define FONT_BLOCK sizeof(font)
+#define MOVE_BLOCK sizeof(move)
 
 font *font_table = NULL;
 unsigned font_table_size = 0;
@@ -48,7 +50,7 @@ unsigned vf_design_size = 0;
 void
 font_table_init(void)
 {
-    font_table_size = BLOCK;
+    font_table_size = FONT_BLOCK;
     font_table = (font *) xmalloc(font_table_size);
     no_fonts = 0;
 }
@@ -56,8 +58,8 @@ font_table_init(void)
 void
 font_no_incr(void)
 {
-    if (no_fonts == font_table_size) {
-       font_table_size += BLOCK;
+    if ((no_fonts * FONT_BLOCK) == font_table_size) {
+       font_table_size += FONT_BLOCK;
        font_table = (font *) xrealloc(font_table, font_table_size);
     }
     no_fonts++;
@@ -395,7 +397,7 @@ void
 move_table_init(void)
 {
     if (move_table == NULL) {
-        move_table_size = BLOCK;
+        move_table_size = MOVE_BLOCK;
         move_table = (move *) xmalloc(move_table_size);
      }
     move_ptr = 0;
@@ -425,7 +427,7 @@ void
 move_ptr_incr(void)
 {
     if (move_ptr == move_table_size) {
-       move_table_size += BLOCK;
+       move_table_size += MOVE_BLOCK;
        move_table = (move *) xrealloc(move_table, move_table_size);
     }
     move_ptr++;
@@ -611,7 +613,7 @@ output_ovf_file(void)
     unsigned i, k;
 
     out_ovf(DVI_PRE); out_ovf(VF_ID);
-    k = strlen(vtitle); out_ovf(k);
+    k = vtitle ? strlen(vtitle) : 0; out_ovf(k);
     for (i=0; i<k; i++) out_ovf(vtitle[i]);
     out_ovf_4(check_sum); out_ovf_4(design_size);
     output_ovf_fonts();
diff -urNp orig/header_routines.c patch/header_routines.c
--- orig/header_routines.c	Tue May 25 19:57:24 2004
+++ patch/header_routines.c	Tue May 25 21:18:43 2004
@@ -472,12 +472,13 @@ init_ofm_level()
 void
 set_ofm_level(unsigned level)
 {
+
     if (ofm_level_specified==TRUE)
         warning_0("OFMLEVEL previously defined; old value ignored");
-    if ((ofm_level != OFM_LEVEL0) && (ofm_level != OFM_LEVEL1)) {
+    if ((ofm_level != (OFM_LEVEL0 - OFM_LEVEL_OFFSET)) && (ofm_level != (OFM_LEVEL1 - OFM_LEVEL_OFFSET))) {
         warning_0("OFMLEVEL value must be D 0 or D 1");
     } else {
-        ofm_level = level+1;
+        ofm_level = level + OFM_LEVEL_OFFSET;
     }
     ofm_level_specified = TRUE;
 }
diff -urNp orig/manifests.h patch/manifests.h
--- orig/manifests.h	Tue May 25 19:57:34 2004
+++ patch/manifests.h	Tue May 25 21:18:43 2004
@@ -278,3 +278,4 @@ along with Omega; if not, write to the F
 #define OFM_LEVEL0	2
 #define OFM_LEVEL1	3
 #define OFM_LEVEL2	4
+#define OFM_LEVEL_OFFSET	2
diff -urNp orig/parse_ofm.c patch/parse_ofm.c
--- orig/parse_ofm.c	Tue May 25 19:56:51 2004
+++ patch/parse_ofm.c	Tue May 25 21:18:43 2004
@@ -118,7 +118,7 @@ ofm_organize(void)
     lf = ofm[0]*256 + ofm[1];
     if (lf==0) { /* This is not a TFM file, it is an OFM-file */
         ofm_on = TRUE;
-        ofm_level = ofm[2]*0x100 + ofm[3] + 1;
+        ofm_level = ofm[2]*0x100 + ofm[3] + OFM_LEVEL_OFFSET;
         if (ofm[4]>127)
             fatal_error_0("File length is negative");
         lf = ofm[4]*0x1000000 + ofm[5]*0x10000 + ofm[6]*0x100 + ofm[7];
@@ -129,12 +129,12 @@ ofm_organize(void)
     if ((lf*4)!=length_ofm)
        fatal_error_2("Stated (%d) and actual (%d) file length do not match",
                       lf*4, length_ofm);
-    
+
     switch(ofm_level) {
         case OFM_TFM: { start_pos = 2; check_sum_pos = 24;  break; }
         case OFM_LEVEL0: { start_pos = 8; check_sum_pos = 56;  break; }
-        case OFM_LEVEL1: { start_pos = 8; check_sum_pos = 116; break; }
-        default: { fatal_error_1("OFMLEVEL %d not supported", ofm_level-1);
+        case OFM_LEVEL1: { start_pos = 8; check_sum_pos = 116;  break; }
+        default: { fatal_error_1("OFMLEVEL %d not supported", ofm_level-OFM_LEVEL_OFFSET);
                    break; }
     }
     design_size_pos = check_sum_pos+4;
@@ -293,7 +293,7 @@ ofm_organize(void)
       break;
     }
     default: {
-      fatal_error_1("Inappropriate font level (%d)", ofm_level-1);
+      fatal_error_1("Inappropriate font level (%d)", ofm_level - OFM_LEVEL_OFFSET);
     }
     }
     width_base    = char_base+ncw;
@@ -319,7 +319,7 @@ ofm_read_simple(void)
 {
 
     if (ofm_on==TRUE) {
-        print_ofm_level(ofm_level-1);
+        print_ofm_level(ofm_level - OFM_LEVEL_OFFSET);
         print_font_dir(font_dir);
     }
     header = (char *) ofm+check_sum_pos;


More information about the Aleph mailing list