How to configure fonts on a remote X connection (XDMCP vs. ssh)?

6,278

Solution 1

I believe XDMCP is using the fonts local to the Solaris system. When you SSH you're using fonts that are local, since in that scenario you're the X server and the Solaris box is the X client. You can use the command xlsfonts to see what fonts are accessible to you on a given system.

EDIT #1 - Font path

You can find out your system's font path using the command xset.

Example

$ xset q | sed -n '/Font/,/DPM/p'
Font Path:
  catalogue:/etc/X11/fontpath.d,built-ins
DPMS (Energy Star):

This path can include paths to local directories as well "paths" to other font servers. These will show up as port@host types of entries.

Example

$ xset +fp tcp/<IP or name of font server>:7100

References

Solution 2

First thing is to compare font paths via xset q, e.g.:

$ xset q
Font Path:
  /usr/share/fonts/misc/,/usr/share/fonts/100dpi/,/usr/share/fonts/75dpi/,built-ins

(a X font server (XFS) url may also be part of a font path)

If needed you can add font paths via xset +fp path. After manipulating font paths you have to call xset rehash.

The next thing is to compare the output of xlsfonts.

If it outputs a lot of fonts but your X programs still complain about missing fonts or simply use an ugly standard font for everything: this can be caused by font related X-resources pointing to unavailable fonts.

A simple test is to start emacs - which may complain about not finding a found like:

-dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*

You can verify if such X resources are set via something like:

$ xrdb -query | grep -- -dt
$ xrdb -query | grep -i font

If that is the case you get output like:

*Font:  -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*
*userFont:      -dt-interface user-medium-r-normal-m*-*-*-*-*-*-*-*-*:

You can remove those entries via xrdb -remove - such that the default font settings are used.

Alternatively, you can load your own font related X resources settings.

Background

X resources are usually set via config files like:

/$SYS_PATH/Xresources
/$SYS_PATH/xinitrc
/$SYS_PATH/Xdefaults
$HOME/.xinitrc
$HOME/.Xresources
...

Or some variation on that - e.g. a lower case x.

Those files may be executed while logging in via an X display manager (XDM). When using XDMCP, XDM runs on the remote system and thus executes those files remotely.

But they are not executed when using X forwarding via ssh.

The obscure font name (-dt-interface) comes from CDE - which seems to was the default desktop environment under Solaris at some point - and they are not included with the Cygwin X server.

Share:
6,278

Related videos on Youtube

Nate Byram
Author by

Nate Byram

Updated on September 18, 2022

Comments

  • Nate Byram
    Nate Byram over 1 year

    I am trying to design a program that will open any text file, read it into a string, encrypt the string with XOR, and write the string to a new text file. The code below works, but generates multiple "system beeps".

    My wild guess is that I am not handling whitespaces correctly? I'm not sure. Any ideas what I'm doing wrong?

    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    
    int main()
    {
        ifstream inFile;
        ofstream outFile;
    
        // Define variables
        string fileName,
            key = "seacrest out";
    
        // Input
        cout << "Please enter the name of the file you wish to encrypt: ";
        cin >> fileName;
        cout << endl;
    
        inFile.open(fileName, ios::in | ios::binary);
        string str((istreambuf_iterator<char>(inFile)), istreambuf_iterator<char>()); // Reads a text file into a single string.
        inFile.close();
        cout << "The file has been read into memory as follows:" << endl;   
        cout << str << endl;
        system("pause");
    
        // Encryption
        cout << "The file has been encrypted as follows:" << endl;
        for (unsigned x = 0; x < str.size(); x++)           // Steps through the characters of the string.
            str[x] ^= key[x % key.size()];                  // Cycles through a multi-character encryption key, and encrypts the character using an XOR bitwise encryption.
        cout << str << endl;                                // This code works, but I get system beeps. Something is still wrong.
    
        // Write Encrypted File
        cout << "Please enter the file name to save the encrypted file under: ";
        cin >> fileName;
        cout << endl;
    
        outFile.open(fileName, ios::out | ios::binary);
        outFile.write(str.c_str(), str.size());         // Writes the string to the binary file by first converting it to a C-String using the .c_str member function.
    
        system("pause");
    
    return 0;
    }
    
    • AndersK
      AndersK almost 12 years
      in order to avoid this problem you could encode the xor values e.g. writing the hex value as a string 0x07 -> "07"
    • Bananguin
      Bananguin over 10 years
      I don't know what XWin does, but this seams like an issue with your environment. What X Server are you connecting to when you use the SSH approach? Is it a different one compared to the XWin use case? I'm guessing when you start the whole Cygwin thing paths are set so that all fonts can be found. If you don't it won't. Fonts are a local thing ... at least in vanilla X.
    • maxschlepzig
      maxschlepzig over 10 years
      @Bananguin, when using ssh -Y I am doing that from inside a stock Cygwin-xterm which is launched when the Cygwin/X application is started. Cygwin/X calls startxwin.exe which it turn seems to also launch XWin.exe. XWin.exe is like a normal X Xserver plus some other options.
    • slm
      slm over 10 years
      XWin is the X server that's bundled with Cygwin. There is also XMing for example, a standalone X server for Windows.
  • maxschlepzig
    maxschlepzig over 10 years
    Ok, I've also tested another proprietary Windows-XDMCP client now. With that I get some fonts (all bitmaps, it seems) - at least more than one - and enough to make emacs happy. Is there an X command to investigate if that session uses some kind of X font server (address/port) or activates some other session relevant setting?
  • maxschlepzig
    maxschlepzig over 10 years
    The xset q outputs showed no differences and a xset fp rehash did not help either. What makes the difference between my two setups is that with XDMCP a remote system-wide xinitrc/xdefaults file is executed after XDM login. And that mechanism sets some font related X-ressources ... You can verify this via something like xrdb -query | grep -- -dt and remove those entries via xrdb -remove. When doing ssh X-forwarding those X-ressources are not loaded, of course.