[poppler] change FontInfo::type() to enumerated value

Brad Hards bradh at frogmouth.net
Fri Jul 1 21:18:03 PDT 2005


In working through the Qt4 bindings for FontInfo, I've found that having the 
font type returned as a GooString isn't all that nice. It would be much nicer 
to have an enumerated type (which it is in GfxFontInfo). So my proposal is to 
make FontInfo::type() return an enumerated value, and to add 
FontInfo::typeName() which return a GooString, in case anyone wants it.

Any concerns with this patch?

Brad

Index: FontInfo.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/FontInfo.h,v
retrieving revision 1.2
diff -u -4 -p -r1.2 FontInfo.h
--- FontInfo.h  28 Jun 2005 22:49:15 -0000      1.2
+++ FontInfo.h  2 Jul 2005 04:12:28 -0000
@@ -5,25 +5,37 @@
 #include "goo/GooList.h"

 class FontInfo {
 public:
-
+  enum Type {
+    unknown,
+    Type1,
+    Type1C,
+    Type3,
+    TrueType,
+    CIDType0,
+    CIDType0C,
+    CIDTrueType
+  };
+
   // Constructor.
   FontInfo(GfxFont *fontA, PDFDoc *doc);
   // Copy constructor
   FontInfo(FontInfo& f);
   // Destructor.
   ~FontInfo();

   GooString *getName()      { return name; };
-  GooString *getType()      { return type; };
+  Type       getType()      { return type; };
+  GooString  getTypeName()  { return typeName; };
   GBool      getEmbedded()  { return emb; };
   GBool      getSubset()    { return subset; };
   GBool      getToUnicode() { return hasToUnicode; };

 private:
   GooString *name;
-  GooString *type;
+  Type type;
+  GooString *typeName;
   GBool emb;
   GBool subset;
   GBool hasToUnicode;
   Ref fontRef;
Index: FontInfo.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/FontInfo.cc,v
retrieving revision 1.4
diff -u -4 -p -r1.4 FontInfo.cc
--- FontInfo.cc 28 Jun 2005 22:51:29 -0000      1.4
+++ FontInfo.cc 2 Jul 2005 04:12:28 -0000
@@ -163,9 +163,10 @@ FontInfo::FontInfo(GfxFont *font, PDFDoc
     name = NULL;
   }

   // font type
-  type = new GooString(fontTypeNames[font->getType()]);
+  type = (FontInfo::Type)font->getType();
+  typeName = new GooString(fontTypeNames[type]);

   // check for an embedded font
   if (font->getType() == fontType3) {
     emb = gTrue;
@@ -195,15 +196,16 @@ FontInfo::FontInfo(GfxFont *font, PDFDoc
 }

 FontInfo::FontInfo(FontInfo& f) {
   name = f.name->copy();
-  type = f.type->copy();
+  type = f.type;
+  typeName = f.typeName->copy();
   emb = f.emb;
   subset = f.subset;
   hasToUnicode = f.hasToUnicode;
   fontRef = f.fontRef;
 }

 FontInfo::~FontInfo() {
   delete name;
-  delete type;
+  delete typeName;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/poppler/attachments/20050702/d6f66082/attachment.pgp


More information about the poppler mailing list