]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/pfb.cc (LY_DEFINE): set ttf_verbosity from ttf-verbosity
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 9 Jun 2005 16:45:47 +0000 (16:45 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 9 Jun 2005 16:45:47 +0000 (16:45 +0000)
program option.

* ttftool/include/ttftool.h ("C"): rename verbosity to
ttf_verbosity. Add to public interface.

* lily/program-option.cc: rename from scm-option.cc

ChangeLog
lily/pfb.cc
lily/program-option.cc
ttftool/include/proto.h
ttftool/include/ttftool.h
ttftool/parse.c
ttftool/ps.c
ttftool/ttfps.c
ttftool/util.c

index 620a0592bc42a3cefbbd7abd0fc4da28ef622acc..1e8d5a8d9beffad5b8de73c3a2746455efe9d1cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-06-09  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/pfb.cc (LY_DEFINE): set ttf_verbosity from ttf-verbosity
+       program option.
+
+       * ttftool/include/ttftool.h ("C"): rename verbosity to
+       ttf_verbosity. Add to public interface.
+
+       * scm/music-functions.scm (unfold-repeats): remove debugging display.
+
        * lily/program-option.cc: rename from scm-option.cc
 
        * lily/scm-option.cc (LY_DEFINE): handle no-foobar option setting.
index 7869d2ed1d25e887e8c306e23ae59209e1a6618b..375429cdd56f23e6f2322678cc0092652445dbdd 100644 (file)
 #include <cstdio>
 #include <cstring>
 
+#include "program-option.hh"
 #include "source-file.hh"
 #include "memory-stream.hh"
 #include "ttftool.h"
 #include "open-type-font.hh"
 #include "main.hh"
 #include "warn.hh"
-
 char *
 pfb2pfa (Byte const *pfb, int length)
 {
@@ -111,6 +112,9 @@ LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa",
   
   
   Memory_out_stream stream;
+  ttf_verbosity =
+    robust_scm2int (ly_get_option (ly_symbol2scm ("ttf-verbosity")), 0);
+  
   create_type42 (file_name.to_str0 (), (void*) &stream);
   SCM asscm = scm_from_locale_stringn (stream.get_string (),
                                       stream.get_length ());
@@ -146,3 +150,4 @@ LY_DEFINE (ly_otf_to_cff, "ly:otf->cff",
   
   return asscm;
 }         
index 0769fcb95ebb5d9a51e1c0cd1abbee8424d20ba8..c4b2d0c856272a97715510bfc1a1a678622c2806 100644 (file)
@@ -53,6 +53,8 @@ static Lilypond_option_init options[] = {
    "include book-titles in preview images."},
   {"gs-font-load", "#f",
    "load fonts via Ghostscript."},
+  {"ttf-verbosity", "0",
+   "how much verbosity for TTF font embedding?"},
   {0,0,0},
 };
 
index 83d5f7a3ca3a60bd438e374450ac56a79d83c89f..a01f1e0651b8efe366e14764be54d6e560ec922a 100644 (file)
@@ -1,7 +1,5 @@
 /* Copyright (c) 1997-1998 by Juliusz Chroboczek */
 
-extern int verbosity;
-
 struct TableDirectoryEntry *readDirectory (int fd, struct OffsetTable *ot);
 char **readNamingTable (int fd);
 void readHeadTable (int fd, struct HeadTable *ht);
index e60bed72fd689d065d954f1302ccd3e2f1e9aeb6..43f35ca7b89b982feaa97807674dfb039f1f76c1 100644 (file)
@@ -5,6 +5,8 @@ extern "C"
 
 
   void create_type42 (char const *, void *);
+  extern int ttf_verbosity;
+  
 #ifdef __cplusplus
 }
 #endif
index e6becb5586e6a818cf9328c39c3c5b352bea83b9..a8e7e3326d54b90d5b4424fb0b5d918e271a5d0e 100644 (file)
@@ -4,8 +4,11 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include "types.h"
 #include "proto.h"
+#include "ttftool.h"
 
 struct TableDirectoryEntry *
 readDirectory (int fd, struct OffsetTable *ot)
@@ -14,9 +17,12 @@ readDirectory (int fd, struct OffsetTable *ot)
   int i;
 
   struct TableDirectoryEntry *td;
+  if (ttf_verbosity >= 3)
+    fprintf (stderr, "");
+  
   surely_read (fd, ot, sizeof (struct OffsetTable));
   FIX_OffsetTable (*ot);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     fprintf (stderr, "%d tables\n", ot->numTables);
   n = sizeof (struct TableDirectoryEntry) * ot->numTables;
   td = mymalloc (n);
@@ -77,7 +83,7 @@ readNamingTable (int fd)
          strings[records[i].nameID] = mymalloc (records[i].length / 2 + 1);
          unistrncpy (strings[records[i].nameID],
                      data + records[i].offset, records[i].length);
-         if (verbosity >= 2)
+         if (ttf_verbosity >= 2)
            fprintf (stderr, "%d: %s\n", records[i].nameID,
                     strings[records[i].nameID]);
        }
@@ -97,7 +103,7 @@ readNamingTable (int fd)
          strncpy (strings[id],
                   data + records[i].offset, records[i].length);
          strings[id][records[i].length] = 0;
-         if (verbosity >= 2)
+         if (ttf_verbosity >= 2)
            fprintf (stderr, "%d: %s\n", records[i].nameID,
                     strings[records[i].nameID]);
        }
@@ -119,7 +125,7 @@ readMaxpTable (int fd)
   surely_read (fd, &data, sizeof (data));
   FIX_Fixed (data.version);
   FIX_UH (data.nglyphs);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     fprintf (stderr, "  version %d.%u\n",
             data.version.mantissa, data.version.fraction);
   return data.nglyphs;
@@ -130,7 +136,7 @@ readHeadTable (int fd, struct HeadTable *ht)
 {
   surely_read (fd, ht, sizeof (struct HeadTable));
   FIX_HeadTable (*ht);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     {
       fprintf (stderr, "  version %d.%d\n",
               ht->version.mantissa, ht->version.fraction);
@@ -139,7 +145,7 @@ readHeadTable (int fd, struct HeadTable *ht)
     }
   if (ht->magicNumber != 0x5F0F3CF5)
     ttf_error ("Bad magic number");
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     fprintf (stderr, "  %d units per Em\n", ht->unitsPerEm);
 }
 
@@ -156,7 +162,7 @@ readPostTable (int fd, int nglyphs, struct PostTable *pt,
 
   surely_read (fd, pt, sizeof (struct PostTable));
   FIX_PostTable (*pt);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     fprintf (stderr, "  format type %d.%u\n",
             pt->formatType.mantissa, pt->formatType.fraction);
 
@@ -171,7 +177,7 @@ readPostTable (int fd, int nglyphs, struct PostTable *pt,
       FIX_UH (nglyphspost);
       if (nglyphspost != nglyphs)
        ttf_error ("Inconsistency between `maxp' and `nglyphs' tables!");
-      if (verbosity >= 2)
+      if (ttf_verbosity >= 2)
        fprintf (stderr, "  %d glyphs\n", nglyphs);
       glyphNameIndex = mymalloc (sizeof (USHORT) * nglyphs);
       surely_read (fd, glyphNameIndex, sizeof (USHORT) * nglyphs);
@@ -203,7 +209,7 @@ readPostTable (int fd, int nglyphs, struct PostTable *pt,
          glyphNamesTemp[i] = mymalloc (c + 1);
          surely_read (fd, glyphNamesTemp[i], c);
          glyphNamesTemp[i][c] = '\0';
-         if (verbosity >= 3)
+         if (ttf_verbosity >= 3)
            fprintf (stderr, "    %d: %s\n", i, glyphNamesTemp[i]);
          i++;
        }
@@ -294,7 +300,7 @@ readHheaTable (int fd)
   hhea = mymalloc (sizeof (struct HheaTable));
   surely_read (fd, hhea, sizeof (struct HheaTable));
   FIX_HheaTable (*hhea);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     fprintf (stderr, "  version %d.%u\n",
             hhea->version.mantissa, hhea->version.fraction);
   if (hhea->metricDataFormat != 0)
@@ -314,7 +320,7 @@ readKernTable (int fd, int **nkep, struct KernEntry0 ***kep)
 
   surely_read (fd, &kt, sizeof (struct KernTable));
   FIX_KernTable (kt);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     {
       fprintf (stderr, "  version %d\n", kt.version);
       fprintf (stderr, "  %d subtables\n", kt.nTables);
@@ -326,7 +332,7 @@ readKernTable (int fd, int **nkep, struct KernEntry0 ***kep)
     {
       surely_read (fd, &ksth, sizeof (struct KernSubTableHeader));
       FIX_KernSubTableHeader (ksth);
-      if (verbosity >= 2)
+      if (ttf_verbosity >= 2)
        fprintf (stderr, "  analyzing subtable %d, version %d... ",
                 i, ksth.version);
       if ((ksth.coverage & kernHorizontal) &&
@@ -336,7 +342,7 @@ readKernTable (int fd, int **nkep, struct KernEntry0 ***kep)
        {
          surely_read (fd, &kst, sizeof (struct KernSubTable0));
          FIX_KernSubTable0 (kst);
-         if (verbosity >= 2)
+         if (ttf_verbosity >= 2)
            fprintf (stderr, "reading %d entries.\n", kst.nPairs);
          nke[i] = kst.nPairs;
          ke[i] = mymalloc (kst.nPairs * sizeof (struct KernEntry0));
@@ -346,7 +352,7 @@ readKernTable (int fd, int **nkep, struct KernEntry0 ***kep)
        }
       else
        {
-         if (verbosity >= 2)
+         if (ttf_verbosity >= 2)
            fprintf (stderr, "skipping.\n");
          surely_lseek (fd, ksth.length - sizeof (struct KernSubTableHeader),
                        SEEK_CUR);
index 4be735e46b5edec86f724cae6c56fc52b1150a13..d672f3b5f7d3b557de4958e1c94d9dd07064cbd2 100644 (file)
@@ -7,8 +7,7 @@
 #include "types.h"
 #include "proto.h"
 
-#define ALIAS_FILE_TO_FILECOOKIE
-
+#include "ttftool.h"
 #include "libc-extension.hh"
 
 #define CHUNKSIZE 65534
@@ -141,7 +140,7 @@ printPSTrailer (void *out, int nglyphs, int postType, struct GlyphName *gnt)
     default:
       if (postType != 1)
        {
-         if (verbosity > -2)
+         if (ttf_verbosity > -2)
            fprintf (stderr,
                     "No glyph name table; assuming MacGlyphEncoding\n");
        }
index 4b0e09e26f410ec8a3ac3034939de8878f1f88a9..8931949574844399a1b148efe24dc907980d2c32 100644 (file)
@@ -13,7 +13,7 @@
 static void endianness_test (void);
 static void usage (char *);
 
-int verbosity = 0;
+int ttf_verbosity = 0;
 
 void
 create_type42 (const char *infile, void *out)
@@ -47,13 +47,13 @@ create_type42 (const char *infile, void *out)
     }
 
   td = readDirectory (fd, &ot);
-  if (verbosity >= 2)
+  if (ttf_verbosity >= 2)
     fprintf (stderr, "True type version %d.%u\n",
             ot.version.mantissa, ot.version.fraction);
 
   for (i = 0; i < ot.numTables; i++)
     {
-      if (verbosity >= 2)
+      if (ttf_verbosity >= 2)
        fprintf (stderr, "Found `%c%c%c%c' table\n",
                 (char) (td[i].tag >> 24),
                 (char) (td[i].tag >> 16) & 255,
@@ -92,35 +92,35 @@ create_type42 (const char *infile, void *out)
   if (maxpOff == 0 || headOff == 0 || postOff == 0 || nameOff == 0)
     ttf_error ("Incomplete TTF file\n");
 
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "Processing `maxp' table\n");
   surely_lseek (fd, maxpOff, SEEK_SET);
   nglyphs = readMaxpTable (fd);
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "  %d glyphs\n", nglyphs);
 
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "Processing `head' table\n");
   surely_lseek (fd, headOff, SEEK_SET);
   ht = mymalloc (sizeof (struct HeadTable));
   readHeadTable (fd, ht);
 
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "Processing `post' table\n");
   surely_lseek (fd, postOff, SEEK_SET);
   pt = mymalloc (sizeof (struct PostTable));
   postType = readPostTable (fd, nglyphs, pt, &gnt);
 
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "Processing `name' table\n");
   surely_lseek (fd, nameOff, SEEK_SET);
   strings = readNamingTable (fd);
 
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "Generating PS file\n");
   printPSFont (out, ht, strings, nglyphs, postType, pt, gnt, fd);
   lily_cookie_fclose (out);
-  if (verbosity >= 1)
+  if (ttf_verbosity >= 1)
     fprintf (stderr, "Done.\n");
   close (fd);
 }
index fa6e7b3add7e0311ea7bd083af5fb37e455be80b..aedbd43a239b83412bf0f1c23e6006074a067226 100644 (file)
@@ -9,9 +9,8 @@
 
 #include "types.h"
 #include "proto.h"
-
 #include "libc-extension.hh"
-
+#include "ttftool.h"
 
 
 void *
@@ -75,12 +74,16 @@ surely_lseek (int fildes, off_t offset, int whence)
 ssize_t
 surely_read (int fildes, void *buf, size_t nbyte)
 {
+  if (ttf_verbosity >= 3)
+    fprintf (stderr, "Reading %d bytes\n", nbyte);
+  
   ssize_t n;
   if ((n = read (fildes, buf, nbyte)) < nbyte)
     {
       char s[100];
       sprintf (s, "read too little in surely_read(), expect %d got %d", nbyte, n);
-      syserror  (s);
+      sprintf (s, "trying again yields %d", read (fildes, buf, nbyte - n));
+      syserror (s);
     }
   return n;
 }