freetype-devel
[Top][All Lists]
Advanced

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

[Devel] Problems with FT_Get_Postscript_Name and TTF files?


From: Eric Poulsen
Subject: [Devel] Problems with FT_Get_Postscript_Name and TTF files?
Date: 28 Sep 2002 22:56:15 -0700

All,

I'm pretty new to using FreeType, and I'm having a bit of an issue with
FT_Get_Postscript_Name.  I have read through the documentation, and the
list archives.  The code listed results in a segfault.  The fonts are
from the Windows fonts library, though I'm developing for Linux.

If I comment out the FT_Get_Postscript_Name line, it works fine.  If I
have it only check postscript (.pfb) files, it works fine.

If I only do 1 or 2 TTF files, it's okay.  It seems iterating through a
large number of them will cause it to segfault when reading the name of
one of them.

I realize this code is rather simplistic and useless -- it's been boiled
down from a much larger project in order to demonstrate the problem at
hand.

Am I just doing something stupid?

-- Eric


System Info:
------------

Debian stable (woody)

 uname -a
Linux cerberus 2.4.19 #1 SMP Thu Aug 29 06:56:12 PDT 2002 i686 unknown


Compile info:
-------------

gcc -g -o crashme crashme.cpp -lfreetype -I. -I..
-I/usr/include/freetype2

gcc --version
2.95.4

Program output:
---------------

Font: fonts/simhei.ttf
Font: fonts/sylfaen.ttf
Font: fonts/symbol.ttf
Segmentation fault

GDB Output:
----------

(gdb) r
Starting program: /root/report/src/typeset/crashme 
Font: fonts/simhei.ttf
Font: fonts/sylfaen.ttf
Font: fonts/symbol.ttf

Program received signal SIGSEGV, Segmentation fault.
0x40041630 in ps2_hints_apply () from /usr/lib/libfreetype.so.6
(gdb) back
#0  0x40041630 in ps2_hints_apply () from /usr/lib/libfreetype.so.6
#1  0x4002541f in FT_Get_Postscript_Name () from
/usr/lib/libfreetype.so.6
#2  0x080487dc in main () at crashme.cpp:59

Entirety of code:

----------------------------

#include <ft2build.h>
#include <stdio.h>

#include FT_FREETYPE_H

int main ()
{

 char *fontlist[]={
"simhei.ttf",
"sylfaen.ttf",
"symbol.ttf",
"tahoma.ttf",
"tahomabd.ttf",
"times.ttf",
"timesbd.ttf",
"timesbi.ttf",
"timesi.ttf",
"trebuc.ttf",
"trebucbd.ttf",
"trebucbi.ttf",
"trebucit.ttf",
"tunga.ttf",
"verdana.ttf",
"verdanab.ttf",
"verdanai.ttf",
"verdanaz.ttf",
"webdings.ttf",
"wingding.ttf",
 ""
 };
 FT_Library     library;
 FT_Face        face;
 int            error;

 
 error = FT_Init_FreeType( &library );
 if (error)
 {
  printf("Init Error\n");
  exit(0);
 }
 
 char buf[300];
 
 for(int i = 0; ; i++)
 {
  if(strcmp(fontlist[i],"") == 0)
   break;
  sprintf(buf,"fonts/%s",fontlist[i]);
  printf("Font: %s\n",buf);
  error = FT_New_Face(library,buf,0,&face);
  if(error)
   continue;
  FT_Get_Postscript_Name(face);
  FT_Done_Face(face);
 
 }
 printf("done.\n");
}


------------------








reply via email to

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