freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] Compact format fonts


From: Eric Nickell
Subject: Re: [Freetype] Compact format fonts
Date: Mon, 25 Nov 2002 09:12:35 PST

Sorry.  Should have sent out a note earlier.  The file attached to that
first message had been inappropriately truncated; so the cff file was
bad.

I am now able to read cff files, but *only* when I have patched the
freetype sources (cffload.c, line 1608) to skip the check which requires
num_glyphs to be 229.

Attached are two cff files which I am able to read with the patched
sources.  They were extracted from typical pdf documents.  It would also
be a good idea to test that freetype can load the example file given in
the cff documentation.  Below, I've appended the skeleton for such a
test.

Eric



/* apologies in advance ... i'm not a c programmer */

static unsigned char dummyFontBytes[] = {
        0x01, 0x00, 0x04, 0x01, 0x00, 0x01, 0x01, 0x01, 
        0x13, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x2b, 
        0x54, 0x69, 0x6d, 0x65, 0x73, 0x2d, 0x52, 0x6f, 
        0x6d, 0x61, 0x6e, 0x00, 0x01, 0x01, 0x01, 0x1f, 
        0xf8, 0x1b, 0x00, 0xf8, 0x1c, 0x02, 0xf8, 0x1d, 
        0x03, 0xf8, 0x19, 0x04, 0x1c, 0x6f, 0x00, 0x0d, 
        0xfb, 0x3c, 0xfb, 0x6e, 0xfa, 0x7c, 0xfa, 0x16, 
        0x05, 0xe9, 0x11, 0xb8, 0xf1, 0x12, 0x00, 0x03, 
        0x01, 0x01, 0x08, 0x13, 0x18, 0x30, 0x30, 0x31, 
        0x2e, 0x30, 0x30, 0x37, 0x54, 0x69, 0x6d, 0x65, 
        0x73, 0x20, 0x52, 0x6f, 0x6d, 0x61, 0x6e, 0x54, 
        0x69, 0x6d, 0x65, 0x73, 0x00, 0x00, 0x00, 0x02, 
        0x01, 0x01, 0x02, 0x03, 0x0e, 0x0e, 0x7d, 0x99, 
        0xf9, 0x2a, 0x99, 0xfb, 0x76, 0x95, 0xf7, 0x73, 
        0x8b, 0x06, 0xf7, 0x9a, 0x93, 0xfc, 0x7c, 0x8c, 
        0x07, 0x7d, 0x99, 0xf8, 0x56, 0x95, 0xf7, 0x5e, 
        0x99, 0x08, 0xfb, 0x6e, 0x8c, 0xf8, 0x73, 0x93, 
        0xf7, 0x10, 0x8b, 0x09, 0xa7, 0x0a, 0xdf, 0x0b, 
        0xf7, 0x8e, 0x14 
};

void
Die(char *message, char *instance)
{
  printf("%s", message);
  if (instance != NULL)
    printf(" [%s]", instance);
  printf("\n");
  exit(1);
}

void
DieFtError(char *message, char *instance, FT_Error error)
{
  printf("%s %d", message, error);
  Die("", instance);
}

void
AssertEqualsInt(char *message, char *instance, int expected, int actual)
{
  char errorBuf[50];

  if (expected != actual) {
    sprintf(errorBuf, "%s expected %d found %d", message, expected,
actual);
    Die(errorBuf, instance);
  }
}

void
AssertTrue(char *message, char *instance, int condition)
{
  if (!condition) {
    Die(message, instance);
  }
}


void
AssertNoFTError(FT_Error error, char *message, char *instance)
{
  if (error != 0)
    DieFtError(message, instance, error);
}

static FT_Library theLibrary = NULL;

FT_Library
GetLibrary()
{
  if (theLibrary == NULL) {
    AssertNoFTError(FT_Init_FreeType(&theLibrary), "FT_Init_FreeType",
NULL);
  }
  return theLibrary;
}

void
TestNewMemoryFace()
{
  FT_Library library;
  FT_Face face;

  library = GetLibrary();
  AssertNoFTError(FT_New_Memory_Face(library, dummyFontBytes,
sizeof(dummyFontBytes), 0, &face), "FT_New_Memory_Face", NULL);
  AssertEqualsInt("Glyphs expected", "Example font", 2,
face->num_glyphs);
  AssertTrue("Is scalable", "Example font", face->face_flags &
FT_FACE_FLAG_SCALABLE);
}

main()
{
  TestNewMemoryFace();
}

On Sat, 2002-11-23 at 08:41, David Turner wrote:
> Hello Eric,
> 
> sorry for this late answer.
> 
> Eric Nickell wrote:
> > I've just started poking around a little at Freetype, mostly as a way to
> > decode cff fonts embedded in pdf documents. When I run the following
> > code, the type 1 font tests out fine (as far as opening it), but the cff
> > font does not.  Any suggestions on what I'm doing wrong?
> > 
> > Attached is the cff file I'm trying to read, and below are excerts of
> > our test code trying to open it.
> > 
> I've tested your file, and FreeType rejects it because it cannot read
> the private dictionary. It seems that that file contains an offset
> (3839) that is outside the font file's length (3317 bytes).
> 
> I don't know if the problem comes from FreeType mal-reading the offset
> from the file, or a broken input. Can you guarantee that your file
> is OK ??
> 
> Regards,
> 
> - David Turner
> - The FreeType Project  (www.freetype.org)
> 
> 
> > Eric
> > 
> > 
> > #include <stdio.h>
> > #include <freetype.h>
> > 
> > void TestNewFace();
> > 
> > char *testFiles[] = {
> >     "garamond-lightitalic.psf",
> >     "ANBAIB+Times-Italic.cff",
> > };
> > 
> > #define N_TESTFILES 2
> > 
> > main()
> > {
> >   TestNewFace();
> > }
> > 
> > void
> > DieFtError(char *s, FT_Error error)
> > {
> >   printf("%s %d\n", s, error);
> >   exit(error);
> > }
> > 
> > void
> > AssertNoFTError(FT_Error error, char *s)
> > {
> >   if (error != 0)
> >     DieFtError(s, error);
> > }
> > 
> > FT_Library
> > GetLibrary()
> > {
> >   FT_Library library;
> >   FT_Error error;
> > 
> >   AssertNoFTError(FT_Init_FreeType(&library), "FT_Init_FreeType");
> >   return library;
> > }
> > 
> > void
> > TestNewFace()
> > {
> >   FT_Library library;
> >   FT_Face face;
> >   int i;
> > 
> >   library = GetLibrary();
> >   for (i = 0; i <  N_TESTFILES; i++) {
> >     AssertNoFTError(FT_New_Face(library, testFiles[i], 0, &face),
> > testFiles[i]);
> >   }
> > }
> > 
> 
> 
> 
> _______________________________________________
> Freetype mailing list
> address@hidden
> http://www.freetype.org/mailman/listinfo/freetype

Attachment: ANBAHA+ArialNarrow-Bold.cff
Description: Binary data

Attachment: ANBAIB+Times-Italic.cff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]