Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Functions
scfonts.cpp File Reference
#include <qapplication.h>
#include <qdom.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qglobal.h>
#include <qstrlist.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qfont.h>
#include <qdict.h>
#include <qmap.h>
#include <qdir.h>
#include <qregexp.h>
#include <cstdlib>
#include "scfonts.h"
#include "fonts/ftface.h"
#include "fonts/scface_ps.h"
#include "fonts/scface_ttf.h"
#include "fonts/scfontmetrics.h"
#include "prefsmanager.h"
#include "prefsfile.h"
#include "prefscontext.h"
#include "prefstable.h"
#include "scribus.h"
#include "scribuscore.h"
#include "scpaths.h"
#include "util.h"

Go to the source code of this file.

Functions

void getFontFormat (FT_Face face, ScFace::FontFormat &fmt, ScFace::FontType &type)
 tests magic words to determine the fontformat and preliminary fonttype
void getSFontType (FT_Face face, ScFace::FontType &type)
 Checks face, which must be sfnt based, for the subtype.

Function Documentation

void getFontFormat ( FT_Face  face,
ScFace::FontFormat &  fmt,
ScFace::FontType &  type 
)

tests magic words to determine the fontformat and preliminary fonttype

Definition at line 199 of file scfonts.cpp.

{
       static const char* T42_HEAD      = "%!PS-TrueTypeFont";
       static const char* T1_HEAD      = "%!FontType1";
       static const char* T1_ADOBE_HEAD = "%!PS-AdobeFont-1";
       static const char* PSFONT_ADOBE2_HEAD  = "%!PS-Adobe-2.0 Font";
       static const char* PSFONT_ADOBE21_HEAD  = "%!PS-Adobe-2.1 Font";
       static const char* PSFONT_ADOBE3_HEAD  = "%!PS-Adobe-3.0 Resource-Font";
       static const int   FONT_NO_ERROR = 0;
       
       const FT_Stream fts = face->stream;
       char buf[128];
       
       fmt = ScFace::UNKNOWN_FORMAT;
       type = ScFace::UNKNOWN_TYPE;
       if (ftIOFunc(fts, 0L, reinterpret_cast<FT_Byte *>(buf), 128) == FONT_NO_ERROR) 
       {
              if(strncmp(buf,T42_HEAD,strlen(T42_HEAD)) == 0) 
              {
                     fmt = ScFace::TYPE42;
                     type = ScFace::TTF;
              }
              else if(strncmp(buf,T1_HEAD,strlen(T1_HEAD)) == 0 ||
                         strncmp(buf,T1_ADOBE_HEAD,strlen(T1_ADOBE_HEAD)) == 0) 
              {
                     fmt = ScFace::PFA;
                     type = ScFace::TYPE1;
              }
              else if(strncmp(buf,PSFONT_ADOBE2_HEAD,strlen(PSFONT_ADOBE2_HEAD)) == 0 ||
                         strncmp(buf,PSFONT_ADOBE21_HEAD,strlen(PSFONT_ADOBE21_HEAD)) == 0 ||
                         strncmp(buf,PSFONT_ADOBE3_HEAD,strlen(PSFONT_ADOBE3_HEAD)) ==0) 
              {
                     // Type2(CFF), Type0(Composite/CID), Type 3, Type 14 etc would end here
                     fmt = ScFace::PFA;
                     type = ScFace::UNKNOWN_TYPE;
              }
              else if(buf[0] == '\200' && buf[1] == '\1')
              {
                     fmt = ScFace::PFB;
                     type = ScFace::TYPE1;
              }
              else if(buf[0] == '\0' && buf[1] == '\1' 
                            && buf[2] == '\0' && buf[3] == '\0')
              {
                     fmt = ScFace::SFNT;
                     type = ScFace::TTF;
              }
              else if(strncmp(buf,"true",4) == 0)
              {
                     fmt = ScFace::SFNT;
                     type = ScFace::TTF;
              }
              else if(strncmp(buf,"ttcf",4) == 0)
              {
                     fmt = ScFace::TTCF;
                     type = ScFace::OTF;
              }
              else if(strncmp(buf,"OTTO",4) == 0)
              {
                     fmt = ScFace::SFNT;
                     type = ScFace::OTF;
              }
              // missing: raw CFF
       }
}

Here is the call graph for this function:

void getSFontType ( FT_Face  face,
ScFace::FontType &  type 
)

Checks face, which must be sfnt based, for the subtype.

Possible values: TTF, CFF, OTF

Definition at line 269 of file scfonts.cpp.

{
       if (FT_IS_SFNT(face)) 
       {
              FT_ULong ret = 0;
              bool hasGlyph = ! FT_Load_Sfnt_Table(face, TTAG_glyf, 0, NULL,  &ret);
              hasGlyph &= ret > 0;
              bool hasCFF = ! FT_Load_Sfnt_Table(face, TTAG_CFF, 0, NULL,  &ret);
              hasCFF &= ret > 0;
              if (hasGlyph)
                     type = ScFace::TTF;
              else if (hasCFF)
                     type = ScFace::OTF;
              // TODO: CID or no
       }
}