[poppler] poppler/poppler: GfxFont.cc, 1.1.1.1, 1.2 GfxFont.h, 1.1.1.1, 1.2

Albert Astals Cid aacid at freedesktop.org
Wed Jul 6 10:12:39 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv717/poppler

Modified Files:
	GfxFont.cc GfxFont.h 
Log Message:
Extract family, stretch and weight from the font descriptor


Index: GfxFont.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- GfxFont.cc	3 Mar 2005 19:46:02 -0000	1.1.1.1
+++ GfxFont.cc	6 Jul 2005 17:12:36 -0000	1.2
@@ -144,10 +144,14 @@
   origName = nameA;
   embFontName = NULL;
   extFontFile = NULL;
+  family = NULL;
+  stretch = StretchNotDefined;
+  weight = WeightNotDefined;
 }
 
 GfxFont::~GfxFont() {
   delete tag;
+  delete family;
   if (origName && origName != name) {
     delete origName;
   }
@@ -189,6 +193,43 @@
     }
     obj2.free();
 
+    // get family
+    obj1.dictLookup("FontFamily", &obj2);
+    if (obj2.isString()) family = new GooString(obj2.getString());
+    obj2.free();
+
+    // get stretch
+    obj1.dictLookup("FontStretch", &obj2);
+    if (obj2.isName()) {
+      if (strcmp(obj2.getName(), "UltraCondensed") == 0) stretch = UltraCondensed;
+      else if (strcmp(obj2.getName(), "ExtraCondensed") == 0) stretch = ExtraCondensed;
+      else if (strcmp(obj2.getName(), "Condensed") == 0) stretch = Condensed;
+      else if (strcmp(obj2.getName(), "SemiCondensed") == 0) stretch = SemiCondensed;
+      else if (strcmp(obj2.getName(), "Normal") == 0) stretch = Normal;
+      else if (strcmp(obj2.getName(), "SemiExpanded") == 0) stretch = SemiExpanded;
+      else if (strcmp(obj2.getName(), "Expanded") == 0) stretch = Expanded;
+      else if (strcmp(obj2.getName(), "ExtraExpanded") == 0) stretch = ExtraExpanded;
+      else if (strcmp(obj2.getName(), "UltraExpanded") == 0) stretch = UltraExpanded;
+      else error(-1, "Invalid Font Stretch");
+    }
+    obj2.free();
+    
+    // get weight
+    obj1.dictLookup("FontWeight", &obj2);
+    if (obj2.isNum()) {
+      if (obj2.getNum() == 100) weight = W100;
+      else if (obj2.getNum() == 200) weight = W200;
+      else if (obj2.getNum() == 300) weight = W300;
+      else if (obj2.getNum() == 400) weight = W400;
+      else if (obj2.getNum() == 500) weight = W500;
+      else if (obj2.getNum() == 600) weight = W600;
+      else if (obj2.getNum() == 700) weight = W700;
+      else if (obj2.getNum() == 800) weight = W800;
+      else if (obj2.getNum() == 900) weight = W900;
+      else error(-1, "Invalid Font Weight");
+    }
+    obj2.free();
+
     // look for embedded font file
     if (obj1.dictLookupNF("FontFile", &obj2)->isRef()) {
       if (type == fontType1) {

Index: GfxFont.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxFont.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- GfxFont.h	3 Mar 2005 19:46:00 -0000	1.1.1.1
+++ GfxFont.h	6 Jul 2005 17:12:36 -0000	1.2
@@ -82,6 +82,30 @@
 class GfxFont {
 public:
 
+  enum Stretch { 
+	StretchNotDefined, 
+	UltraCondensed, 
+	ExtraCondensed, 
+	Condensed, 
+	SemiCondensed, 
+	Normal, 
+	SemiExpanded, 
+	Expanded, 
+	ExtraExpanded, 
+	UltraExpanded };
+
+  enum Weight { 
+	WeightNotDefined, 
+	W100, 
+	W200, 
+	W300, 
+	W400, // Normal
+	W500, 
+	W600, 
+	W700, // Bold
+	W800, 
+	W900 };
+
   // Build a GfxFont object.
   static GfxFont *makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict);
 
@@ -102,6 +126,15 @@
 
   // Get base font name.
   GooString *getName() { return name; }
+  
+  // Get font family name.
+  GooString *getFamily() { return family; }
+  
+  // Get font stretch.
+  Stretch getStretch() { return stretch; }
+  
+  // Get font weight.
+  Weight getWeight() { return weight; }
 
   // Get the original font name (ignornig any munging that might have
   // been done to map to a canonical Base-14 font name).
@@ -168,6 +201,9 @@
   GooString *tag;			// PDF font tag
   Ref id;			// reference (used as unique ID)
   GooString *name;		// font name
+  GooString *family;		// font family
+  Stretch stretch;			// font stretch
+  Weight weight;			// font weight
   GooString *origName;		// original font name
   GfxFontType type;		// type of font
   int flags;			// font descriptor flags



More information about the poppler mailing list