Re: XForms: Trouble with fonts and format characters

Steve Lamont (spl@szechuan.ucsd.edu)
Thu, 17 Dec 98 17:22:39 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I set the browser font by doing the following:
>
> if(fl_set_font_name(30, "-*-arial-*-*-*-*-*-?-*-*-*-*-*-*")<0)
> exit(1);
> fl_set_browser_fontstyle(mybrowser, 30);
>
> The browser displays text correctly until one attempts to display a text
> in bold or italic style:
> "@bhello" ==>In SetFont [fonts.c 224] Bad FontStyle request 32:
> "@ihello" ==>In SetFont [fonts.c 224] Bad FontStyle request 31:
>
> Where are 31 and 32 from?
> Let's set font style 31 to "-*-times new roman-*-*-*-*-*-?-*-*-*-*-*-*"
> and see what happens:
> The warning with request 31 disappears but "@ihello" is now displayed
> using times new roman.
>
> The user specifies the browser font in an X resource file. When they
> later use "@b", I suppose that they expect to have a line displayed
> using their font and in bold...

The reason for this is that fl_set_browser_fontstyle() sets the base
font style for the browser contents. Any modifiers are calculated
relative to that font style and looked up in an internal font table.
Since you declared the font 30, the browser will look for font numbers
30, 31, 32, and 33, corresponding to FL_NORMAL_STYLE, FL_BOLD_STYLE,
FL_ITALIC_STYLE, and FL_BOLDITALIC_STYLE.

If you use your own fonts, you should fill the font list as follows (I
used "new century schoolbook" since I didn't find "arial" in my
system):

#define FONT \
"-adobe-new century schoolbook-medium-r-normal--*-160-75-75-*-*-*-*"

#define BOLD \
"-adobe-new century schoolbook-bold-r-normal--*-160-75-75-*-*-*-*"

#define ITALIC \
"-adobe-new century schoolbook-medium-i-normal--*-160-75-75-*-*-*-*"

#define BOLDITALIC \
"-adobe-new century schoolbook-bold-i-normal--*-160-75-75-*-*-*-*"

[...]

fl_set_font_name( 30, FONT );
fl_set_font_name( 30 + FL_BOLD_STYLE, BOLD );
fl_set_font_name( 30 + FL_ITALIC_STYLE, ITALIC );
fl_set_font_name( 30 + FL_BOLDITALIC_STYLE, BOLDITALIC );

fl_set_browser_fontstyle(fd_try->browser, 30);

[...]

spl

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/