Reputation: 1279
So I'm trying to print lbf.S²/in⁴
in a mfc label, but it shows-up as lbf.S²/in4
.
I'm wondering why ²
will display correctly while ⁴
wouldn't.
It's a 32bit project with Unicode character set.
Here's the .rc code
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Units"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
CTEXT "lbf-sec²/ in⁴",IDC_IPS1,77,36,48,8
END
Upvotes: 3
Views: 417
Reputation: 10756
I'm convinced this has to do with inadvertent changes to the file encoding.
Recreate as follows:
lbf-sec²/ in⁴
as static text captionBuild and run, and all is well.
Visual Studio now refreshes and caption is garbled.
lbf-sec²/ in⁴
as the label captionBuild and run, and you see the error
View .rc file in editor and text has indeed reverted and so has encoding
Caveat
I'm not saying I know how, why or when the encoding changes, I'm saying it somehow can happen.
A solution (What works for me)
lbf-sec²/ in4
, and with encoding UTF-8lbf-sec²/ in⁴
Clean, Rebuild All, run and all is well.
Upvotes: 2
Reputation: 51874
It would appear that the font you have selected for your dialog box doesn't support the superscript 4
and the character is being mapped to the plain 4
. (Many fonts have the superscript 2
, as yours does, but other superscript characters are not so widely supported.)
In your resource script, make sure you have a font that includes all characters you want to use (Arial Unicode MS has pretty much everything you're likely to use, and is installed on most Windows systems, IIRC), and be sure to include the DS_SETFONT
style:
IDD_MYBOX DIALOGEX 0, 0, 370, 270 // 14-JAN-2020
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION L"My Dialog Box Title"
FONT 10, L"Arial Unicode MS"
{
//.. dialog controls
}
Alternatively, you can explicitly set the font for a given control, but that's a bit more work, as you have to define and load the font into your executable at run-time (I can help you with some code to do this, if you want to go down that path.)
Other fonts that have a good selection of superscript numbers include "Calibri" (my favourite for UIs) and "Arial," but I'm not sure what the licencing and redistribution arrangements for these are.
Upvotes: 1