Hi all,
I'm so sorry to have had forgot build-testing my original
patch, it didn't build for me (with gcc4.9 on 32-bit Linux)
either, so it isn't particularly likely yours is any stricter.
I've attached a fixed patch which builds cleanly (no build log
changes, except, for some reason, "Scanning dependencies ..."
lines, I did run make clean after a practically-clean build).
Please review/accept the fixed patch because:
a) we both want type safety and this patch achieves to better it,
b) no bitwise-or of flags is required, because only the Bold,
Italic and BoldItalic flags apply for Base14 fonts and they're
mutually exclusive (if you think you need one, please use the
BoldItalic flag, since that's the only one where it would apply)
c) the PdfFontFactory::CreateBase14Font()method isn't documented
yet, so no change to the public documented API happens with this.
So if you are persuaded (I hope so), please apply the fixed patch
and commit it (separately) to the public repository, otherwise please
tell me why not.
Best regards, mabri
----- Original Message -----
From: zyx <z...@litepdf.cz>
To: podofo-users@lists.sourceforge.net
CC:
Sent: 19:28 Friday, 2 October 2015
Subject: Re: [Podofo-users] Method signature clarification for
PdfFontFactory::CreateBase14Font()
On Thu, 2015-10-01 at 21:50 +0000, Matthew Brincke wrote:
> -PdfFont *PdfFontFactory::CreateBase14Font(const char* pszFontName, int
> nFlags, const PdfEncoding * const pEncoding, PdfVecObjects *pvecObjects)
> +PdfFont *PdfFontFactory::CreateBase14Font(const char* pszFontName,
> + EPdfFontFlags eFlags, const PdfEncoding * const
> pEncoding,
> + PdfVecObjects *pParent)
Hi,
I would not change that type of nFlags, it's not a good idea:
a) I get build break due to not changed prototype in the header file
b) even if I fix it, I get a build break due to no cast from int to
the enum, for example called from PoDoFo::PdfFontCache::GetFont()
I can have set my gcc too strict, but I do not think it's that much
strict. After all, you do not pass one value of the enum, but a bit-or
of them, which the 'int' works for pretty well (or 'unsigned int' can,
in some cases with many enum values).
Bye,
zyx
--
http://www.litePDF.cz i...@litepdf.cz
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users
Index: src/doc/PdfFontCache.cpp
===================================================================
--- src/doc/PdfFontCache.cpp (revision 1683)
+++ src/doc/PdfFontCache.cpp (working copy)
@@ -491,19 +491,25 @@
if( it.first == it.second )
{
- if ( (eFontCreationFlags & eFontCreationFlags_AutoSelectBase14)
- && PODOFO_Base14FontDef_FindBuiltinData(pszFontName))
- {
- int nFlags = ePdfFont_Normal;
+ if ( (eFontCreationFlags & eFontCreationFlags_AutoSelectBase14)
+ && PODOFO_Base14FontDef_FindBuiltinData(pszFontName) )
+ {
+ EPdfFontFlags eFlags = ePdfFont_Normal;
+ if( bBold )
+ {
+ if( bItalic )
+ {
+ eFlags = ePdfFont_BoldItalic;
+ }
+ else
+ {
+ eFlags = ePdfFont_Bold;
+ }
+ } else if( bItalic )
+ eFlags = ePdfFont_Italic;
- if( bBold )
- nFlags |= ePdfFont_Bold;
-
- if( bItalic )
- nFlags |= ePdfFont_Italic;
-
- pFont = PdfFontFactory::CreateBase14Font(pszFontName, nFlags, pEncoding, m_pParent);
-
+ pFont = PdfFontFactory::CreateBase14Font(pszFontName, eFlags,
+ pEncoding, m_pParent);
if( pFont )
{
TFontCacheElement element;
Index: src/doc/PdfFontFactory.cpp
===================================================================
--- src/doc/PdfFontFactory.cpp (revision 1683)
+++ src/doc/PdfFontFactory.cpp (working copy)
@@ -354,14 +354,17 @@
return found ? &PODOFO_BUILTIN_FONTS[i] : NULL;
}
-PdfFont *PdfFontFactory::CreateBase14Font(const char* pszFontName, int nFlags, const PdfEncoding * const pEncoding, PdfVecObjects *pvecObjects)
+PdfFont *PdfFontFactory::CreateBase14Font(const char* pszFontName,
+ EPdfFontFlags eFlags, const PdfEncoding * const pEncoding,
+ PdfVecObjects *pParent)
{
- PdfFont *pFont = new PdfFontType1Base14(PODOFO_Base14FontDef_FindBuiltinData(pszFontName), pEncoding, pvecObjects);
- if (pFont) {
- pFont->SetBold( nFlags & ePdfFont_Bold ? true : false );
- pFont->SetItalic( nFlags & ePdfFont_Italic ? true : false );
- }
- return pFont;
+ PdfFont *pFont = new PdfFontType1Base14(
+ PODOFO_Base14FontDef_FindBuiltinData(pszFontName), pEncoding, pParent);
+ if (pFont) {
+ pFont->SetBold( eFlags & ePdfFont_Bold ? true : false );
+ pFont->SetItalic( eFlags & ePdfFont_Italic ? true : false );
+ }
+ return pFont;
}
};
Index: src/doc/PdfFontFactory.h
===================================================================
--- src/doc/PdfFontFactory.h (revision 1683)
+++ src/doc/PdfFontFactory.h (working copy)
@@ -82,7 +82,10 @@
*/
static PdfFont* CreateFont( FT_Library* pLibrary, PdfObject* pObject );
- static PdfFont* CreateBase14Font(const char* pszFontName, int nFlags, const PdfEncoding * const pEncoding,PdfVecObjects *pvecObjects);
+ static PdfFont* CreateBase14Font( const char* pszFontName,
+ EPdfFontFlags eFlags,
+ const PdfEncoding * const pEncoding,
+ PdfVecObjects *pParent );
/** Try to guess the fonttype from a the filename of a font file.
*
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users