Le 11/03/2011 14:42, Dominik Seichter a écrit :
> Hi Xavier,
>
> Thank you very much for your patches!
>
> I have a problem when I try to apply the cidfont.patch
>
> Could you please send an updated patch file for the cidfonts?
>
Sorry about that. Here's the patch. This one should work.
Greetings,
Xavier Trochu
EDP Sciences
Index: src/doc/PdfFontMetricsObject.h
===================================================================
--- src/doc/PdfFontMetricsObject.h (révision 1441)
+++ src/doc/PdfFontMetricsObject.h (copie de travail)
@@ -229,6 +229,7 @@
double m_dStrikeOutPosition;
bool m_bSymbol; ///< Internal member to singnal a symbol font
+ double m_dDefWidth; ///< default width
};
};
Index: src/doc/PdfFontMetricsObject.cpp
===================================================================
--- src/doc/PdfFontMetricsObject.cpp (révision 1441)
+++ src/doc/PdfFontMetricsObject.cpp (copie de travail)
@@ -31,16 +31,19 @@
PdfFontMetricsObject::PdfFontMetricsObject( PdfObject* pFont, PdfObject* pDescriptor, const PdfEncoding* const pEncoding )
: PdfFontMetrics( ePdfFontType_Unknown, "", NULL ),
- m_pEncoding( pEncoding )
+ m_pEncoding( pEncoding ), m_dDefWidth(0.0)
{
if( !pDescriptor )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
}
- m_sName = pDescriptor->GetDictionary().GetKey( "FontName" )->GetName();
- m_bbox = pDescriptor->GetDictionary().GetKey( "FontBBox" )->GetArray();
+ const PdfName & rSubType = pFont->GetDictionary().GetKey( PdfName::KeySubtype )->GetName();
+
// OC 15.08.2010 BugFix: /FirstChar /LastChar /Widths are in the Font dictionary and not in the FontDescriptor
+ if ( rSubType == PdfName("Type1") || rSubType == PdfName("TrueType") ) {
+ m_sName = pDescriptor->GetIndirectKey( "FontName" )->GetName();
+ m_bbox = pDescriptor->GetIndirectKey( "FontBBox" )->GetArray();
m_nFirst = static_cast<int>(pFont->GetDictionary().GetKeyAsLong( "FirstChar", 0L ));
m_nLast = static_cast<int>(pFont->GetDictionary().GetKeyAsLong( "LastChar", 0L ));
// OC 15.08.2010 BugFix: GetIndirectKey() instead of GetDictionary().GetKey() and "Widths" instead of "Width"
@@ -59,7 +62,60 @@
m_missingWidth = widths;
}
}
+ } else if ( rSubType == PdfName("CIDFontType0") || rSubType == PdfName("CIDFontType2") ) {
+ PdfObject *pObj = pDescriptor->GetIndirectKey( "FontName" );
+ if (pObj) {
+ m_sName = pObj->GetName();
+ }
+ pObj = pDescriptor->GetIndirectKey( "FontBBox" );
+ if (pObj) {
+ m_bbox = pObj->GetArray();
+ }
+ m_nFirst = 0;
+ m_nLast = 0;
+ m_dDefWidth = pFont->GetDictionary().GetKeyAsLong( "DW", 1000L );
+ PdfVariant default_width(m_dDefWidth);
+ PdfObject * pw = pFont->GetIndirectKey( "W" );
+
+ for (int i = m_nFirst; i <= m_nLast; ++i) {
+ m_width.push_back(default_width);
+ }
+ if (pw) {
+ PdfArray w = pw->GetArray();
+ int pos = 0;
+ while (pos < static_cast<int>(w.size())) {
+ int start = static_cast<int>(w[pos++].GetNumber());
+ PODOFO_ASSERT (start >= 0);
+ if (w[pos].IsArray()) {
+ PdfArray widths = w[pos++].GetArray();
+ int length = start + static_cast<int>(widths.size());
+ PODOFO_ASSERT (length >= start);
+ if (length > m_width.size()) {
+ m_width.resize(length, default_width);
+ }
+ for (int i = 0; i < static_cast<int>(widths.size()); ++i) {
+ m_width[start + i] = widths[i];
+ }
+ } else {
+ int end = static_cast<int>(w[pos++].GetNumber());
+ int length = start + end;
+ PODOFO_ASSERT (length >= start);
+ if (length > m_width.size()) {
+ m_width.resize(length, default_width);
+ }
+ pdf_int64 width = w[pos++].GetNumber();
+ for (int i = start; i <= end; ++i)
+ m_width[i] = PdfVariant(width);
+ }
+ }
+ }
+ m_nLast = m_width.size() - 1;
+ } else {
+ PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedFontFormat, rSubType.GetEscapedName().c_str() );
+ }
+
+
m_nWeight = static_cast<unsigned int>(pDescriptor->GetDictionary().GetKeyAsLong( "FontWeight", 400L ));
m_nItalicAngle = static_cast<int>(pDescriptor->GetDictionary().GetKeyAsLong( "ItalicAngle", 0L ));
@@ -94,7 +150,7 @@
double PdfFontMetricsObject::CharWidth( unsigned char c ) const
{
- if( c >= m_nFirst && c < m_nLast
+ if( c >= m_nFirst && c <= m_nLast
&& c - m_nFirst < m_width.size () )
{
double dWidth = m_width[c - m_nFirst].GetReal();
@@ -107,7 +163,7 @@
if( m_missingWidth != NULL )
return m_missingWidth->GetReal ();
else
- return 0.0;
+ return m_dDefWidth;
}
double PdfFontMetricsObject::UnicodeCharWidth( unsigned short c ) const
Index: src/doc/PdfFontCID.cpp
===================================================================
--- src/doc/PdfFontCID.cpp (révision 1441)
+++ src/doc/PdfFontCID.cpp (copie de travail)
@@ -53,7 +53,7 @@
PdfFontCID::PdfFontCID( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, PdfObject* pObject, bool bEmbed )
: PdfFont( pMetrics, pEncoding, pObject )
{
- this->Init( bEmbed );
+ /* this->Init( bEmbed ); */
}
void PdfFontCID::Init( bool bEmbed )
@@ -224,6 +224,7 @@
}
}
+ if (nMax >= nMin) {
// Now compact the array
std::ostringstream oss;
PdfArray array;
@@ -283,12 +284,14 @@
void PdfFontCID::CreateCMap( PdfObject* pUnicode ) const
{
+ PdfFontMetricsFreetype* pFreetype = dynamic_cast<PdfFontMetricsFreetype*>(m_pMetrics);
+ if (!pFreetype) return;
+
int nFirstChar = m_pEncoding->GetFirstChar();
int nLastChar = m_pEncoding->GetLastChar();
std::ostringstream oss;
- PdfFontMetricsFreetype* pFreetype = dynamic_cast<PdfFontMetricsFreetype*>(m_pMetrics);
FT_Face face = pFreetype->GetFace();
FT_ULong charcode;
FT_UInt gindex;
Index: src/doc/PdfFontCache.cpp
===================================================================
--- src/doc/PdfFontCache.cpp (révision 1441)
+++ src/doc/PdfFontCache.cpp (copie de travail)
@@ -630,7 +630,7 @@
sPath = reinterpret_cast<const char*>(v.u.s);
#ifdef PODOFO_VERBOSE_DEBUG
PdfError::LogMessage( eLogSeverity_Debug,
- "Got Font %s for for %s\n", sPath.c_str(), pszFontname );
+ "Got Font %s for for %s\n", sPath.c_str(), pszFontName );
#endif // PODOFO_DEBUG
}
Index: src/base/PdfVariant.h
===================================================================
--- src/base/PdfVariant.h (révision 1441)
+++ src/base/PdfVariant.h (copie de travail)
@@ -180,6 +180,7 @@
/** \returns true if this variant is a dictionary (i.e. GetDataType() == ePdfDataType_Dictionary)
*/
inline bool IsDictionary() const { return GetDataType() == ePdfDataType_Dictionary; }
+ inline bool IsDictionary_NoDL() const { return m_eDataType == ePdfDataType_Dictionary; }
/** \returns true if this variant is raw data (i.e. GetDataType() == ePdfDataType_RawData
*/
Index: src/base/PdfArray.h
===================================================================
--- src/base/PdfArray.h (révision 1441)
+++ src/base/PdfArray.h (copie de travail)
@@ -205,6 +205,7 @@
inline void erase( const iterator& pos );
inline void erase( const iterator& first, const iterator& last );
+ inline void resize(size_type __n, PdfObject const & = PdfObject());
inline void reserve(size_type __n);
/**
@@ -445,6 +446,11 @@
// -----------------------------------------------------
//
// -----------------------------------------------------
+void PdfArray::resize(size_type __n, PdfObject const & o)
+{
+ PdfArrayBaseClass::resize( __n, o );
+}
+
void PdfArray::reserve(size_type __n)
{
PdfArrayBaseClass::reserve( __n );
Index: src/base/PdfParserObject.cpp
===================================================================
--- src/base/PdfParserObject.cpp (révision 1441)
+++ src/base/PdfParserObject.cpp (copie de travail)
@@ -201,7 +201,7 @@
if( strncmp( pszToken, "endobj", s_nLenEndObj ) == 0 )
; // nothing to do, just validate that the PDF is correct
// If it's a dictionary, it might have a stream, so check for that
- else if( this->IsDictionary() && strncmp( pszToken, "stream", s_nLenStream ) == 0 )
+ else if( this->IsDictionary_NoDL() && strncmp( pszToken, "stream", s_nLenStream ) == 0 )
{
m_bStream = true;
m_lStreamOffset = m_device.Device()->Tell(); // NOTE: whitespace after "stream" handle in stream parser!
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users