> There is some code in FLTK e.g. in the browser widget, that uses
> the method of OR'ing the constants FL_BOLD, FL_ITALIC,.. to the
> current Fl_Font (which is just an index into the font table) to
> get the font index of the bold, italic,.. font of the current font
> family.
> 
> In Enumerations.H the comment says that this constants can be
> added to the FLTK internal fonts HELVETICA and COURIER.
> 
> Thats certainly due to the fact, that only for *these fonts* it
> can be guarranted that their position in the font table starts at
> a multiple of 4.

Yes - OR'ing in the modifiers is fine with the "built-in" fonts. I wouldn't 
recommend it with the "extended" fonts though, for the reasons you identify 
below...!


> On the other hand there seems to be some effort in the font routines
> to sort the fonts to the specific order normal-bold-italic-bold/italic.
> So I assume it was meant to make the logic of OR'ing in the style
> attribute also available for other fonts.

That was (maybe) the original intent, but as the available fonts become more 
complex, and we added Unicode support, a lot of the things that make sense for 
a Latin font, don't really apply so well any more.


> Anyway the sorting in the Xft file fl_set_fonts_xft.cxx is currently
> broken if it was meant to achieve this sorting order. This is mainly
> because most fonts nowadays have style descriptions in multiple languages
> and there seems to be no defined order of the language
> terms within the style string.

Yup - it was never meant to support that sorting.
To be honest, I wrote most of that code and it was really only meant to fill a 
need (we were missing the ability to load the XT fonts.) The idea was always to 
try and get to something better; but it has never been really clear what that 
better thing would be...
And it very quickly becomes messy, depending on what fonts a given platform 
has, since what you actually find inside each font can be quite... variable... 
hmm...


> On my machine it now sorts in the order bold/italic-bold-normal-italic.
> It can be seen for example with the 'fonts' program in the test folder.
> 
> My questions are:
> 
> 1. Was there really the intention to have this sorting order
>    so that the OR'ing method could be used for other fonts than the
>    FLTK internal ones too?

Not really; it was a good idea once upon a time, and a nice aspiration, but not 
always practical in the current situation.

> 2. Would it be of benefit if sorting in Xft would work as planned?
>    (I would have a patch for it already).

Patches are always welcome; that's what the STR pages are for - though I've no 
idea whether it'd be implemented, at least having it logged must be a good 
thing.

> 3. Should there not be a more reliable method to find the bold/italic,..
>    fonts, or is there already one?

I think there possibly is: I don't have a XFT box to hand right now, but I 
think the way the XFT (and WIN32) hosts store the fonts internally, you can 
tell from the "FLTK name" what the font style is...

Try this; run the utf8 test demo, in a shell, pick a font name and click the 
"Select" button.

In the shell, you get something like this (this form a WinXP host, but the 
behaviour is similar I think!)

$ ./utf8.exe 
idx 19
User name :Fixedsys bold:
FLTK name :BFixedsys:
size 9

idx 106
User name :Lucida Console:
FLTK name : Lucida Console:
size 9

idx 108
User name :Lucida Console italic:
FLTK name :ILucida Console:
size 9

idx 109
User name :Lucida Console bold italic:
FLTK name :PLucida Console:
size 9


So... that's four font selections, and for each we see:

- the index number the font was enumerated with (this is not relaible and may 
change from time to time.)

- The "User name" - basically the name extracted from the font

- The "FLTK name" - a name that fltk makes up to hold the font internally; the 
interesting thing here is the first character of the name:

-- regular font names all begin with " "
-- bold font names begin with "B"
-- italic font names begin with "I"
-- bold italic font names begin with "P"

(There are no other supported states)

- size, which is, um, the size...


So, anyway, from the FLTK name you can tell some stuff about the font style - 
and you can use the FLTK name to load that face in that style too, so if you 
know you want "Lucida Console bold italic" you can ask for "PLucida Console" in 
your call to Fl::set_font(...) and there's a fair chance it will do the Right 
Thing. Well, maybe...




SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to