summaryrefslogtreecommitdiff
path: root/vcl/source/fontsubset
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2011-02-16 12:16:56 +0100
committerThomas Arnhold <thomas@arnhold.org>2011-02-16 20:17:26 +0100
commit83c35aa428e910e17042babcfe4abf15266f1dcf (patch)
tree68832cfeac8a96b4da243a1f00b81d6d9ec4be2e /vcl/source/fontsubset
parent6f248073aae4e5c0208c19ad2ad15f4ab953246a (diff)
Remove TEST* and DEBUG*
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r--vcl/source/fontsubset/list.c272
-rw-r--r--vcl/source/fontsubset/sft.cxx581
2 files changed, 0 insertions, 853 deletions
diff --git a/vcl/source/fontsubset/list.c b/vcl/source/fontsubset/list.c
index c58e4497d2cf..def5faa7b553 100644
--- a/vcl/source/fontsubset/list.c
+++ b/vcl/source/fontsubset/list.c
@@ -35,20 +35,12 @@
/*[]---------------------------------------------------[]*/
#include <stdlib.h>
-
-#if OSL_DEBUG_LEVEL == 0
-# ifndef NDEBUG
-# define NDEBUG
-# endif
-#endif
-
#include <assert.h>
#ifdef MALLOC_TRACE
#include <stdio.h>
#include </usr/local/include/malloc.h>
#endif
-/* #define TEST */
#include "list.h"
/*- private data types */
@@ -101,31 +93,6 @@ static lnode *appendPrim(list this, void *el)
this->aCount++;
return ptr;
}
-#ifdef TEST
-static lnode *prependPrim(list this, void *el)
-{
- lnode *ptr = newNode(el);
- lnode *flink, **blink;
-
- if (this->head != 0) {
- blink = &(this->head->prev);
- flink = this->head;
- } else {
- blink = &this->tail;
- flink = 0;
- this->cptr = ptr; /*- list was empty - set current to this element */
- }
-
- *blink = ptr;
- this->head = ptr;
-
- ptr->next = flink;
- ptr->prev = 0;
-
- this->aCount++;
- return ptr;
-}
-#endif
/*- public methods */
list listNewEmpty(void) /*- default ctor */
@@ -140,32 +107,6 @@ list listNewEmpty(void) /*- default ctor */
return this;
}
-#ifdef TEST
-list listNewCopy(list l) /*- copy ctor */
-{
- lnode *ptr, *c;
- list this;
- assert(l != 0);
-
- this = malloc(sizeof(struct _list));
- assert(this != 0);
-
- ptr = l->head;
-
- this->aCount = 0;
- this->eDtor = 0;
- this->head = this->tail = this->cptr = 0;
-
- while (ptr) {
- c = appendPrim(this, ptr->value);
- if (ptr == l->cptr) this->cptr = c;
- ptr = ptr->next;
- }
-
- return this;
-}
-#endif
-
void listDispose(list this) /*- dtor */
{
assert(this != 0);
@@ -199,36 +140,6 @@ int listIsEmpty(list this)
return this->aCount == 0;
}
-
-#ifdef TEST
-int listAtFirst(list this)
-{
- assert(this != 0);
- return this->cptr == this->head;
-}
-
-int listAtLast(list this)
-{
- assert(this != 0);
- return this->cptr == this->tail;
-}
-
-int listPosition(list this)
-{
- int res = 0;
- lnode *ptr;
- assert(this != 0);
-
- ptr = this->head;
-
- while (ptr != this->cptr) {
- ptr = ptr->next;
- res++;
- }
-
- return res;
-}
-#endif
int listFind(list this, void *el)
{
lnode *ptr;
@@ -312,59 +223,7 @@ list listAppend(list this, void *el)
appendPrim(this, el);
return this;
}
-#ifdef TEST
-list listPrepend(list this, void *el)
-{
- assert(this != 0);
-
- prependPrim(this, el);
- return this;
-}
-
-list listInsertAfter(list this, void *el)
-{
- lnode *ptr;
- assert(this != 0);
-
- if (this->cptr == 0) return listAppend(this, el);
-
- ptr = newNode(el);
-
- ptr->prev = this->cptr;
- ptr->next = this->cptr->next;
- this->cptr->next = ptr;
-
- if (ptr->next != 0) {
- ptr->next->prev = ptr;
- } else {
- this->tail = ptr;
- }
- this->aCount++;
- return this;
-}
-
-list listInsertBefore(list this, void *el)
-{
- lnode *ptr;
- assert(this != 0);
-
- if (this->cptr == 0) return listAppend(this, el);
-
- ptr = newNode(el);
- ptr->prev = this->cptr->prev;
- ptr->next = this->cptr;
- this->cptr->prev = ptr;
-
- if (ptr->prev != 0) {
- ptr->prev->next = ptr;
- } else {
- this->head = ptr;
- }
- this->aCount++;
- return this;
-}
-#endif
list listRemove(list this)
{
lnode *ptr = 0;
@@ -409,135 +268,4 @@ list listClear(list this)
return this;
}
-#ifdef TEST
-
-void listForAll(list this, void (*f)(void *))
-{
- lnode *ptr = this->head;
- while (ptr) {
- f(ptr->value);
- ptr = ptr->next;
- }
-}
-
-
-#include <stdio.h>
-
-void printlist(list l)
-{
- int saved;
- assert(l != 0);
- saved = listPosition(l);
-
- printf("[ ");
-
- if (!listIsEmpty(l)) {
- listToFirst(l);
- do {
- printf("%d ", (int) listCurrent(l));
- } while (listNext(l));
- }
-
- printf("]\n");
-
- listPositionAt(l, saved);
-}
-
-void printstringlist(list l)
-{
- int saved;
- assert(l != 0);
- saved = listPosition(l);
-
- printf("[ ");
-
- if (!listIsEmpty(l)) {
- listToFirst(l);
- do {
- printf("'%s' ", (char *) listCurrent(l));
- } while (listNext(l));
- }
-
- printf("]\n");
-
- listPositionAt(l, saved);
-}
-
-void printstat(list l)
-{
- printf("count: %d, position: %d, isEmpty: %d, atFirst: %d, atLast: %d.\n",
- listCount(l), listPosition(l), listIsEmpty(l), listAtFirst(l), listAtLast(l));
-}
-
-void allfunc(void *e)
-{
- printf("%d ", e);
-}
-
-void edtor(void *ptr)
-{
- printf("element dtor: 0x%08x\n", ptr);
- free(ptr);
-}
-
-int main()
-{
- list l1, l2;
- char *ptr;
- int i;
-
-#ifdef MALLOC_TRACE
- mal_leaktrace(1);
- mal_debug(2);
-#endif
-
- l1 = listNewEmpty();
- printstat(l1);
-
- listAppend(l1, 1);
- printstat(l1);
-
- listAppend(l1, 2);
- printstat(l1);
-
- listAppend(l1, 3);
- printstat(l1);
-
- printlist(l1);
-
- listToFirst(l1);
- listInsertBefore(l1, -5);
- printlist(l1);
-
- l2 = listNewCopy(l1);
- printlist(l2);
-
- listForAll(l2, allfunc);
- printf("\n");
-
- listClear(l1);
- listSetElementDtor(l1, edtor);
-
- for(i=0; i<10; i++) {
- ptr = malloc(20);
- snprintf(ptr, 20, "element # %d", i);
- listAppend(l1, ptr);
- }
-
- printstringlist(l1);
-
-
- listDispose(l1);
- listDispose(l2);
-
-#ifdef MALLOC_TRACE
- mal_dumpleaktrace(stdout);
-#endif
-
-
- return 0;
-}
-#endif
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 3b7e5eb5b5f3..3c40b962a9b8 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -36,11 +36,6 @@
*
*/
-#if OSL_DEBUG_LEVEL == 0
-# ifndef NDEBUG
-# define NDEBUG
-# endif
-#endif
#include <assert.h>
#include <stdlib.h>
@@ -65,10 +60,6 @@
#include <osl/endian.h>
#include <algorithm>
-#ifdef TEST7
-#include <ctype.h>
-#endif
-
namespace vcl
{
@@ -676,10 +667,6 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
glyphlist.push_back( index );
-#ifdef DEBUG2
- fprintf(stderr,"glyphlist: += %d\n", index);
-#endif
-
if ((np = GetTTGlyphOutline(ttf, index, &nextComponent, 0, &glyphlist)) == 0)
{
/* XXX that probably indicates a corrupted font */
@@ -689,18 +676,6 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
#endif
}
-#ifdef DEBUG2
- fprintf(stderr,"%d [", (int)glyphlist.size() );
- for( std::vector< sal_uInt32 >::const_iterator it = glyphlist.begin();
- it != glyphlist.end(); ++it )
- {
- fprintf( stderr,"%d ", (int) *it );
- }
- fprintf(stderr, "]\n");
- if( ! glyphlist.empty() )
- fprintf(stderr, "glyphlist: -= %d\n", (int) glyphlist.back());
-
-#endif
if( ! glyphlist.empty() )
glyphlist.pop_back();
@@ -730,23 +705,14 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
b = c = 0;
if (flags & WE_HAVE_A_SCALE) {
-#ifdef DEBUG2
- fprintf(stderr, "WE_HAVE_A_SCALE\n");
-#endif
a = GetInt16(ptr, 0, 1) << 2;
d = a;
ptr += 2;
} else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
-#ifdef DEBUG2
- fprintf(stderr, "WE_HAVE_AN_X_AND_Y_SCALE\n");
-#endif
a = GetInt16(ptr, 0, 1) << 2;
d = GetInt16(ptr, 2, 1) << 2;
ptr += 4;
} else if (flags & WE_HAVE_A_TWO_BY_TWO) {
-#ifdef DEBUG2
- fprintf(stderr, "WE_HAVE_A_TWO_BY_TWO\n");
-#endif
a = GetInt16(ptr, 0, 1) << 2;
b = GetInt16(ptr, 2, 1) << 2;
c = GetInt16(ptr, 4, 1) << 2;
@@ -772,18 +738,6 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
assert(!"ARGS_ARE_XY_VALUES is not implemented!!!\n");
}
-#ifdef DEBUG2
- fprintf(stderr, "a: %f, b: %f, c: %f, d: %f, e: %f, f: %f, m: %f, n: %f\n",
- ((double) a) / 65536,
- ((double) b) / 65536,
- ((double) c) / 65536,
- ((double) d) / 65536,
- ((double) e) / 65536,
- ((double) f) / 65536,
- ((double) m) / 65536,
- ((double) n) / 65536);
-#endif
-
for (i=0; i<np; i++) {
F16Dot16 t;
ControlPoint cp;
@@ -793,10 +747,6 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
t = fixedMulDiv(b, nextComponent[i].x << 16, n) + fixedMulDiv(d, nextComponent[i].y << 16, n) + (f << 16);
cp.y = (sal_Int16)(fixedMul(t, n) >> 16);
-#ifdef DEBUG2
- fprintf(stderr, "( %d %d ) -> ( %d %d )\n", nextComponent[i].x, nextComponent[i].y, cp.x, cp.y);
-#endif
-
myPoints.push_back( cp );
}
@@ -858,21 +808,6 @@ static int GetTTGlyphOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint
res = GetCompoundTTOutline(ttf, glyphID, pointArray, metrics, glyphlist ? *glyphlist : aPrivList );
}
-#ifdef DEBUG3
- {
- int i;
- FILE *out = fopen("points.dat", "a");
- assert(out != 0);
- fprintf(out, "Glyph: %d\nPoints: %d\n", glyphID, res);
- for (i=0; i<res; i++) {
- fprintf(out, "%c ", ((*pointArray)[i].flags & 0x8000) ? 'X' : '.');
- fprintf(out, "%c ", ((*pointArray)[i].flags & 1) ? '+' : '-');
- fprintf(out, "%d %d\n", (*pointArray)[i].x, (*pointArray)[i].y);
- }
- fclose(out);
- }
-#endif
-
return res;
}
@@ -1546,79 +1481,6 @@ static void GetKern(TrueTypeFont *ttf)
return;
}
-#ifdef TEST5
-/* KernGlyphsPrim?() functions expect the caller to ensure the validity of their arguments and
- * that x and y elements of the kern array are initialized to zeroes
- */
-static void KernGlyphsPrim1(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern)
-{
- (void)ttf; /* avoid warning */
- (void)glyphs; /* avoid warning */
- (void)nglyphs; /* avoid warning */
- (void)wmode; /* avoid warning */
- (void)nglyphs; /* avoid warning */
- (void)kern; /* avoid warning */
- fprintf(stderr, "MacOS kerning tables have not been implemented yet!\n");
-}
-
-static void KernGlyphsPrim2(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern)
-{
- sal_uInt32 i, j;
- sal_uInt32 gpair;
-
- if( ! nglyphs )
- return;
-
- for (i = 0; i < (sal_uInt32)nglyphs - 1; i++) {
- gpair = (glyphs[i] << 16) | glyphs[i+1];
-#ifdef DEBUG2
- /* All fonts with MS kern table that I've seen so far contain just one kern subtable.
- * MS kern documentation is very poor and I doubt that font developers will be using
- * several subtables. I expect them to be using OpenType tables instead.
- * According to MS documention, format 2 subtables are not supported by Windows and OS/2.
- */
- if (ttf->nkern > 1) {
- fprintf(stderr, "KernGlyphsPrim2: %d kern tables found.\n", ttf->nkern);
- }
-#endif
- for (j = 0; j < ttf->nkern; j++) {
- sal_uInt16 coverage = GetUInt16(ttf->kerntables[j], 4, 1);
- sal_uInt8 *ptr;
- int npairs;
- sal_uInt32 t;
- int l, r, k;
-
- if (! ((coverage & 1) ^ wmode)) continue;
- if ((coverage & 0xFFFE) != 0) {
-#ifdef DEBUG2
- fprintf(stderr, "KernGlyphsPrim2: coverage flags are not supported: %04X.\n", coverage);
-#endif
- continue;
- }
- ptr = ttf->kerntables[j];
- npairs = GetUInt16(ptr, 6, 1);
- ptr += 14;
- l = 0;
- r = npairs;
- do {
- k = (l + r) >> 1;
- t = GetUInt32(ptr, k * 6, 1);
- if (gpair >= t) l = k + 1;
- if (gpair <= t) r = k - 1;
- } while (l <= r);
- if (l - r == 2) {
- if (!wmode) {
- kern[i].x = XUnits(ttf->unitsPerEm, GetInt16(ptr, 4 + (l-1) * 6, 1));
- } else {
- kern[i].y = XUnits(ttf->unitsPerEm, GetInt16(ptr, 4 + (l-1) * 6, 1));
- }
- /* !wmode ? kern[i].x : kern[i].y = GetInt16(ptr, 4 + (l-1) * 6, 1); */
- }
- }
- }
-}
-#endif
-
/*- Public functions */ /*FOLD00*/
int CountTTCFonts(const char* fname)
@@ -1754,10 +1616,6 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
return SF_TTFORMAT;
}
-#ifdef DEBUG2
- fprintf(stderr, "tdoffset: %d\n", tdoffset);
-#endif
-
/* magic number */
t->tag = TTFontClassTag;
@@ -2741,23 +2599,6 @@ void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
}
}
-#ifdef TEST5
-void KernGlyphs(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern)
-{
- int i;
-
- if (!nglyphs || !glyphs || !kern) return;
-
- for (i = 0; i < nglyphs-1; i++) kern[i].x = kern[i].y = 0;
-
- switch (ttf->kerntype) {
- case KT_APPLE_NEW: KernGlyphsPrim1(ttf, glyphs, nglyphs, wmode, kern); return;
- case KT_MICROSOFT: KernGlyphsPrim2(ttf, glyphs, nglyphs, wmode, kern); return;
- default: return;
- }
-}
-#endif
-
GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID)
{
const sal_uInt8* glyf = getTable(ttf, O_glyf);
@@ -2862,10 +2703,6 @@ int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr)
}
else
{
-#ifdef DEBUG
- fprintf( stderr, "found invalid name record %d with name id %d for file %s\n",
- i, rec[i].nameID, ttf->fname );
-#endif
rec[i].sptr = 0;
rec[i].slen = 0;
}
@@ -2892,422 +2729,4 @@ void DisposeNameRecords(NameRecord* nr, int n)
} // namespace vcl
-
-#ifdef TEST1
-/* This example creates a subset of a TrueType font with two encoded characters */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- int r;
-
- /* Array of Unicode source characters */
- sal_uInt16 chars[2];
-
- /* Encoding vector maps character encoding to the ordinal number
- * of the glyph in the output file */
- sal_uInt8 encoding[2];
-
- /* This array is for glyph IDs that source characters map to */
- sal_uInt16 g[2];
-
-
- if (ac < 2) return 0;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
-
- /* We want to create the output file that only contains two Unicode characters:
- * L'a' and L'A' */
-
- chars[0] = L'a';
- chars[1] = L'A';
-
- /* Figure out what glyphs do these characters map in our font */
- MapString(fnt, chars, 2, g);
-
- /* Encode the characters. Value of encoding[i] is the number 0..255 which maps to glyph i of the
- * newly generated font */
- encoding[0] = chars[0];
- encoding[1] = chars[1];
-
-
- /* Generate a subset */
- CreateT3FromTTGlyphs(fnt, stdout, 0, g, encoding, 2, 0);
-
- /* Now call the dtor for the font */
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-#ifdef TEST2
-/* This example extracts first 224 glyphs from a TT fonts and encodes them starting at 32 */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- int i, r;
-
- /* Array of Unicode source characters */
- sal_uInt16 glyphs[224];
-
- /* Encoding vector maps character encoding to the ordinal number
- * of the glyph in the output file */
- sal_uInt8 encoding[224];
-
-
-
- for (i=0; i<224; i++) {
- glyphs[i] = i;
- encoding[i] = 32 + i;
- }
-
- if (ac < 2) return 0;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
-
- /* Encode the characters. Value of encoding[i] is the number 0..255 which maps to glyph i of the
- * newly generated font */
-
- /* Generate a subset */
- CreateT3FromTTGlyphs(fnt, stdout, 0, glyphs, encoding, 224, 0);
-
- /* Now call the dtor for the font */
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-#ifdef TEST3
-/* Glyph metrics example */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- int i, r;
- sal_uInt16 glyphs[224];
- TTSimpleGlyphMetrics *m;
-
- for (i=0; i<224; i++) {
- glyphs[i] = i;
- }
-
- if (ac < 2) return 0;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- if ((m = GetTTSimpleGlyphMetrics(fnt, glyphs, 224, 0)) == 0) {
- printf("Requested metrics is not available\n");
- } else {
- for (i=0; i<224; i++) {
- printf("%d. advWid: %5d, LSBear: %5d\n", i, m[i].adv, m[i].sb);
- }
- }
-
- /* Now call the dtor for the font */
- free(m);
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-#ifdef TEST4
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- TTGlobalFontInfo info;
- int i, r;
-
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- printf("Font file: %s\n", av[1]);
-
-#ifdef PRINT_KERN
- switch (fnt->kerntype) {
- case KT_MICROSOFT:
- printf("\tkern: MICROSOFT, ntables: %d.", fnt->nkern);
- if (fnt->nkern) {
- printf(" [");
- for (i=0; i<fnt->nkern; i++) {
- printf("%04X ", GetUInt16(fnt->kerntables[i], 4, 1));
- }
- printf("]");
- }
- printf("\n");
- break;
-
- case KT_APPLE_NEW:
- printf("\tkern: APPLE_NEW, ntables: %d.", fnt->nkern);
- if (fnt->nkern) {
- printf(" [");
- for (i=0; i<fnt->nkern; i++) {
- printf("%04X ", GetUInt16(fnt->kerntables[i], 4, 1));
- }
- printf("]");
- }
- printf("\n");
- break;
-
- case KT_NONE:
- printf("\tkern: none.\n");
- break;
-
- default:
- printf("\tkern: unrecoginzed.\n");
- break;
- }
- printf("\n");
-#endif
-
- GetTTGlobalFontInfo(fnt, &info);
- printf("\tfamily name: `%s`\n", info.family);
- printf("\tsubfamily name: `%s`\n", info.subfamily);
- printf("\tpostscript name: `%s`\n", info.psname);
- printf("\tweight: %d\n", info.weight);
- printf("\twidth: %d\n", info.width);
- printf("\tpitch: %d\n", info.pitch);
- printf("\titalic angle: %d\n", info.italicAngle);
- printf("\tbouding box: [%d %d %d %d]\n", info.xMin, info.yMin, info.xMax, info.yMax);
- printf("\tascender: %d\n", info.ascender);
- printf("\tdescender: %d\n", info.descender);
- printf("\tlinegap: %d\n", info.linegap);
- printf("\tvascent: %d\n", info.vascent);
- printf("\tvdescent: %d\n", info.vdescent);
- printf("\ttypoAscender: %d\n", info.typoAscender);
- printf("\ttypoDescender: %d\n", info.typoDescender);
- printf("\ttypoLineGap: %d\n", info.typoLineGap);
- printf("\twinAscent: %d\n", info.winAscent);
- printf("\twinDescent: %d\n", info.winDescent);
- printf("\tUnicode ranges:\n");
- for (i = 0; i < 32; i++) {
- if ((info.ur1 >> i) & 1) {
- printf("\t\t\t%s\n", UnicodeRangeName(i));
- }
- }
- for (i = 0; i < 32; i++) {
- if ((info.ur2 >> i) & 1) {
- printf("\t\t\t%s\n", UnicodeRangeName(i+32));
- }
- }
- for (i = 0; i < 32; i++) {
- if ((info.ur3 >> i) & 1) {
- printf("\t\t\t%s\n", UnicodeRangeName(i+64));
- }
- }
- for (i = 0; i < 32; i++) {
- if ((info.ur4 >> i) & 1) {
- printf("\t\t\t%s\n", UnicodeRangeName(i+96));
- }
- }
-
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-#ifdef TEST5
-/* Kerning example */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- sal_uInt16 g[224];
- KernData d[223];
- int r, i, k = 0;
-
- g[k++] = 11;
- g[k++] = 36;
- g[k++] = 11;
- g[k++] = 98;
- g[k++] = 11;
- g[k++] = 144;
- g[k++] = 41;
- g[k++] = 171;
- g[k++] = 51;
- g[k++] = 15;
-
- if (ac < 2) return 0;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- KernGlyphs(fnt, g, k, 0, d);
-
- for (i = 0; i < k-1; i++) {
- printf("%3d %3d: [%3d %3d]\n", g[i], g[i+1], d[i].x, d[i].y);
- }
-
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-
-
-#ifdef TEST6
-/* This example extracts a single glyph from a font */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- int r, i;
-
- sal_uInt16 glyphs[256];
- sal_uInt8 encoding[256];
-
- for (i=0; i<256; i++) {
- glyphs[i] = 512 + i;
- encoding[i] = i;
- }
-
- if (ac < 2) return 0;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- /* Generate a subset */
- CreateT3FromTTGlyphs(fnt, stdout, 0, glyphs, encoding, 256, 0);
-
- fprintf(stderr, "UnitsPerEm: %d.\n", fnt->unitsPerEm);
-
- /* Now call the dtor for the font */
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-#ifdef TEST7
-/* NameRecord extraction example */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- int r, i, j, n;
- NameRecord *nr;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- if ((n = GetTTNameRecords(fnt, &nr)) == 0) {
- fprintf(stderr, "No name records in the font.\n");
- return 0;
- }
-
- printf("Number of name records: %d.\n", n);
- for (i = 0; i < n; i++) {
- printf("%d %d %04X %d [", nr[i].platformID, nr[i].encodingID, nr[i].languageID, nr[i].nameID);
- for (j=0; j<nr[i].slen; j++) {
- printf("%c", isprint(nr[i].sptr[j]) ? nr[i].sptr[j] : '.');
- }
- printf("]\n");
- }
-
-
- DisposeNameRecords(nr, n);
- CloseTTFont(fnt);
- return 0;
-}
-#endif
-
-#ifdef TEST8
-/* TrueType -> TrueType subsetting */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- sal_uInt16 glyphArray[] = { 0, 98, 99, 22, 24, 25, 26, 27, 28, 29, 30, 31, 1270, 1289, 34};
- sal_uInt8 encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46};
- int r;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- CreateTTFromTTGlyphs(fnt, "subfont.ttf", glyphArray, encoding, 15, 0, 0, TTCF_AutoName | TTCF_IncludeOS2);
-
-
- CloseTTFont(fnt);
-
- return 0;
-}
-#endif
-
-#ifdef TEST9
-/* TrueType -> Type42 subsetting */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- /*
- sal_uInt16 glyphArray[] = { 0, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34};
- sal_uInt8 encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46};
- */
- sal_uInt16 glyphArray[] = { 0, 6711, 6724, 11133, 11144, 14360, 26, 27, 28, 29, 30, 31, 1270, 1289, 34};
- sal_uInt8 encoding[] = {32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46};
- int r;
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- CreateT42FromTTGlyphs(fnt, stdout, "testfont", glyphArray, encoding, 15);
-
- CloseTTFont(fnt);
-
- return 0;
-}
-#endif
-
-#ifdef TEST10
-/* Component glyph test */
-int main(int ac, char **av)
-{
- TrueTypeFont *fnt;
- int r, i;
- list glyphlist = listNewEmpty();
-
-
- if ((r = OpenTTFont(av[1], 0, &fnt)) != SF_OK) {
- fprintf(stderr, "Error %d opening font file: `%s`.\n", r, av[1]);
- return 0;
- }
-
- for (i = 0; i < fnt->nglyphs; i++) {
- r = GetTTGlyphComponents(fnt, i, glyphlist);
- if (r > 1) {
- printf("%d -> ", i);
- listToFirst(glyphlist);
- do {
- printf("%d ", (int) listCurrent(glyphlist));
- } while (listNext(glyphlist));
- printf("\n");
- } else {
- printf("%d: single glyph.\n", i);
- }
- listClear(glyphlist);
- }
-
- CloseTTFont(fnt);
- listDispose(glyphlist);
-
- return 0;
-}
-#endif
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */