From e4ad23a0ec473c310664c168cb5696e4dae9cdca Mon Sep 17 00:00:00 2001 From: hanwen Date: Thu, 9 Jun 2005 16:45:47 +0000 Subject: [PATCH] * 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. * lily/program-option.cc: rename from scm-option.cc --- ChangeLog | 8 ++++++++ lily/pfb.cc | 7 ++++++- lily/program-option.cc | 2 ++ ttftool/include/proto.h | 2 -- ttftool/include/ttftool.h | 2 ++ ttftool/parse.c | 34 ++++++++++++++++++++-------------- ttftool/ps.c | 5 ++--- ttftool/ttfps.c | 20 ++++++++++---------- ttftool/util.c | 9 ++++++--- 9 files changed, 56 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 620a0592bc..1e8d5a8d9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2005-06-09 Han-Wen Nienhuys + * 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. diff --git a/lily/pfb.cc b/lily/pfb.cc index 7869d2ed1d..375429cdd5 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -10,13 +10,14 @@ #include #include +#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; } + diff --git a/lily/program-option.cc b/lily/program-option.cc index 0769fcb95e..c4b2d0c856 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -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}, }; diff --git a/ttftool/include/proto.h b/ttftool/include/proto.h index 83d5f7a3ca..a01f1e0651 100644 --- a/ttftool/include/proto.h +++ b/ttftool/include/proto.h @@ -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); diff --git a/ttftool/include/ttftool.h b/ttftool/include/ttftool.h index e60bed72fd..43f35ca7b8 100644 --- a/ttftool/include/ttftool.h +++ b/ttftool/include/ttftool.h @@ -5,6 +5,8 @@ extern "C" void create_type42 (char const *, void *); + extern int ttf_verbosity; + #ifdef __cplusplus } #endif diff --git a/ttftool/parse.c b/ttftool/parse.c index e6becb5586..a8e7e3326d 100644 --- a/ttftool/parse.c +++ b/ttftool/parse.c @@ -4,8 +4,11 @@ #include #include #include +#include + #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); diff --git a/ttftool/ps.c b/ttftool/ps.c index 4be735e46b..d672f3b5f7 100644 --- a/ttftool/ps.c +++ b/ttftool/ps.c @@ -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"); } diff --git a/ttftool/ttfps.c b/ttftool/ttfps.c index 4b0e09e26f..8931949574 100644 --- a/ttftool/ttfps.c +++ b/ttftool/ttfps.c @@ -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); } diff --git a/ttftool/util.c b/ttftool/util.c index fa6e7b3add..aedbd43a23 100644 --- a/ttftool/util.c +++ b/ttftool/util.c @@ -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; } -- 2.39.5