Index: src/base/PdfEncoding.h
===================================================================
--- src/base/PdfEncoding.h	(revision 1954)
+++ src/base/PdfEncoding.h	(working copy)
@@ -220,6 +220,16 @@
      */
     virtual pdf_utf16be GetCharCode( int nIndex ) const = 0;
 
+    virtual pdf_uint16 GetEncodedUnicode( pdf_uint16 unicodeValue ) const
+    {
+        if( m_bToUnicodeIsLoaded )
+        {
+            return GetCIDValue( unicodeValue );
+        }
+
+        return unicodeValue;
+    }
+
  protected:
     bool m_bToUnicodeIsLoaded;  ///< If true, ToUnicode has been parse
                              
@@ -408,6 +418,20 @@
 
     char GetUnicodeCharCode(pdf_utf16be unicodeValue) const;
 
+    pdf_uint16 GetEncodedUnicode( pdf_uint16 unicodeValue ) const
+    {
+        if( m_bToUnicodeIsLoaded )
+        {
+            return PdfEncoding::GetEncodedUnicode( unicodeValue );
+        }
+
+#ifdef PODOFO_IS_LITTLE_ENDIAN
+        unicodeValue = ((unicodeValue & 0xff00) >> 8) | ((unicodeValue & 0xff) << 8);
+#endif // PODOFO_IS_LITTLE_ENDIAN
+
+        return static_cast<unsigned char>(GetUnicodeCharCode( unicodeValue ));
+    }
+
  private:
     /** Initialize the internal table of mappings from unicode code points
      *  to encoded byte values.
Index: src/doc/PdfDifferenceEncoding.h
===================================================================
--- src/doc/PdfDifferenceEncoding.h	(revision 1954)
+++ src/doc/PdfDifferenceEncoding.h	(working copy)
@@ -283,6 +283,21 @@
      */
     virtual pdf_utf16be GetCharCode( int nIndex ) const;
 
+    pdf_uint16 GetEncodedUnicode( pdf_uint16 unicodeValue ) const
+    {
+#ifdef PODOFO_IS_LITTLE_ENDIAN
+        unicodeValue = ((unicodeValue & 0xff00) >> 8) | ((unicodeValue & 0xff) << 8);
+#endif // PODOFO_IS_LITTLE_ENDIAN
+
+        char val;
+        if (!m_differences.ContainsUnicodeValue( unicodeValue, val ))
+    	{
+            val = static_cast<const PdfSimpleEncoding*>(GetBaseEncoding())->GetUnicodeCharCode( unicodeValue );
+        }
+
+        return static_cast<unsigned char>(val);
+    }
+
  protected:
 
     /** Get a unique ID for this encoding
Index: src/doc/PdfFontMetricsObject.cpp
===================================================================
--- src/doc/PdfFontMetricsObject.cpp	(revision 1954)
+++ src/doc/PdfFontMetricsObject.cpp	(working copy)
@@ -203,23 +203,13 @@
 
 double PdfFontMetricsObject::CharWidth( unsigned char c ) const
 {
-    if( c >= m_nFirst && c <= m_nLast
-        && c - m_nFirst < static_cast<int>(m_width.GetSize()) )
-    {
-        double dWidth = m_width[c - m_nFirst].GetReal();
-        
-        return (dWidth * m_matrix.front().GetReal() * this->GetFontSize() + this->GetFontCharSpace()) * this->GetFontScale() / 100.0;
-
-    }
-
-    if( m_missingWidth != NULL )
-        return m_missingWidth->GetReal ();
-    else
-        return m_dDefWidth;
+    return UnicodeCharWidth(c);
 }
 
 double PdfFontMetricsObject::UnicodeCharWidth( unsigned short c ) const
 {
+    c = m_pEncoding->GetEncodedUnicode(c);
+
     if( c >= m_nFirst && c <= m_nLast
         && c - m_nFirst < static_cast<int>(m_width.GetSize()) )
     {
