warsaw@nlm.nih.gov (Barry A. Warsaw) (05/01/91)
System: Sun SS1+, OS4.1.1, X11R4.18, MIT XSun, XView2 I *think* I have found a bug in XView's TEXTSW package. The problem is that getting the font of the TEXTSW returns the incorrect font. I haven't been able to track this down to any XView code (the TEXTSW stuff is fairly hairy), but I do have an example you can compile -- see below. I use Guide to create a window with a TEXTSW in it called textpane1. Then I do the following: Xv_Font font = (Xv_Font)xv_get( textpane1, XV_FONT ); This will return the default font for the application, *not* the font the textpane1 actually uses, which is a fixedwidth version of this default font. This really screws up you horizontal width calculations when you're trying to correctly size the TEXTSW! To recreate this (you must have GUIDE), generate either the C or C++ code from the GIL file following my siggy. Then add the following lines to the top of sample_stubs.C (or .c): #include <xview/font.h> #ifdef __cplusplus #include <stream.h> #else #include <stdio.h> #endif Then in the getinfo function, add the following: Xv_Font font = (Xv_Font)xv_get(ip->textpane1,XV_FONT); #ifdef __cplusplus cout << "font family: " << (char*)xv_get(font,FONT_FAMILY) << endl; cout << "font name: " << (char*)xv_get(font,FONT_NAME) << endl; cout << "font style: " << (char*)xv_get(font,FONT_STYLE) << endl; #else printf( "font family: %s\n", (char*)xv_get(font,FONT_FAMILY) ); printf( "font name: %s\n", (char*)xv_get(font,FONT_NAME) ); printf( "font style: %s\n", (char*)xv_get(font,FONT_STYLE) ); #endif I've tested this with C++ (getting a bit rusty with that old stdio stuff :-). Anyway, unless I've lost my mind (which admittedly *could* be my problem -- big demo coming up in 2 days ;-), you should see the font printed out as a lucida, variable width font, instead of the lucida fixed width font the TEXTSW actually uses. Load a file into the TEXTSW to verify that it uses a fixed width font. Also, be sure you don't have any XView font resources set. -Barry NAME: Barry A. Warsaw INET: warsaw@nlm.nih.gov TELE: (301) 496-1936 UUCP: uunet!nlm.nih.gov!warsaw --------------------cut here-------------------- ;GIL-2 ( ( :type :base-window :name window1 :owner nil :width 400 :height 150 :background-color "" :foreground-color "" :label "Base Window" :label-type :string :mapped t :show-footer t :resizable t :icon-file "" :icon-mask-file "" :event-handler nil :events () :user-data () ) ( :type :control-area :name controls1 :owner window1 :help "" :x 0 :y 0 :width 400 :height 36 :background-color "" :foreground-color "" :show-border nil :menu nil :event-handler nil :events () :user-data () ) ( :type :button :name info :owner controls1 :help "" :x 20 :y 8 :constant-width nil :button-type :normal :width 42 :height 19 :foreground-color "" :label "Info" :label-type :string :menu nil :notify-handler getinfo :event-handler nil :events () :user-data () ) ( :type :text-pane :name textpane1 :owner window1 :help "" :x 0 :y 36 :width 400 :height 114 :background-color "" :foreground-color "" :show-border t :read-only nil :event-handler nil :events () :user-data () ) )
jcb@NCD.COM (Jim Becker) (05/02/91)
warsaw@nlm.nih.gov (Barry A. Warsaw) writes:
System: Sun SS1+, OS4.1.1, X11R4.18, MIT XSun, XView2
I *think* I have found a bug in XView's TEXTSW package. The problem is
that getting the font of the TEXTSW returns the incorrect font. I
haven't been able to track this down to any XView code (the TEXTSW
stuff is fairly hairy), but I do have an example you can compile --
see below.
I use Guide to create a window with a TEXTSW in it called textpane1.
Then I do the following:
Xv_Font font = (Xv_Font)xv_get( textpane1, XV_FONT );
This will return the default font for the application, *not* the font
the textpane1 actually uses, which is a fixedwidth version of this
default font. This really screws up you horizontal width calculations
when you're trying to correctly size the TEXTSW!
try finding the font for the first view in the textsw:
Xv_Font font = (Xv_Font)xv_get( textsw_first(textpane1), XV_FONT );
that should do it, if anything will.
-Jim Becker
--
--
Jim Becker / jcb@ncd.com / Network Computing Devices (NCD)
openlook-request@openlook (05/13/91)
> > I *think* I have found a bug in XView's TEXTSW package. The problem is > that getting the font of the TEXTSW returns the incorrect font. I > haven't been able to track this down to any XView code (the TEXTSW > stuff is fairly hairy), but I do have an example you can compile -- > see below. > > I use Guide to create a window with a TEXTSW in it called textpane1. > Then I do the following: > > Xv_Font font = (Xv_Font)xv_get( textpane1, XV_FONT ); Try getting the TEXTSW_FONT. That works for me. Frank G.
fgreco@govt.shearson.com (Frank Greco) (05/14/91)
> > But when I grep for TEXTSW_FONT in the OpenWindows 2.0 XView include > files I get: > > warsaw@warsaw[3]% grep TEXTSW_FONT *.h > textsw.h:#define TEXTSW_FONT XV_FONT hmmm... that's interesting. I have been using this in a little hack using TEXTSW's as very fast-loading exclusive scrolling lists (created in the alpha days). I'll take a look.... Whoops my mistake, I was grabbing the font in an interposed event proc for my textsw, which means I was actually looking at a view, not the tsw itself. That means you'll have to get the font from the view of the textsw. Sorry. I hope I didn't cause any confusion. Frank G.