Re: DiaFont abstraction and namespacing



At 14:36 23.06.02 +0200, Cyrille Chepelov wrote:
Le Sun, Jun 23, 2002, à 02:16:27PM +0200, Hans Breuer a écrit:

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

Which comments ? 

"The Pango people don't seem to encounter the real world much..."

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.

Well, it was feared on Saturday that exposing all this complexity to the
user might be too much. I'm don't have any strong opinions on this, frankly.

Whatever works best is good, I guess (also, the ability to derive another
face in the same family out of a DiaFont may be very useful to things like
the UML Class object -- specify the class font, and have the abstract class
version of it automatically).

Have you looked at Lars' new font selector widget, and its ability to
enumerate (and show) all the available faces for a family ?

Impressive, if it wouldn't pop up about 8 message boxes with:
        Trying to set invalid font arial, helvetica, helv, sans!
        Trying to set invalid font courier new, courier, monospace, fixed!
on UML
classes; which isn't Lars' fault but some strangeness with BASIC_SANS_FONT,
BASIC_MONOSPACE_FONT etc.

What I propose is:

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

Yuck! 

Means dia is now hardcoded to only three families ? 
Nope. But these constants could be used for some simplifiction like

        dia_font_new_from_style(DIA_FONT_SANS | DIA_FONT_BOLD, 0.42) 

which I hope could replace the BASIC_SANS_FONT, ... above. It appears
to me that at least the win32 Pango backend isn't capable of
loading such.
With my approach there would only be one central place in font.c
where the assignment between "BASIC_*" and a real font name needs
to happen. I'm not sure if even there it is required than. Pango
should be able to give me a font from style only - without
naming it. As font info to store one would have the font name
_and_ the style as fallback.

One could even think of a specific default font matching
widget, which would the user allow to choose if she wants to use
Helvetica, Arial, Impact, or another available font as default
Sans font.

What I like to get though is a - per default - shorter list
of fonts to select from. In the spirit of useability and
the ability to exchange diagrams between platforms with
differnt font sets. 
I am thinking of a GtkFifoOptionMenu with a details entry to 
select additional fonts from the standard Gtk font selector, 
to have the choice of using any font available on the system. 

(there are so many
available families on my system I have to scroll through three screenfuls of
the font widget -- with 1024 dots of vertical resolution).

Is this the new kind of useability, menus about 3072 pixels long :-) ?

Please keep the family a gchar* out of this guint... Merging pango::weight
and pango::style together seems good, and your way seems more powerful than
the gross approximation I made.

It wasn't meant as a restriction but as a simplification. The WPG, WMF,
and Python plug-ins shouldn't need to care about real font names,
if they are only interested in the font style. Obviously your
dia_font_new(family_name, ...) needs to stay. 

Some constants for the general (regular, bold, italic, bold-italic) styles
may be a useful thing to keep.

Something like ?
#define DIA_FONT_STYLE_SANS_NORMAL (DIA_FONT_SANS | DIA_FONT_WEIGHT_NORMAL)
I'm not sure if it's worth the effort, but will do it when replacing
BASIC_*_FONT otherwise would be too much hassle.
 
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 future goal - when the question: who needs to know layouts ? 
is sorted out - is to _not_ include <pango/pango.h> in font.h
anymore.

Sounds very good. The ideal is to have the objects independent of any of
{gdk, gtk, pango}.

That's what I thought ;-)

BTW: here are some of the warnings Dia (or better Pango) spits out
if I play with uml-demo.dia (Is this your magic font scaler? :) :

** (dia.exe:4294445299): WARNING **: Couldn't load font "courier new,
courier, monospace, fixed Ultra-Light Semi-Condensed 16.8037109375" falling
back to "SansUltra-Light Semi-Condensed 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Sans Ultra-Light
Semi-Condensed 16.8037109375" falling back to "Sans 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "courier new,
courier, monospace, fixed Ultra-Light Semi-Condensed 16.8037109375" falling
back to "SansUltra-Light Semi-Condensed 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Sans Ultra-Light
Semi-Condensed 16.8037109375" falling back to "Sans 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "courier new,
courier, monospace, fixed Ultra-Light Semi-Condensed 16.8037109375" falling
back to "SansUltra-Light Semi-Condensed 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Sans Ultra-Light
Semi-Condensed 16.8037109375" falling back to "Sans 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "courier new,
courier, monospace, fixed Ultra-Light Semi-Condensed 16.8037109375" falling
back to "SansUltra-Light Semi-Condensed 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Sans Ultra-Light
Semi-Condensed 16.8037109375" falling back to "Sans 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Monospace
Ultra-Light Semi-Condensed 16.8037109375" falling back to "Sans Ultra-Light
Semi-Condensed 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Sans Ultra-Light
Semi-Condensed 16.8037109375" falling back to "Sans 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Monospace
Ultra-Light Semi-Condensed 16.8037109375" falling back to "Sans Ultra-Light
Semi-Condensed 16.8037109375"
** (dia.exe:4294445299): WARNING **: Couldn't load font "Sans Ultra-Light
Semi-Condensed 16.8037109375" falling back to "Sans 16.8037109375"
** (dia.exe:4294511719): WARNING **: Couldn't load font "Helvetica
Ultra-Light 8" falling back to "Sans Ultra-Light 8"
 
        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]