HP VEX模拟器XLoadQueryFont字体缺失问题:安装字体能否解决?
Absolutely—installing the exact Courier font specified in your code will almost certainly resolve the XLoadQueryFont error. That function returns a NULL pointer when it can’t locate the requested font, which breaks the VCG visualization tool integration your HP VEX simulator depends on. Here’s how to fix it:
1. Confirm the missing font
First, verify that the font your code is requesting isn’t already installed. Run this command in your terminal:
xlsfonts | grep "-*-courier-*-*-*--14-"
If you get no output, that confirms the font is missing.
2. Install the required font package
The steps vary slightly depending on your Linux distribution (since this is an X11-based issue, we’ll focus on common Linux setups):
Debian/Ubuntu-based systems
Update your package list and install the scalable Courier font package plus X11 font utilities:
sudo apt update && sudo apt install xfonts-scalable xfonts-utils
Then refresh the X11 font cache to make the new font available immediately:
xset fp rehash
RHEL/CentOS/Fedora systems
Install the misc X11 fonts package and utilities:
sudo dnf install xorg-x11-fonts-misc xorg-x11-fonts-utils
Again, refresh the font cache:
xset fp rehash
Manual installation (if package managers don’t work)
If you can’t find the font via your package manager, you can manually install a Courier TrueType font and convert it for X11:
- Download a Courier TrueType font (e.g., the open-source Courier Prime).
- Create a directory for custom X11 fonts, like
~/.fonts/x11/, and place the font file there. - Run these commands to generate X11 font indexes:
mkfontdir ~/.fonts/x11/ mkfontscale ~/.fonts/x11/ - Add the directory to your X11 font path:
xset fp+ ~/.fonts/x11/ xset fp rehash
3. Verify the fix
Run the xlsfonts command from step 1 again—you should now see matching font entries. Launch your HP VEX simulator, and it should successfully load the VCG tool without the font error.
Fallback option (if installing the font isn’t feasible)
If you can’t install the exact font, you can modify the VCG_DEFAULT_FONT definition to use a Courier font that’s already on your system. Use the xfontsel tool to visually select a valid XLFD string for an installed Courier font, then replace the existing macro definition and recompile the code (if you have access to the source).
内容的提问来源于stack exchange,提问作者hkassir72

