--- a/src/doc/PdfDocument.cpp
+++ b/src/doc/PdfDocument.cpp
@@ -236,6 +236,12 @@ PdfFont* PdfDocument::CreateFontSubset( const char* pszFontName, bool bBold, boo
     return m_fontCache.GetFontSubset( pszFontName, bBold, bItalic, bSymbolCharset, pEncoding, pszFileName );
 }
 
+PdfFont *PdfDocument::CreateFontSubsetWithPSName( const char *pszPSFontName, bool bSymbolCharset,
+                                                  const PdfEncoding * const pEncoding, const char *pszFileName, int nFaceIndex )
+{
+    return m_fontCache.GetFontSubsetWithPSName( pszPSFontName, bSymbolCharset, pEncoding, pszFileName, nFaceIndex );
+}
+
 #if defined(_WIN32) && !defined(PODOFO_NO_FONTMANAGER)
 PdfFont* PdfDocument::CreateFontSubset( const wchar_t* pszFontName, bool bBold, bool bItalic, bool bSymbolCharset,
                                         const PdfEncoding * const pEncoding)
--- a/src/doc/PdfDocument.h
+++ b/src/doc/PdfDocument.h
@@ -274,8 +274,22 @@ class PODOFO_DOC_API PdfDocument {
      *  \returns PdfFont* a pointer to a new PdfFont object.
      */
     PdfFont* CreateFontSubset( const char* pszFontName, bool bBold, bool bItalic, bool bSymbolCharset = false,
-			       const PdfEncoding * const pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
-			       const char* pszFileName = NULL);
+                               const PdfEncoding * const pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
+                               const char* pszFileName = NULL);
+
+    /** Creates a font subset which contains only a few characters and is embedded using Postscript name.
+     *
+     *  \param pszPSFontName Postscript name of the font
+     *  \param bSymbolCharset whether to use the symbol charset, rather than unicode charset
+     *  \param pEncoding the encoding of the font. The font will not take ownership of this object
+     *  \param pszFileName optional path of a font file which should be used
+     *  \param nFaceIndex Index of face if the font file contains multiple faces
+     *
+     *  \returns PdfFont* a pointer to a new PdfFont object.
+     */
+    PdfFont* CreateFontSubsetWithPSName( const char* pszPSFontName, bool bSymbolCharset = false,
+                                         const PdfEncoding * const pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
+                                         const char* pszFileName = NULL, int nFaceIndex = 0 );
 
 #ifdef _WIN32
     /** Creates a font subset which contains only a few characters and is embedded.
--- a/src/doc/PdfFontCID.cpp
+++ b/src/doc/PdfFontCID.cpp
@@ -277,7 +277,9 @@ void PdfFontCID::EmbedFont( PdfObject* pDescriptor )
 			PdfRefCountedBuffer buffer;
 			PdfOutputDevice output(&buffer);
 
-            PdfFontTTFSubset subset(&input, pMetrics, PdfFontTTFSubset::eFontFileType_TTF);
+            PdfFontTTFSubset subset( &input, pMetrics,
+                                     PdfFontTTFSubset::GetFontFileTypeByExt(pMetrics->GetFilename()),
+                                     pMetrics->GetFaceIndex() );
 
             std::vector<unsigned char> array;
             subset.BuildFont(buffer, m_setUsed, array );
--- a/src/doc/PdfFontCache.cpp
+++ b/src/doc/PdfFontCache.cpp
@@ -669,6 +669,50 @@ PdfFont* PdfFontCache::GetFontSubset( const char* pszFontName, bool bBold, bool
     return pFont;
 }
 
+PdfFont *PdfFontCache::GetFontSubsetWithPSName( const char *pszPSFontName, bool bSymbolCharset, const PdfEncoding * const pEncoding,
+                                                const char *pszFileName, int nFaceIndex )
+{
+    PODOFO_ASSERT( pEncoding );
+
+    PdfFont* pFont = NULL;
+    PdfFontMetrics* pMetrics = NULL;
+    std::pair<TISortedFontList,TCISortedFontList> it;
+
+    // WARNING: The characters are completely ignored right now!
+    it = std::equal_range( m_vecFontSubsets.begin(), m_vecFontSubsets.end(),
+                           TFontCacheElement( pszPSFontName, bSymbolCharset, pEncoding ) );
+    if( it.first == it.second )
+    {
+        std::string sPath;
+        int faceIndex = -1;
+        if( pszFileName == NULL || *pszFileName == 0)
+        {
+            this->GetFontPathForPSName( pszPSFontName, sPath, faceIndex );
+            if( sPath.empty() )
+            {
+#if defined(_WIN32) && !defined(PODOFO_NO_FONTMANAGER)
+            PdfError::LogMessage( eLogSeverity_Critical, "GetFontSubsetWithPSName Windows version is not implemented yet\n" );
+#else
+            PdfError::LogMessage( eLogSeverity_Critical, "No path was found for the specified PS fontname: %s\n", pszPSFontName );
+            return NULL;
+#endif // _WIN32
+            }
+        }
+        else
+        {
+            sPath = pszFileName;
+            faceIndex = nFaceIndex;
+        }
+        pMetrics = PdfFontMetricsFreetype::CreateForSubsetting( &m_ftLibrary, sPath.c_str(), bSymbolCharset, genSubsetBasename(), faceIndex );
+        pFont = this->CreateFontObject( it.first, m_vecFontSubsets, pMetrics,
+                                        true, pszPSFontName, pEncoding, true );
+    }
+    else
+        pFont = (*it.first).m_pFont;
+
+    return pFont;
+}
+
 void PdfFontCache::EmbedSubsetFonts()
 {
     TCISortedFontList it = m_vecFontSubsets.begin();
@@ -855,6 +899,47 @@ std::string PdfFontCache::GetFontConfigFontPath( FcConfig* pConfig, const char*
     return sPath;
 }
 
+void PdfFontCache::GetFCFontPathForPSName( FcConfig *pConfig, const char *pszPSFontName, std::string &rsPath, int &rnFaceIndex )
+{
+    rsPath = "";
+    rnFaceIndex = -1;
+#ifdef FC_POSTSCRIPT_NAME
+    FcPattern* pattern;
+    FcPattern* matched;
+    FcResult result = FcResultMatch;
+    FcValue v;
+    // Build a pattern to search using fontname, bold and italic
+    pattern = FcPatternBuild( 0, FC_POSTSCRIPT_NAME,
+                              FcTypeString, pszPSFontName,
+                              static_cast<char*>(0) );
+    FcDefaultSubstitute( pattern );
+
+    if( !FcConfigSubstitute( pConfig, pattern, FcMatchFont ) )
+    {
+        FcPatternDestroy( pattern );
+        return;
+    }
+    matched = FcFontMatch( pConfig, pattern, &result );
+    if( result != FcResultNoMatch )
+    {
+        result = FcPatternGet( matched, FC_FILE, 0, &v );
+        rsPath = reinterpret_cast<const char*>(v.u.s);
+        result = FcPatternGet( matched, FC_INDEX, 0, &v );
+        rnFaceIndex = v.u.i;
+#ifdef PODOFO_VERBOSE_DEBUG
+        PdfError::LogMessage( eLogSeverity_Debug,
+                              "Got Font %s with index %d for %s\n", rsPath.c_str(), rnFaceIndex, pszPSFontName );
+#endif // PODOFO_DEBUG
+    }
+
+    FcPatternDestroy( pattern );
+    FcPatternDestroy( matched );
+#else
+    PdfError::LogMessage( eLogSeverity_Critical,
+                          "It seems you are using an old version of the fontconfig library. Please update the library to 2.10.92 version or later.\n" );
+#endif
+}
+
 #endif // PODOFO_HAVE_FONTCONFIG
 
 std::string PdfFontCache::GetFontPath( const char* pszFontName, bool bBold, bool bItalic )
@@ -870,7 +955,19 @@ std::string PdfFontCache::GetFontPath( const char* pszFontName, bool bBold, bool
     return sPath;
 }
 
-PdfFont* PdfFontCache::CreateFontObject( TISortedFontList itSorted, TSortedFontList & rvecContainer, 
+void PdfFontCache::GetFontPathForPSName( const char *pszPSFontName, std::string & rPath, int & rFaceIndex )
+{
+#if defined(PODOFO_HAVE_FONTCONFIG)
+    Util::PdfMutexWrapper mutex(m_fontConfig.GetFontConfigMutex());
+    FcConfig* pFcConfig = static_cast<FcConfig*>(m_fontConfig.GetFontConfig());
+    GetFCFontPathForPSName( pFcConfig, pszPSFontName, rPath, rFaceIndex );
+#else
+    rPath = "";
+    rFaceIndex = -1;
+#endif
+}
+
+PdfFont* PdfFontCache::CreateFontObject( TISortedFontList itSorted, TSortedFontList & rVecContainer,
                      PdfFontMetrics* pMetrics, bool bEmbedd, bool bBold, bool bItalic, 
                      const char* pszFontName, const PdfEncoding * const pEncoding, bool bSubsetting ) 
 {
@@ -904,7 +1001,7 @@ PdfFont* PdfFontCache::CreateFontObject( TISortedFontList itSorted, TSortedFontL
             element.m_bIsSymbolCharset = pMetrics->IsSymbol();
             
             // Do a sorted insert, so no need to sort again
-            rvecContainer.insert( itSorted, element );
+            rVecContainer.insert( itSorted, element );
         }
     } catch( PdfError & e ) {
         e.AddToCallstack( __FILE__, __LINE__ );
@@ -916,6 +1013,47 @@ PdfFont* PdfFontCache::CreateFontObject( TISortedFontList itSorted, TSortedFontL
     return pFont;
 }
 
+PdfFont *PdfFontCache::CreateFontObject( TISortedFontList itSorted,  TSortedFontList & rVecContainer,
+                                         PdfFontMetrics *pMetrics, bool bEmbedd, const char *pszPSName,
+                                         const PdfEncoding * const pEncoding, bool bSubsetting)
+{
+    PdfFont* pFont;
+
+    try {
+        int nFlags = ePdfFont_Normal;
+
+        if ( bSubsetting )
+            nFlags |= ePdfFont_Subsetting;
+
+        if( bEmbedd )
+            nFlags |= ePdfFont_Embedded;
+
+        pFont = PdfFontFactory::CreateFontObject( pMetrics, nFlags, pEncoding, m_pParent );
+
+        if( pFont )
+        {
+            TFontCacheElement element;
+            element.m_pFont = pFont;
+            element.m_sPSName = pszPSName;
+            element.m_bUsePSName = true;
+            element.m_bBold = false;
+            element.m_bItalic = false;
+            element.m_pEncoding = pEncoding;
+            element.m_bIsSymbolCharset = pMetrics->IsSymbol();
+
+            // Do a sorted insert, so no need to sort again
+            rVecContainer.insert( itSorted, element );
+        }
+    } catch( PdfError & e ) {
+        e.AddToCallstack( __FILE__, __LINE__ );
+        e.PrintErrorMsg();
+        PdfError::LogMessage( eLogSeverity_Error, "Cannot initialize font: %s\n", pszPSName ? pszPSName : "" );
+        return NULL;
+    }
+
+    return pFont;
+}
+
 const char *PdfFontCache::genSubsetBasename(void)
 {
     int ii = 0;
--- a/src/doc/PdfFontCache.h
+++ b/src/doc/PdfFontCache.h
@@ -75,25 +75,40 @@ class PdfVecObjects;
 struct TFontCacheElement {
     TFontCacheElement() 
         : m_pFont( NULL ),
-	  m_pEncoding( NULL ),
-	  m_bBold( false ),
-	  m_bItalic( false ),
+          m_pEncoding( NULL ),
+          m_bBold( false ),
+          m_bItalic( false ),
+          m_bUsePSName( false ),
           m_bIsSymbolCharset (false)
     {
     }
 
     TFontCacheElement( const char* pszFontName, bool bBold, bool bItalic, bool bIsSymbolCharset,
-		               const PdfEncoding * const pEncoding )
-        : m_pFont(NULL), m_pEncoding( pEncoding ), m_bBold( bBold ), m_bItalic( bItalic ),
-          m_sFontName( reinterpret_cast<const pdf_utf8*>(pszFontName) ), m_bIsSymbolCharset (bIsSymbolCharset)
+                       const PdfEncoding * const pEncoding )
+        : m_pFont( NULL ), m_pEncoding( pEncoding ), m_bBold( bBold ), m_bItalic( bItalic ),
+          m_sFontName( reinterpret_cast<const pdf_utf8*>(pszFontName) ),
+          m_bUsePSName( false ),
+          m_bIsSymbolCharset ( bIsSymbolCharset )
+    {
+    }
+
+    TFontCacheElement( const char* pszPSName, bool bIsSymbolCharset,
+                       const PdfEncoding * const pEncoding )
+        : m_pFont( NULL ), m_pEncoding( pEncoding ),
+          m_bBold( false ), m_bItalic( false ),
+          m_bUsePSName( true ),
+          m_sPSName( reinterpret_cast<const pdf_utf8*>(pszPSName) ),
+          m_bIsSymbolCharset( bIsSymbolCharset )
     {
     }
 
 #if defined(_WIN32) && !defined(PODOFO_NO_FONTMANAGER)
     TFontCacheElement( const wchar_t* pszFontName, bool bBold, bool bItalic, bool bIsSymbolCharset,
-		       const PdfEncoding * const pEncoding )
-        : m_pFont(NULL), m_pEncoding( pEncoding ), m_bBold( bBold ), 
-          m_bItalic( bItalic ), m_sFontName( pszFontName ), m_bIsSymbolCharset (bIsSymbolCharset)
+                       const PdfEncoding * const pEncoding )
+        : m_pFont(NULL), m_pEncoding( pEncoding ), m_bBold( bBold ),
+          m_bItalic( bItalic ), m_sFontName( pszFontName ),
+          m_bUsePSName( false ),
+          m_bIsSymbolCharset (bIsSymbolCharset)
     {
     }
 #endif // _WIN32
@@ -105,11 +120,13 @@ struct TFontCacheElement {
     
     const TFontCacheElement & operator=( const TFontCacheElement & rhs ) 
     {
-        m_pFont     = rhs.m_pFont;
-        m_pEncoding = rhs.m_pEncoding;
-        m_bBold     = rhs.m_bBold;
-        m_bItalic   = rhs.m_bItalic;
-        m_sFontName = rhs.m_sFontName;
+        m_pFont      = rhs.m_pFont;
+        m_pEncoding  = rhs.m_pEncoding;
+        m_bBold      = rhs.m_bBold;
+        m_bItalic    = rhs.m_bItalic;
+        m_sFontName  = rhs.m_sFontName;
+        m_bUsePSName = rhs.m_bUsePSName;
+        m_sPSName    = rhs.m_sPSName;
         m_bIsSymbolCharset = rhs.m_bIsSymbolCharset;
         
         return *this;
@@ -117,27 +134,47 @@ struct TFontCacheElement {
     
     bool operator<( const TFontCacheElement & rhs ) const
     {
-		  if (m_bIsSymbolCharset != rhs.m_bIsSymbolCharset) {
-			   return m_bIsSymbolCharset < rhs.m_bIsSymbolCharset;
-		  }
-        if( m_sFontName == rhs.m_sFontName ) 
+        if( m_bUsePSName != rhs.m_bUsePSName )
+        {
+            return m_bUsePSName < rhs.m_bUsePSName;
+        }
+        if( m_bIsSymbolCharset != rhs.m_bIsSymbolCharset )
+        {
+            return m_bIsSymbolCharset < rhs.m_bIsSymbolCharset;
+        }
+        if ( m_bUsePSName )
         {
-            if( m_pEncoding == NULL  ||  rhs.m_pEncoding == NULL  ||  *m_pEncoding == *rhs.m_pEncoding ) 
+            if( m_sPSName == rhs.m_sPSName )
             {
-                if( m_bBold == rhs.m_bBold) 
-                    return m_bItalic < rhs.m_bItalic;
+                if( m_pEncoding == NULL || rhs.m_pEncoding == NULL || *m_pEncoding == *rhs.m_pEncoding )
+                    return false;
                 else
-                    return m_bBold < rhs.m_bBold;
+                    return *m_pEncoding < *rhs.m_pEncoding;
             }
             else
-                return *m_pEncoding < *rhs.m_pEncoding;
+                return m_sPSName < rhs.m_sPSName;
         }
         else
-            return (m_sFontName < rhs.m_sFontName);
+        {
+            if( m_sFontName == rhs.m_sFontName )
+            {
+                if( m_pEncoding == NULL || rhs.m_pEncoding == NULL || *m_pEncoding == *rhs.m_pEncoding )
+                {
+                    if( m_bBold == rhs.m_bBold )
+                        return m_bItalic < rhs.m_bItalic;
+                    else
+                        return m_bBold < rhs.m_bBold;
+                }
+                else
+                    return *m_pEncoding < *rhs.m_pEncoding;
+            }
+            else
+                return m_sFontName < rhs.m_sFontName;
+        }
     }
     
-    inline bool operator()( const TFontCacheElement& r1, 
-			    const TFontCacheElement& r2 ) const 
+    inline bool operator()( const TFontCacheElement& r1,
+                            const TFontCacheElement& r2 ) const
     { 
         return r1 < r2;
     }
@@ -147,6 +184,8 @@ struct TFontCacheElement {
     bool               m_bBold;
     bool               m_bItalic;
     PdfString          m_sFontName; ///< We use PdfString here as it can easily handle unicode on windows
+    bool               m_bUsePSName;
+    PdfString          m_sPSName;
     bool               m_bIsSymbolCharset;
 };
 
@@ -299,18 +338,33 @@ class PODOFO_DOC_API PdfFontCache {
      *  \param pszFontName a valid fontname
      *  \param bBold if true search for a bold font
      *  \param bItalic if true search for an italic font
-	  *  \param bSymbolCharset whether to use symbol charset, rather than unicode charset
+     *  \param bSymbolCharset whether to use symbol charset, rather than unicode charset
      *  \param pEncoding the encoding of the font. All characters
-     *                   of the encoding will be included in this subset.
-     *                   The font will not take ownership of this object.     
+     *         of the encoding will be included in this subset.
+     *         The font will not take ownership of this object.
      *  \param pszFileName optional path to a valid font file
      *
      *  \returns a PdfFont object or NULL if the font could
      *           not be created or found.
      */
     PdfFont* GetFontSubset( const char* pszFontName, bool bBold, bool bItalic, bool bSymbolCharset,
-			    const PdfEncoding * const = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
-			    const char* pszFileName = NULL);
+                            const PdfEncoding * const = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
+                            const char* pszFileName = NULL);
+
+    /** Get a fontsubset from the cache. If the font does not yet
+     * exist, add it to the cache.
+     *
+     *  \param pszPSFontName Postscript font name
+     *  \param bSymbolCharset whether to use symbol charset, rather than unicode charset
+     *  \param pEncoding the encoding of the font. All characters
+     *         of the encoding will be included in this subset
+     *         The font will not take ownership of this object
+     *  \param pszFileName optional path to a valid font file
+     *  \param nFaceIndex Index of face if the font file contains multiple faces
+     */
+    PdfFont* GetFontSubsetWithPSName( const char* pszPSFontName, bool bSymbolCharset,
+                                      const PdfEncoding * const pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
+                                      const char* pszFileName = NULL, int nFaceIndex = 0 );
 
     /** Embeds all pending subset-fonts
      *
@@ -331,6 +385,19 @@ class PODOFO_DOC_API PdfFontCache {
      *  \returns the path to the fontfile or an empty string
      */
     static std::string GetFontConfigFontPath( FcConfig* pConfig, const char* pszFontName, bool bBold, bool bItalic );
+
+    /** Get the path of a font file and face index on a Unix system using fontconfig
+     *
+     *  This method is only available if PoDoFo was compiled with
+     *  fontconfig support. Make sure to lock any FontConfig mutexes before
+     *  calling this method by yourself!
+     *
+     *  @param pConfig a handle to an initialized fontconfig library
+     *  @param pszPSFontName Postscript name of the font face
+     *  @param rsPath the path to the fontfile or an empty string
+     *  @param rnFaceIndex the face index in the fontfile or -1 if not found
+     */
+    static void GetFCFontPathForPSName(FcConfig* pConfig, const char* pszPSFontName, std::string &rsPath, int &rnFaceIndex );
 #endif // defined(PODOFO_HAVE_FONTCONFIG)
 
     // Peter Petrov: 26 April 2008
@@ -361,6 +428,8 @@ class PODOFO_DOC_API PdfFontCache {
      */
     std::string GetFontPath( const char* pszFontName, bool bBold, bool bItalic );
 
+    void GetFontPathForPSName(const char* pszPSFontName, std::string & rPath, int & rFaceIndex );
+
     /** Create a font and put it into the fontcache
      *
      *  \param itSorted iterator pointing to a location in vecContainer
@@ -376,11 +445,16 @@ class PODOFO_DOC_API PdfFontCache {
      *
      *  \returns a font handle or NULL in case of error
      */
-    PdfFont* CreateFontObject( TISortedFontList itSorted, TSortedFontList & vecContainer,
+    PdfFont* CreateFontObject( TISortedFontList itSorted, TSortedFontList & rVecContainer,
                                PdfFontMetrics* pMetrics, bool bEmbedd, bool bBold, 
                                bool bItalic, const char* pszFontName, const PdfEncoding * const pEncoding,
 							   bool bSubsetting = false );
 
+    PdfFont* CreateFontObject( TISortedFontList itSorted, TSortedFontList & rVecContainer,
+                               PdfFontMetrics* pMetrics, bool bEmbedd, const char* pszPSName,
+                               const PdfEncoding * const pEncoding,
+                               bool bSubsetting = false );
+
     /** Create a font subset.
      *  \param pMetrics a font metrics
      *  \param pszFontName a font name for debug output
--- a/src/doc/PdfFontMetrics.cpp
+++ b/src/doc/PdfFontMetrics.cpp
@@ -1021,4 +1021,9 @@ EPdfFontType PdfFontMetrics::FontTypeFromFilename( const char* pszFilename )
     return eFontType;
 }
 
+int PdfFontMetrics::GetFaceIndex() const
+{
+    return 0;
+}
+
 };
--- a/src/doc/PdfFontMetrics.h
+++ b/src/doc/PdfFontMetrics.h
@@ -235,6 +235,11 @@ class PODOFO_DOC_API PdfFontMetrics {
      */
     inline const char* GetFilename() const;
 
+    /** Set he path of the font file.
+     *  \param pszFilename a zero terminated string containing the filename of the font file
+     */
+    inline void SetFilename( const char* pszFilename );
+
     /** Get a pointer to the actual font data - if it was loaded from memory.
      *  \returns a binary buffer of data containing the font data
      */
@@ -379,6 +384,11 @@ class PODOFO_DOC_API PdfFontMetrics {
      */
     static EPdfFontType FontTypeFromFilename( const char* pszFilename );
 
+    /** Get an index of the face int the font
+     * \return index of the face in the font
+     */
+    virtual int GetFaceIndex() const;
+
  protected:
     /**
      *  Set the fonttype.
@@ -457,7 +467,7 @@ unsigned long PdfFontMetrics::GetLineSpacingMM() const
 // -----------------------------------------------------
 long PdfFontMetrics::GetUnderlinePositionMM() const
 {
-    return static_cast<long>(this->GetUnderlinePosition() /  PODOFO_CONVERSION_CONSTANT);
+    return static_cast<long>(this->GetUnderlinePosition() / PODOFO_CONVERSION_CONSTANT);
 }
 
 // -----------------------------------------------------
@@ -465,7 +475,7 @@ long PdfFontMetrics::GetUnderlinePositionMM() const
 // -----------------------------------------------------
 unsigned long PdfFontMetrics::GetStrikeOutPositionMM() const
 {
-    return static_cast<long>(this->GetStrikeOutPosition() /  PODOFO_CONVERSION_CONSTANT);
+    return static_cast<unsigned long>(this->GetStrikeOutPosition() / PODOFO_CONVERSION_CONSTANT);
 }
 
 // -----------------------------------------------------
@@ -495,6 +505,14 @@ const char* PdfFontMetrics::GetFilename() const
 // -----------------------------------------------------
 //
 // -----------------------------------------------------
+void PdfFontMetrics::SetFilename(const char* pszFilename)
+{
+    m_sFilename = pszFilename;
+}
+
+// -----------------------------------------------------
+//
+// -----------------------------------------------------
 EPdfFontType PdfFontMetrics::GetFontType() const
 {
     return m_eFontType;
--- a/src/doc/PdfFontMetricsFreetype.cpp
+++ b/src/doc/PdfFontMetricsFreetype.cpp
@@ -69,11 +69,12 @@ struct Scoped_FT_Face {
     FT_Face ftFace;
 };
 
-PdfFontMetricsFreetype* PdfFontMetricsFreetype::CreateForSubsetting(FT_Library* pLibrary, const char* pszFilename, bool pIsSymbol, const char* pszSubsetPrefix ) 
+PdfFontMetricsFreetype* PdfFontMetricsFreetype::CreateForSubsetting( FT_Library* pLibrary, const char* pszFilename, bool pIsSymbol,
+                                                                     const char* pszSubsetPrefix , int nFaceIndex )
 {
     Scoped_FT_Face scoped_face;
 
-    FT_Error err = FT_New_Face( *pLibrary, pszFilename, 0, &scoped_face.ftFace );
+    FT_Error err = FT_New_Face( *pLibrary, pszFilename, nFaceIndex, &scoped_face.ftFace );
     if (!err) {
         FT_ULong  length = 0;
         err = FT_Load_Sfnt_Table( scoped_face.ftFace, 0, 0, NULL, &length );
@@ -81,7 +82,9 @@ PdfFontMetricsFreetype* PdfFontMetricsFreetype::CreateForSubsetting(FT_Library*
             PdfRefCountedBuffer buffer(length);
             err = FT_Load_Sfnt_Table( scoped_face.ftFace, 0, 0, reinterpret_cast<FT_Byte*>(buffer.GetBuffer()), &length );
             if (!err) {
-                return new PdfFontMetricsFreetype( pLibrary, buffer, pIsSymbol, pszSubsetPrefix );
+                PdfFontMetricsFreetype* pMetrics = new PdfFontMetricsFreetype( pLibrary, buffer, pIsSymbol, pszSubsetPrefix, nFaceIndex );
+                pMetrics->SetFilename(pszFilename);
+                return pMetrics;
             }
         }
         // throw an exception
@@ -98,13 +101,14 @@ PdfFontMetricsFreetype* PdfFontMetricsFreetype::CreateForSubsetting(FT_Library*
     return 0;
 }
 
-PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary, const char* pszFilename, 
+PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary, const char* pszFilename,
                                                 bool pIsSymbol, const char* pszSubsetPrefix )
     : PdfFontMetrics( PdfFontMetrics::FontTypeFromFilename( pszFilename ),
                       pszFilename, pszSubsetPrefix ),
       m_pLibrary( pLibrary ),
       m_pFace( NULL ),
-      m_bSymbol( pIsSymbol )
+      m_bSymbol( pIsSymbol ),
+      m_nFaceIndex( 0 )
 {
     FT_Error err = FT_New_Face( *pLibrary, pszFilename, 0, &m_pFace );
     if ( err )
@@ -118,14 +122,15 @@ PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary, const char
     InitFromFace(pIsSymbol);
 }
 
-PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary, 
+PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary,
                                                 const char* pBuffer, unsigned int nBufLen,
-                                                                bool pIsSymbol,
-                                                const char* pszSubsetPrefix )
+                                                bool pIsSymbol,
+                                                const char* pszSubsetPrefix, int nFaceIndex )
     : PdfFontMetrics( ePdfFontType_Unknown, "", pszSubsetPrefix ),
       m_pLibrary( pLibrary ),
       m_pFace( NULL ),
-      m_bSymbol( pIsSymbol )
+      m_bSymbol( pIsSymbol ),
+      m_nFaceIndex( nFaceIndex )
 {
     m_bufFontData = PdfRefCountedBuffer( nBufLen ); // const_cast is ok, because we SetTakePossension to false!
     memcpy( m_bufFontData.GetBuffer(), pBuffer, nBufLen );
@@ -135,12 +140,13 @@ PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary,
 
 PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary, 
                                                 const PdfRefCountedBuffer & rBuffer,
-                                                                bool pIsSymbol,
-                                                const char* pszSubsetPrefix ) 
+                                                bool pIsSymbol,
+                                                const char* pszSubsetPrefix, int nFaceIndex )
     : PdfFontMetrics( ePdfFontType_Unknown, "", pszSubsetPrefix ),
       m_pLibrary( pLibrary ),
       m_pFace( NULL ),
       m_bSymbol( pIsSymbol ),
+      m_nFaceIndex( nFaceIndex ),
       m_bufFontData( rBuffer )
 {
     InitFromBuffer(pIsSymbol);
@@ -148,8 +154,8 @@ PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary,
 
 PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary, 
                                                 FT_Face face, 
-                                                                bool pIsSymbol,
-                                                const char* pszSubsetPrefix  )
+                                                bool pIsSymbol,
+                                                const char* pszSubsetPrefix )
     : PdfFontMetrics( ePdfFontType_TrueType, 
                       // Try to initialize the pathname from m_face
                       // so that font embedding will work
@@ -158,7 +164,8 @@ PdfFontMetricsFreetype::PdfFontMetricsFreetype( FT_Library* pLibrary,
                       pszSubsetPrefix ),
       m_pLibrary( pLibrary ),
       m_pFace( face ),
-      m_bSymbol( pIsSymbol )
+      m_bSymbol( pIsSymbol ),
+      m_nFaceIndex( 0 )
 {
     // asume true type
     // m_eFontType = ePdfFontType_TrueType;
@@ -179,9 +186,9 @@ void PdfFontMetricsFreetype::InitFromBuffer(bool pIsSymbol)
     FT_Open_Args openArgs;
     memset(&openArgs, 0, sizeof(openArgs));
     openArgs.flags = FT_OPEN_MEMORY;
-    openArgs.memory_base = reinterpret_cast<FT_Byte*>(m_bufFontData.GetBuffer()), 
+    openArgs.memory_base = reinterpret_cast<FT_Byte*>(m_bufFontData.GetBuffer());
     openArgs.memory_size = static_cast<FT_Long>(m_bufFontData.GetSize());
-    FT_Error error = FT_Open_Face( *m_pLibrary, &openArgs, 0, &m_pFace ); 
+    FT_Error error = FT_Open_Face( *m_pLibrary, &openArgs, m_nFaceIndex, &m_pFace );
     if( error ) 
     {
         PdfError::LogMessage( eLogSeverity_Critical, "FreeType returned the error %i when calling FT_New_Face for a buffered font.", error );
@@ -212,7 +219,7 @@ void PdfFontMetricsFreetype::InitFromFace(bool pIsSymbol)
     m_dStrikeOutPosition  = 0.0;
     m_dStrikeOutThickness = 0.0;
     m_fFontSize           = 0.0f;
-     m_bSymbol = pIsSymbol;
+    m_bSymbol = pIsSymbol;
     m_bIsBold = false;
     m_bIsItalic = false;
 
@@ -488,7 +495,12 @@ const char* PdfFontMetricsFreetype::GetFontData() const
 pdf_long PdfFontMetricsFreetype::GetFontDataLen() const
 {
     return m_bufFontData.GetSize();
-}  
+}
+
+int PdfFontMetricsFreetype::GetFaceIndex() const
+{
+    return m_nFaceIndex;
+}
 
 // -----------------------------------------------------
 // 
--- a/src/doc/PdfFontMetricsFreetype.h
+++ b/src/doc/PdfFontMetricsFreetype.h
@@ -50,39 +50,41 @@ class PODOFO_DOC_API PdfFontMetricsFreetype : public PdfFontMetrics {
     /** Create a font metrics object for a given true type file
      *  \param pLibrary handle to an initialized FreeType2 library handle
      *  \param pszFilename filename of a truetype file
-	  *  \param pIsSymbol whether use a symbol encoding, rather than unicode
+     *  \param pIsSymbol whether use a symbol encoding, rather than unicode
      *  \param pszSubsetPrefix unique prefix for font subsets (see GetFontSubsetPrefix)
      */
-    PdfFontMetricsFreetype( FT_Library* pLibrary, const char* pszFilename, 
-			 bool pIsSymbol, const char* pszSubsetPrefix = NULL );
+    PdfFontMetricsFreetype( FT_Library* pLibrary, const char* pszFilename,
+                            bool pIsSymbol, const char* pszSubsetPrefix = NULL );
 
     /** Create a font metrics object for a given memory buffer
      *  \param pLibrary handle to an initialized FreeType2 library handle
      *  \param pBuffer block of memory representing the font data (PdfFontMetricsFreetype will copy the buffer)
      *  \param nBufLen the length of the buffer
-	  *  \param pIsSymbol whether use a symbol encoding, rather than unicode
+     *  \param pIsSymbol whether use a symbol encoding, rather than unicode
      *  \param pszSubsetPrefix unique prefix for font subsets (see GetFontSubsetPrefix)
+     *  \param nFaceIndex index of the face in the buffer
      */
     PdfFontMetricsFreetype( FT_Library* pLibrary, const char* pBuffer, unsigned int nBufLen,
-			 bool  pIsSymbol, const char* pszSubsetPrefix = NULL);
+                            bool  pIsSymbol, const char* pszSubsetPrefix = NULL, int nFaceIndex = 0);
 
     /** Create a font metrics object for a given true type file
      *  \param pLibrary handle to an initialized FreeType2 library handle
      *  \param rBuffer a buffer containing a font file
-	  *  \param pIsSymbol whether use a symbol encoding, rather than unicode
+     *  \param pIsSymbol whether use a symbol encoding, rather than unicode
      *  \param pszSubsetPrefix unique prefix for font subsets (see GetFontSubsetPrefix)
+     *  \param nFaceIndex index of the face in the buffer
      */
     PdfFontMetricsFreetype( FT_Library* pLibrary, const PdfRefCountedBuffer & rBuffer,
-		    bool  pIsSymbol, const char* pszSubsetPrefix = NULL);
+                            bool  pIsSymbol, const char* pszSubsetPrefix = NULL, int nFaceIndex = 0);
 
     /** Create a font metrics object for a given freetype font.
      *  \param pLibrary handle to an initialized FreeType2 library handle
      *  \param face a valid freetype font face
-	  *  \param pIsSymbol whether use a symbol encoding, rather than unicode
+     *  \param pIsSymbol whether use a symbol encoding, rather than unicode
      *  \param pszSubsetPrefix unique prefix for font subsets (see GetFontSubsetPrefix)
      */
     PdfFontMetricsFreetype( FT_Library* pLibrary, FT_Face face,
-		    bool  pIsSymbol, const char* pszSubsetPrefix = NULL);
+                            bool  pIsSymbol, const char* pszSubsetPrefix = NULL);
 
     /** Create a font metrics object based on an existing PdfObject
      *
@@ -94,10 +96,12 @@ class PODOFO_DOC_API PdfFontMetricsFreetype : public PdfFontMetrics {
     /** Create a font metrics object suitable for subsetting for a given true type file
      *  \param pLibrary handle to an initialized FreeType2 library handle
      *  \param pszFilename filename of a truetype file
-	 *  \param pIsSymbol whether use a symbol encoding, rather than unicode
+     *  \param pIsSymbol whether use a symbol encoding, rather than unicode
      *  \param pszSubsetPrefix unique prefix for font subsets (see GetFontSubsetPrefix)
+     *  \param nFaceIndex Index of the face in the font file.
      */
-    static PdfFontMetricsFreetype* CreateForSubsetting(FT_Library* pLibrary, const char* pszFilename, bool pIsSymbol, const char* pszSubsetPrefix );
+    static PdfFontMetricsFreetype* CreateForSubsetting( FT_Library* pLibrary, const char* pszFilename, bool pIsSymbol,
+                                                        const char* pszSubsetPrefix, int nFaceIndex = 0 );
 
     virtual ~PdfFontMetricsFreetype();
 
@@ -252,6 +256,11 @@ class PODOFO_DOC_API PdfFontMetricsFreetype : public PdfFontMetrics {
      */
     virtual pdf_long GetFontDataLen() const;
 
+    /** Get an index of the face int the font
+     * \return index of the face in the font
+     */
+    virtual int GetFaceIndex() const;
+
     /** Get whether the internal font style flags contain the Bold flag.
      *  \returns whether the Bold style flag is set on the font
      */
@@ -272,7 +281,8 @@ class PODOFO_DOC_API PdfFontMetricsFreetype : public PdfFontMetrics {
     
     /** Initialize this object from an in memory buffer
      *  Called internally by the constructors
-	  * \param pIsSymbol Whether use a symbol charset, rather than unicode
+     * \param pIsSymbol Whether use a symbol charset, rather than unicode
+     * \param nFaceIndex index of the face in the buffer
      */
     void InitFromBuffer(bool pIsSymbol);
 
@@ -306,6 +316,7 @@ class PODOFO_DOC_API PdfFontMetricsFreetype : public PdfFontMetrics {
     double        m_dStrikeOutThickness;
     double        m_dStrikeOutPosition;
 
+    int           m_nFaceIndex;
     PdfRefCountedBuffer m_bufFontData;
     std::vector<double> m_vecWidth;
 };
--- a/src/doc/PdfFontTTFSubset.cpp
+++ b/src/doc/PdfFontTTFSubset.cpp
@@ -116,26 +116,7 @@ PdfFontTTFSubset::PdfFontTTFSubset( const char* pszFontFileName, PdfFontMetrics*
       m_bIsLongLoca( false ), m_numTables( 0 ), m_numGlyphs( 0 ), m_numHMetrics( 0 ), m_faceIndex( nFaceIndex ), m_ulStartOfTTFOffsets( 0 ),
       m_bOwnDevice( true )
 {
-    //File type is now distinguished by ext, which might cause problems.
-    const char* pname = pszFontFileName;
-    const char* ext   = pname + strlen(pname) - 3;
-
-    if (PoDoFo::compat::strcasecmp(ext,"ttf") == 0)
-    {
-        m_eFontFileType = eFontFileType_TTF;
-    }
-    else if (PoDoFo::compat::strcasecmp(ext,"ttc") == 0)
-    {
-        m_eFontFileType = eFontFileType_TTC;
-    }
-    else if (PoDoFo::compat::strcasecmp(ext,"otf") == 0)
-    {
-        m_eFontFileType = eFontFileType_OTF;
-    }
-    else
-    {
-        m_eFontFileType = eFontFileType_Unknown;
-    }
+    m_eFontFileType = GetFontFileTypeByExt(pszFontFileName);
 
     m_pDevice = new PdfInputDevice( pszFontFileName );
 }
@@ -850,6 +831,21 @@ void PdfFontTTFSubset::BuildFont( PdfRefCountedBuffer& outputBuffer, const std::
     WriteTables(outputBuffer);
 }
 
+PdfFontTTFSubset::EFontFileType PdfFontTTFSubset::GetFontFileTypeByExt( const char *pszFontFileName )
+{
+    //File type is now distinguished by ext, which might cause problems.
+    const char* pname = pszFontFileName;
+    const char* ext   = pname + strlen(pname) - 3;
+
+    if( PoDoFo::compat::strcasecmp( ext,"ttf" ) == 0 )
+        return eFontFileType_TTF;
+    else if( PoDoFo::compat::strcasecmp( ext,"ttc" ) == 0 )
+        return eFontFileType_TTC;
+    else if( PoDoFo::compat::strcasecmp( ext,"otf" ) == 0 )
+        return eFontFileType_OTF;
+    return eFontFileType_Unknown;
+}
+
 void PdfFontTTFSubset::GetData(unsigned long offset, void* address, unsigned long sz)
 {
     m_pDevice->Seek( offset );
--- a/src/doc/PdfFontTTFSubset.h
+++ b/src/doc/PdfFontTTFSubset.h
@@ -97,6 +97,13 @@ class PODOFO_DOC_API PdfFontTTFSubset {
      */
     void BuildFont( PdfRefCountedBuffer& outputBuffer, const std::set<pdf_utf16be>& usedChars, std::vector<unsigned char>& cidSet );
 
+    /** Get the type of a fontfile by its extension
+     *
+     *  @param pszFontFileName path to a font file
+     *  @return the type of a fontfile
+     */
+    static EFontFileType GetFontFileTypeByExt( const char* pszFontFileName );
+
  private:
     /** Hide default constructor
      */


