DiaFont abstraction and namespacing



Hi Cyrille,
while trying to compile the wmf and Python plug-in again I've stumbled
over some 'possibly offending' comments in lib/font.h

It has to do with Style, which IMO should be called DiaFontStyle if
it should stay like it is. I'm not sure if the Pango concept
of splitting (Pango)Weight and (Pango)Style wouldn't work
better in Dia, too.

What I propose is:

/* storing different style info like 
 * (DIA_FONT_SANS | DIA_FONT_ITALIC | DIA_FONT_BOLD)
 */
typedef guint DiaFontStyle;

typedef enum
{
  DIA_FONT_FAMILY_ANY = 0
  DIA_FONT_SANS       = 1,
  DIA_FONT_SERIF      = 2,
  DIA_FONT_MONOSPACE  = 3
} DiaFontFamily;

typedef enum
{
  DIA_FONT_NORMAL  = (0<<2),
  DIA_FONT_OBLIQUE = (1<<2),
  DIA_FONT_ITALIC  = (2<<2)
} DiaFontObliquity; /* Don't call this Style, better names ? */

typedef enum
{
  DIA_FONT_ULTRALIGHT    = (1<<4),
  DIA_FONT_LIGHT         = (2<<4),
  DIA_FONT_WEIGHT_NORMAL = (0<<4), /* intentionaly ==0 */
  DIA_FONT_MEDIUM        = (3<<4),
  DIA_FONT_DEMIBOLD      = (4<<4),
  DIA_FONT_BOLD          = (5<<4),
  DIA_FONT_ULTRABOLD     = (6<<4),
  DIA_FONT_HEAVY         = (7<<4)
} DiaFontWeight;

/* macros to get a specific style info */
#define DIA_FONT_STYLE_GET_FAMILY(st)    ((st) & (0x3))
#define DIA_FONT_STYLE_GET_OBLIQUITY(st) ((st) & (0x3<<2))
#define DIA_FONT_STYLE_GET_WEIGHT(st)    ((st) & (0x7<<4))

This would allow to store all this information in one guint,
get it with one function call and be able to separate the
required info for the respective plug-in. And all this
without including any Pango header.

A fuure goal - when the question: who needs to know layouts ? 
is sorted out - is to _not_ include <pango/pango.h> in font.h
anymore.

What do you think ?

        Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]