01-30-2013 02:41 PM - edited 01-30-2013 02:50 PM
We are having problems with panels that look fine on Windows being difficult to read on Linux, presumably because most control and text fonts are VAL_DIALOG_META_FONT on Windows but the CVI for Linux run-time only has NISYSTEM.
As a quick way to test different fonts on Linux I created a tui file from the uir file and then used global search and replace to change VAL_DIALOG_META_FONT to something that would hopefully look decent on Linux.
Problem is that LoadPanel(0,"filename.tui",1) works on WIndows but throws error -46 on Linux.
Whereas LoadPanel,0,"filename.uir,PANEL) works fine on Linux & Windows but the fonts are very hard to read on Linux.
Is there a table somewhere mapping the VAL_FONT attribute magic numbers to corresponding fonts on Windows and Linux?
It'd be nice to have some guidance on the default font mappings. But at the end of the day, I don't really care much about fonts unless the defaults are hard to read. 😞
I guess one other potential complication is the UIR file originally came from CVI 8.5, but CVI 2010 for Windows didn't say anything about needing to "convert" it. Perhaps one of the attributes in the tui file is not valid on Linux, but is on Windows?
Solved! Go to Solution.
01-31-2013 03:36 AM
It may be that CVI does not complain about UIR version when opening a 8.5 file, but if you explicitly save it in 2010 format it should fix all attributes to that release. After hat you should be able to it save in .TUI format and read it back in linux without problems. If this is successful you could start modifying it according to your needs.
This is just my 2c out of common sense thinking, as I have no experience on CVI for Linux.
01-31-2013 07:42 AM - edited 01-31-2013 07:43 AM
It has been loaded into CVI2012, a few attributes changed to get some clues about the font problems, and then saved in CVI2010 with the "always save tui with uir" option checked in preferences.
I can post the uir file if anyone at NI is interested. Its trivially easy to test, just as stub program the call InitCVIRTE() and LoadPanel() to see if LoadPanel() succeds or returns error -46.
This would not be the first issue I've found with uir files that work on Windows but not on Linux when porting.
02-01-2013 11:16 AM
Loading TUI files in Linux it's an issue that we have recently discovered and it did not made it yet to the known issue list. I'm not 100% sure but I believe a workaround to that problem would be to go and manually edit that tui file and remove those attributes that generates errors. You can begin with ATTR_TITLEBAR_STYLE and then look if one of the following are in the tui file: ATTR_DS_BIND_PLOT_STYLE, ATTR_DS_BIND_POINT_STYLE, ATTR_DS_BIND_LINE_STYLE, ATTR_DS_BIND_PLOT_COLOR and delete them. Then try to load the tui file again.
On the other hand I think there is a workaround for your original problem: the predefined fonts (VAL_DIALOG_METAFONT) looks bad on Linux. I believe there is a way a user can change the underlying font and the size of a predefined font. In windows you can change it in the registry but in Linux you can define an environment variable: XAPPLRESDIR that points to a directory that should contain a file named cvi, a file where you can write font settings. Each line has to be of the following format: <appName>.<key>:<value>. If you want the settings you're writing to be persistent for all applications the put a "*"instead of the application name.
The list of possible key is: appFont (NIAppMetaFont), menuFont (NIMenuMetaFont), dialogFont (NIDialogMetaFont), editorFont (NIEditorMetaFont), messageBoxFont (NIMessageBoxMetaFont).
The value have to be of the following form: <font family>-<font name>-<font size>
Here is the only line I have in the cvi file: *.dialogFont : adobe-helvetica-19
02-01-2013 04:10 PM
Thanks, removing the line with the ATTR_TITLEBAR_STYLE from the tui file allows the tui file to load, so I was on the right track. But although the panel loads the
control with ATTR_CTRL_STYLE = CTRL_NUMERIC_GAUGE_LS doesn't work correctly -- the numeric display updates correctly, but the "tickmarks" are not drawn and the indicator needle never moves. There are no ATTR_DS_BIND_* attributes in the tui file.
As I said, if I load the UIR file in Linux everything works correctly.
Its just a simple little toy app we use to test USB joysticks to see if they will be useable for our experiments and to map the button presses. I've zipped it up and attached.
I was only looking at using the tui file as a way to work around and perhaps solve our font problem, so the second part of your reply may be the real solution I've been looking for!
Will get back to you after I've had time to give it a try.
Thanks!
02-01-2013 05:04 PM
Thanks! making a /usr/local/natinst/cvires directory with a file cvi in it containing:
*.dialogFont : Sans-12
*.appFont : Sans-12
*.menuFont : Sans-12
*.messageBoxFont : Sans-12
helped a lot after I did the:
export XAPPLRESDIR=/usr/local/natinst/cvires
and ran a few applications.
Sans may not be the best choice, so I'll play around some more, but two quick application checks made things a lot more readable! although some labels overlapped a little.
I gave you a kudo as I've been fighting this since I first got the CVI8 Linux runtime.
Can I use a * for the -<fontsize>? As I said originally I don't really care much about the fonts as long as they are easy to read, but I do use a lot of size variations in UIR control attributes to emphasize certain things in the UI. I have learned that BOLD is not generally a good ide on Linux, would be nice if this also fixes it.
Now to add the export to my .profile file to make it permanent.
02-06-2013 03:09 AM
Thanks, finally a solution to a problem I've had for years in my linux CVI apps.
My solution was to prompt the user for a font and do a massive replace of all FONT attributes. Here's the code for those interested (see Ctrl-Shift-F in HandlePanelDefaultKeys() in the PanelManagement.c code here)
02-07-2013 09:39 AM
One more useful tidbit, at least on Debian derived systems (Ubuntu, Mint etc.) it would appear the proper place to put the
XAPPLRESDIR="/usr/local/natinst/cvires"
line is in the file: /etc/environment
This way it is in the environment of all shells for all users and makes it work when a CVI application is launched from a desktop menu selection.