Tk Source Code

View Ticket
Login
Ticket UUID: 483387
Title: BadFont error using multiple X servers
Type: Bug Version: obsolete: 8.3.2
Submitter: fitchk Created on: 2001-11-19 13:26:17
Subsystem: 46. Unix Fonts Assigned To: hobbs
Priority: 6 Severity:
Status: Open Last Modified: 2026-09-28 13:36:51
Resolution: None Closed By:
    Closed on:
Description:
The script below documents and demonstrates the
problem.  I've worked around this in my environment, so
it isn't urgent for me, but it would be nice if it
could be fixed or documented as a limitation.

Ken Fitch


#
#       This tk/tcl script demonstrates the X BadFont
error thrown when
#       we set up a toplevel for display on an X server
that is different
#       from the X server derived from "-display" or
the 
#       DISPLAY environment
#       variable.
#
#       Using multiple screens on a single X server
host seems to be OK
#               
#       This problem was seen on a Solaris system
running Tk/Tcl 8.3.2
#
#       To test on your system:
#       
#               - you need X server access to some
other machine on your  
#                 network
#
#               - invoke as "wish <this script>"
#                       (it should exit normally)
#
#               - invoke as "wish <this script>
-display  <remote_X_server>:0.0"
#                       (it should throw a BadFont
error)
#       
#       Alternatively, you can edit the X_screen line
to use a remote X server
#       and omit the "-display" stuff.  The key is to
get the "." window and the
#       ".my_toplevel" windows to be rendered on
different hosts.
#
##################################################################################
#
#       I'm not sure if there's an easy (or hard) fix
for this or not.  This does 
#       not seem to me to be a common case, so it may
be sufficient to simply
#       document the behavior.  I have no idea what
would happen on a non-Unix system.
#
#       It would be nice if the code could detect the
situation, and at least 
#       circumvent the X error(s).
#
#


set X_screen ":0.0"


eval font create symbolic_font 

set window  [toplevel .my_toplevel -screen $X_screen] 
button $window.button  -text "Touch here"  -font
symbolic_font



puts "default     window screen: [winfo screen .]"
puts "my_toplevel window screen: [winfo screen
.my_toplevel]"

puts "about to delete named font symbolic_font ..."
font delete symbolic_font 
update

puts "about to create named font symbolic_font ..."
font create symbolic_font 
update
puts "taking a nap ..."
after 3000
puts "exiting normally"
exit
User Comments: serhiy.storchaka added on 2026-09-28 13:36:51:

Still reproducible with the X11 core fonts (configured with --disable-xft --disable-bidi); Xft is not affected. When a named font was changed or recreated, the fonts which depend on it were recreated for the display of the main window, including the one used on the other display.

Proposed fix in branch font-multiple-displays, with test font-47.4 (needs TK_ALT_DISPLAY).


hobbs added on 2002-10-09 02:33:44:
Logged In: YES 
user_id=72656

Richard did a lot of work on multiple display cleanup ... 
passing to him as he may have a quick solution.

hobbs added on 2002-07-25 01:53:43:
Logged In: YES 
user_id=72656

I do get the error:

default window screen: lorax:0.0
my_toplevel window screen: woset:0.0
about to delete named font symbolic_font ...
about to create named font symbolic_font ...
X Error of failed request:  BadFont (invalid Font parameter)
  Major opcode of failed request:  55 (X_CreateGC)
  Resource id in failed request:  0x200000b
  Serial number of failed request:  57
  Current serial number in output stream:  63

which likely indicates some info about the font is not cleared 
properly, or some error should be thrown since you can't 
really delete a named font while it is still in use.