[poppler] [Patch] Add some more information to FontInfo

Kristian Høgsberg krh at bitplanet.net
Fri Jul 22 09:52:09 EST 2005


Hi Martin,

Looks good, please commit.  Actually another feature I was thinking of 
for the font dialog would be showing the substituted font that's 
actually used.  For example, when a document asks for "Times-Roman" 
evince substitutes "Nimbus Roman No9 L" on my system.  That might be 
interesting information if, say, you wanted to use that font in another 
application.  Or maybe it's just because acroread has that feature, and 
I wanted it in evince when testing Alberts fontconfig patch ;-)

Kristian

Martin Kretzschmar wrote:
> Am Samstag, den 18.06.2005, 23:40 +0200 schrieb Martin Kretzschmar:
> 
>>this patch exposes information about the font type in the glib api (and
>>adds it to the FontInfo class). And it strips the subset tags from font
>>names. I used it to implement this in evince:
>>
>>http://www.gnome.org/~martink/2005/stuff/Screenshot-FontDetails.png
>>http://www.gnome.org/~martink/2005/patches/evince-font-details.diff
>>
>>Comments?
> 
> 
> So, lets try again. The xpdf half of the patch is obsolete because a
> similar feature was added for the qt bindings, here's the rest, updated
> to use that. Now it's a glib/ only patch.
> 
> Would be nice to have it in poppler before GNOME 2.12 UI-freeze next
> week.
> 
> Regards,
> 
> Martin
> 
> 
> ------------------------------------------------------------------------
> 
> ? link-it
> cvs diff: Diffing .
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/poppler/poppler/ChangeLog,v
> retrieving revision 1.147
> diff -u -p -r1.147 ChangeLog
> --- ChangeLog	15 Jul 2005 19:55:30 -0000	1.147
> +++ ChangeLog	20 Jul 2005 21:12:58 -0000
> @@ -1,3 +1,14 @@
> +2005-07-20  Martin Kretzschmar  <martink at gnome.org>
> +
> +	* glib/poppler-document.cc (poppler_fonts_iter_get_name): if the
> +	font is a subset, strip the ABCDEF+ tag.
> +	(poppler_fonts_iter_get_full_name): does what the old get_name did.
> +	(poppler_fonts_iter_get_font_type, poppler_fonts_iter_is_embedded)
> +	(poppler_fonts_iter_is_subset): new wrappers.
> +
> +	* glib/poppler-document.h (PopplerFontType): new enum.
> +	Update prototypes.
> +
>  2005-07-15  Martin Kretzschmar  <martink at gnome.org>
>  
>  	* test/gtk-cairo-test.cc: update for 2005-06-27 change to actually
> cvs diff: Diffing fofi
> cvs diff: Diffing glib
> Index: glib/poppler-document.cc
> ===================================================================
> RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v
> retrieving revision 1.23
> diff -u -p -r1.23 poppler-document.cc
> --- glib/poppler-document.cc	7 Jul 2005 11:13:24 -0000	1.23
> +++ glib/poppler-document.cc	20 Jul 2005 21:12:59 -0000
> @@ -791,7 +791,7 @@ poppler_fonts_iter_get_type (void)
>  }
>  
>  const char *
> -poppler_fonts_iter_get_name (PopplerFontsIter *iter)
> +poppler_fonts_iter_get_full_name (PopplerFontsIter *iter)
>  {
>  	GooString *name;
>  	FontInfo *info;
> @@ -806,6 +806,58 @@ poppler_fonts_iter_get_name (PopplerFont
>  	}
>  }
>  
> +const char *
> +poppler_fonts_iter_get_name (PopplerFontsIter *iter)
> +{
> +	FontInfo *info;
> +	const char *name;
> +
> +	name = poppler_fonts_iter_get_full_name (iter);
> +	info = (FontInfo *)iter->items->get (iter->index);
> +
> +	if (info->getSubset() && name) {
> +		while (*name && *name != '+')
> +			name++;
> +
> +		if (*name)
> +			name++;
> +	}
> +
> +	return name;
> +}
> +
> +PopplerFontType
> +poppler_fonts_iter_get_font_type (PopplerFontsIter *iter)
> +{
> +	FontInfo *info;
> +
> +	g_return_val_if_fail (iter != NULL, POPPLER_FONT_TYPE_UNKNOWN);
> +
> +	info = (FontInfo *)iter->items->get (iter->index);
> +
> +	return (PopplerFontType)info->getType ();
> +}
> +
> +gboolean
> +poppler_fonts_iter_is_embedded (PopplerFontsIter *iter)
> +{
> +	FontInfo *info;
> +
> +	info = (FontInfo *)iter->items->get (iter->index);
> +
> +	return info->getEmbedded();
> +}
> +
> +gboolean
> +poppler_fonts_iter_is_subset (PopplerFontsIter *iter)
> +{
> +	FontInfo *info;
> +
> +	info = (FontInfo *)iter->items->get (iter->index);
> +
> +	return info->getSubset();
> +}
> +
>  gboolean
>  poppler_fonts_iter_next (PopplerFontsIter *iter)
>  {
> Index: glib/poppler-document.h
> ===================================================================
> RCS file: /cvs/poppler/poppler/glib/poppler-document.h,v
> retrieving revision 1.13
> diff -u -p -r1.13 poppler-document.h
> --- glib/poppler-document.h	15 Jun 2005 15:02:46 -0000	1.13
> +++ glib/poppler-document.h	20 Jul 2005 21:12:59 -0000
> @@ -52,6 +52,18 @@ typedef enum
>    POPPLER_PAGE_MODE_USE_ATTACHMENTS,
>  } PopplerPageMode;
>  
> +typedef enum
> +{
> +  POPPLER_FONT_TYPE_UNKNOWN,
> +  POPPLER_FONT_TYPE_TYPE1,
> +  POPPLER_FONT_TYPE_TYPE1C,
> +  POPPLER_FONT_TYPE_TYPE3,
> +  POPPLER_FONT_TYPE_TRUETYPE,
> +  POPPLER_FONT_TYPE_CID_TYPE0,
> +  POPPLER_FONT_TYPE_CID_TYPE0C,
> +  POPPLER_FONT_TYPE_CID_TYPE2
> +} PopplerFontType;
> +
>  typedef enum /*< flags >*/
>  {
>    POPPLER_VIEWER_PREFERENCES_UNSET = 0,
> @@ -105,17 +117,21 @@ PopplerAction    *poppler_index_iter_get
>  gboolean          poppler_index_iter_next       (PopplerIndexIter  *iter);
>  
>  /* Interface for getting the Fonts of a poppler_document */
> -PopplerFontInfo  *poppler_font_info_new         (PopplerDocument   *document);
> -gboolean          poppler_font_info_scan        (PopplerFontInfo   *font_info,
> -						 int                n_pages,
> -						 PopplerFontsIter **iter);
> -void		  poppler_font_info_free	(PopplerFontInfo   *font_info);
> -
> -GType             poppler_fonts_iter_get_type   (void) G_GNUC_CONST;
> -PopplerFontsIter *poppler_fonts_iter_copy       (PopplerFontsIter  *iter);
> -void              poppler_fonts_iter_free       (PopplerFontsIter  *iter);
> -const char       *poppler_fonts_iter_get_name   (PopplerFontsIter  *iter);
> -gboolean          poppler_fonts_iter_next       (PopplerFontsIter  *iter);
> +PopplerFontInfo  *poppler_font_info_new            (PopplerDocument   *document);
> +gboolean          poppler_font_info_scan           (PopplerFontInfo   *font_info,
> +						    int                n_pages,
> +						    PopplerFontsIter **iter);
> +void		  poppler_font_info_free	   (PopplerFontInfo   *font_info);
> +
> +GType             poppler_fonts_iter_get_type      (void) G_GNUC_CONST;
> +PopplerFontsIter *poppler_fonts_iter_copy          (PopplerFontsIter  *iter);
> +void              poppler_fonts_iter_free          (PopplerFontsIter  *iter);
> +const char       *poppler_fonts_iter_get_name      (PopplerFontsIter  *iter);
> +const char       *poppler_fonts_iter_get_full_name (PopplerFontsIter  *iter);
> +PopplerFontType   poppler_fonts_iter_get_font_type (PopplerFontsIter  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler



More information about the poppler mailing list