[Podofo-svn] SF.net SVN: podofo: [655] podofo/trunk/src
A PDF parsing, modification and creation library.
Brought to you by:
domseichter
From: <ri...@us...> - 2007-09-23 03:21:28
|
Revision: 655 http://podofo.svn.sourceforge.net/podofo/?rev=655&view=rev Author: ringerc Date: 2007-09-22 20:21:31 -0700 (Sat, 22 Sep 2007) Log Message: ----------- Win32 build fixes for log2/exp2 use and a horrid macro defined in <windows.h> for GetObject. Modified Paths: -------------- podofo/trunk/src/PdfImage.cpp podofo/trunk/src/PdfTTFWriter.cpp Modified: podofo/trunk/src/PdfImage.cpp =================================================================== --- podofo/trunk/src/PdfImage.cpp 2007-09-23 03:00:25 UTC (rev 654) +++ podofo/trunk/src/PdfImage.cpp 2007-09-23 03:21:31 UTC (rev 655) @@ -42,6 +42,12 @@ } #endif // PODOFO_HAVE_JPEG_LIB +// <windows.h> defines an annoying GetObject macro that changes uses of GetObject to +// GetObjectA . Since macros aren't scope and namespace aware that breaks our code. +// Since we won't be using the Win32 resource manager API here, just undefine it. +#if defined(GetObject) +#undef GetObject +#endif using namespace std; Modified: podofo/trunk/src/PdfTTFWriter.cpp =================================================================== --- podofo/trunk/src/PdfTTFWriter.cpp 2007-09-23 03:00:25 UTC (rev 654) +++ podofo/trunk/src/PdfTTFWriter.cpp 2007-09-23 03:21:31 UTC (rev 655) @@ -25,11 +25,23 @@ #include "PdfRefCountedBuffer.h" #include "PdfString.h" -#include <math.h> +#include <cmath> #include <ft2build.h> #include FT_FREETYPE_H +namespace { +// MSVC++ does not provide the c99 exp2(..) and log2(..) in <cmath> since they +// are not required by C++ . Use the gcc ones if we're on gcc. +#if defined(__GNUC__) +inline double PdfLog2(double x) { return log2(x); } +inline double PdfExp2(double x) { return exp2(x); } +#else +inline double PdfLog2(double x) { return log(x)/log(2.0f); } +inline double PdfExp2(double x) { return pow(2,x); } +#endif +} + namespace PoDoFo { extern bool podofo_is_little_endian(); @@ -855,7 +867,6 @@ void PdfTTFWriter::WriteGlyfTable( PdfOutputDevice* pDevice ) { - pdf_ttf_ulong lValue; TIVecGlyphs it = m_vecGlyphs.begin(); int nPosition = 0; @@ -957,7 +968,7 @@ vecRanges.push_back( current ); int i; - pdf_ttf_ushort nSearchRange = 2 * ( exp2( floor( log2( vecRanges.size() ) ) ) ); + pdf_ttf_ushort nSearchRange = 2 * ( PdfExp2( floor( PdfLog2( vecRanges.size() ) ) ) ); // write the actual cmap table nValue = 4; @@ -970,7 +981,7 @@ WRITE_TTF_USHORT( nValue ); // seg count * 2 nValue = nSearchRange; WRITE_TTF_USHORT( nValue ); // search range - nValue = log2( vecRanges.size() >> 1 ); + nValue = PdfLog2( vecRanges.size() >> 1 ); WRITE_TTF_USHORT( nValue ); // entry selector nValue = 2 * vecRanges.size() - nSearchRange; WRITE_TTF_USHORT( nValue ); // range shift This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |