Hello all,
this is for replacing the patch attached to the e-mail this replies to,
I had missed (empty) implementations for private constructors and some
typos, I've also inserted a forward declaration of PdfFontMetricsBase14
to be able to do without the dynamic_cast addition (now removed).
Otherwise the same applies, build log (not attached because it's > 400
KiB large) and binary package (nearly 500 KiB) available upon request.
Best regards, mabri
> Matthew Brincke has written on 3 January 2018 at 17:34:
>
>
> Hello all,
>
> the internal function name PODOFO_Base14FontDef_FindBuiltinData looks
> like it should be in a namespace and a class IMHO, therefore I've
> converted it to a private method with access only from PdfFontFactory.
> I've also implemented a wrapper method IsBase14Font() to give the
> class PdfFontCache access on a need-to-know basis (that is, a boolean
> return value instead of a pointer to, possibly even writable, metrics).
> Should someone desire access to any of this info outside PoDoFo, some
> workaround is possible: e.g. create the font, query its metrics and
> check if they can be converted (dynamic_cast) to PdfFontMetricsBase14.
>
> The only not backward-compatible change (by Debian Policy 4.1.2 clause
> 8.6.2 Shared library ABI changes) is IIUC the removal of the function
> named above, which really is internal, right?
> I build-tested the change with Debian sbuild into a Debian sid chroot.
> No new warnings were produced (build log available on request, not
> attached because it's > 100KiB large).
> So please (@committers) accept this change, which is attached as a
> diff -up format patch to this e-mail (applies the same to 0.9.5 and the
> trunk) before the next (candidate) release.
>
> Best regards,
> mabri------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org!
> http://sdm.link/slashdot_______________________________________________
> Podofo-users mailing list
> Podofo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/podofo-users
Description: Change PODOFO_Base14FontDef_FindBuiltinData function to method
PdfFontFactory::Builtin::FindMetrics(const char*) (with the nested class
having a friend declaration for the enclosing class).
Implement private method IsBase14Font() as wrapper for it,
to provide as-needed access for the PdfFontCache (friend) class.
Change friend declaration in PdfFontMetricsBase14 to the class
PdfFontFactory::Builtin to solve "must be public" problem
Author: Matthew Brincke <ma...@mailbox.org>
Last-Updated: 2018-01-04
---
--- libpodofo-0.9.5.orig/src/doc/PdfFontCache.cpp
+++ libpodofo-0.9.5/src/doc/PdfFontCache.cpp
@@ -396,7 +396,7 @@ PdfFont* PdfFontCache::GetFont( const ch
if( it.first == it.second )
{
if ( (eFontCreationFlags & eFontCreationFlags_AutoSelectBase14)
- && PODOFO_Base14FontDef_FindBuiltinData(pszFontName) )
+ && PdfFontFactory::FontTypes::IsBase14Font(pszFontName) )
{
EPdfFontFlags eFlags = ePdfFont_Normal;
if( bBold )
--- libpodofo-0.9.5.orig/src/doc/PdfFontFactory.cpp
+++ libpodofo-0.9.5/src/doc/PdfFontFactory.cpp
@@ -241,7 +241,8 @@ PdfFont* PdfFontFactory::CreateFont( FT_
PdfObject* pBaseFont = NULL;
pBaseFont = pObject->GetIndirectKey( "BaseFont" );
const char* pszBaseFontName = pBaseFont->GetName().GetName().c_str();
- PdfFontMetricsBase14* pMetrics = PODOFO_Base14FontDef_FindBuiltinData(pszBaseFontName);
+ PdfFontMetricsBase14* pMetrics
+ = Builtin::FindMetrics(pszBaseFontName);
if ( pMetrics != NULL )
{
// pEncoding may be undefined, found a valid pdf with
@@ -348,9 +349,13 @@ EPdfFontType PdfFontFactory::GetFontType
return eFontType;
}
+bool PdfFontFactory::FontTypes::IsBase14Font(const char * pszFontName)
+{
+ return Builtin::FindMetrics(pszFontName);
+}
PdfFontMetricsBase14*
-PODOFO_Base14FontDef_FindBuiltinData(const char *font_name)
+PdfFontFactory::Builtin::FindMetrics(const char *font_name)
{
unsigned int i = 0;
bool found = false;
@@ -371,8 +376,8 @@ PdfFont *PdfFontFactory::CreateBase14Fon
EPdfFontFlags eFlags, const PdfEncoding * const pEncoding,
PdfVecObjects *pParent)
{
- PdfFont *pFont = new PdfFontType1Base14(
- PODOFO_Base14FontDef_FindBuiltinData(pszFontName), pEncoding, pParent);
+ PdfFont *pFont = new PdfFontType1Base14( Builtin::FindMetrics(pszFontName),
+ pEncoding, pParent );
if (pFont) {
pFont->SetBold( eFlags & ePdfFont_Bold ? true : false );
pFont->SetItalic( eFlags & ePdfFont_Italic ? true : false );
--- libpodofo-0.9.5.orig/src/doc/PdfFontFactory.h
+++ libpodofo-0.9.5/src/doc/PdfFontFactory.h
@@ -40,6 +40,7 @@
namespace PoDoFo {
class PdfFontMetrics;
+class PdfFontMetricsBase14;
class PdfVecObjects;
enum EPdfFontFlags {
@@ -104,6 +105,25 @@ class PODOFO_DOC_API PdfFontFactory {
*/
static EPdfFontType GetFontType( const char* pszFilename );
+ /** Nested class to restrict access for the font cache to the necessary.
+ */
+ class FontTypes {
+ private:
+ friend class PdfFontCache;
+ static bool IsBase14Font(const char * pszFontName);
+ FontTypes() {}; // prohibit instantiation
+ };
+
+ /** Nested class to restrict access to PdfFontMetricsBase14's private
+ * members to the former's method.
+ */
+ class Builtin {
+ private:
+ friend class PdfFontFactory;
+ static PdfFontMetricsBase14* FindMetrics(const char *font_name);
+ Builtin() {}; // prohibit instantiation
+ };
+
private:
// prohibit instantiation of all-methods-static factory from outside
PdfFontFactory();
--- libpodofo-0.9.5.orig/src/doc/PdfFontMetricsBase14.h
+++ libpodofo-0.9.5/src/doc/PdfFontMetricsBase14.h
@@ -39,6 +39,7 @@
#include "podofo/base/PdfVariant.h"
#include "PdfFontMetrics.h"
+#include "PdfFontFactory.h"
#include <string.h>
@@ -81,8 +82,7 @@ public:
~PdfFontMetricsBase14();
- friend PdfFontMetricsBase14*
- PODOFO_Base14FontDef_FindBuiltinData (const char *font_name);
+ friend class PdfFontFactory::Builtin;
/** Create a width array for this font which is a required part
* of every font dictionary.
@@ -277,10 +277,6 @@ private :
};
-
-PdfFontMetricsBase14*
-PODOFO_Base14FontDef_FindBuiltinData (const char *font_name);
-
// -----------------------------------------------------
//
// -----------------------------------------------------
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users