Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!bu.edu!snorkelwacker.mit.edu!paperboy!hsdndev!cmcl2!adm!lhc!lhc!warsaw From: warsaw@nlm.nih.gov (Barry A. Warsaw) Newsgroups: comp.windows.open-look Subject: Bug in XView TEXTSW package? Message-ID: Date: 30 Apr 91 23:51:09 GMT Sender: usenet@nlm.nih.gov (usenet news poster) Reply-To: warsaw@nlm.nih.gov Organization: Century Computing, Inc. Lines: 134 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 #ifdef __cplusplus #include #else #include #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 () ) )