AddFontResource does not install the font correctly - c++

I use AddFontResourceW(_T("C:\Program Files\MyApp\MyFont.ttf")); to install 2 fonts from my 64-bit C++ app.
The return value is 1, but in the app the font is displayed 10 times smaller and look like Sans Serif (not my font).
If I manually install the font in Windows, then it is displayed correctly in the app.
I have tried AddFontResourceEx, but the same result. I also have tried to copy the TTF font file in C:\Windows\Fonts with my app installer and then call AddFontResource(_T("myfont.ttf")); and the same result.
If I don't call the AddFontResource at all, then the font is substituted with Arial with the correct size.
Tested in 64-bit Windows 7, 10 and Windows 2012 Server.
I have tried with Oswald font and Ubuntu, but I get the same results.

I have solved the problem by copying the font to C:\Windows\Fonts then add it to registry and then AddFontResource, otherwise it does not display the font correctly. Using it as a temporary font resource it does not work.

Related

Qt tableview model not native Windows system font

I created a tableview with model, but the font is not the native system font. It currently looks like this (a combobox inside the tableview):
But in another textinput in the same application it looks correctly like this:
I use no custom fonts and have not overridden the Qt::FontRole (return invalid QVariant()). Why doesn't it use the system font? This is on Windows 10.
EDIT:
There doesn't seem to be any issue when running the executable on my laptop. I'm suspecting a mismatch in .dll files. It should be using the exact same ones but perhaps its using .dll files it finds on my system PATH.
EDIT:
After checking with ProcessExplorer it seems that it loads the correct dlls which are exactly the same my other system loads. The Visual C++ Redistributables versions are also exactly the same.
EDIT
Tried with Visual Studio 2017 (from 2015) with fresh Qt installation, but that doesn't solve the problem either.

Windows 10 Creators Update (1703) crashes our application

Our users are experiencing crashes when Windows 10 Creators Update (1703) is automatically installed through Windows Updates. The Windows application of ours is a multilevel, C++ WinForms application. The application can start, but if we click on certain menus, it crashes. Appears to be a graphics issue or something to do with fonts, perhaps. Why?
When the Windows 10 1703 update was applied, the installer replaced the Windows/Fonts directory and did not include shortcuts to fonts included elsewhere in Windows.
In our case, our application was needing Lucida Sans Typewriter font, which had been registered with Windows, but located in a bundled JRE for IBM Client Access off Program Files (Our application uses some IBM Client Access components).
Shortcuts of the Lucida fonts were in the Windows/Fonts directory before the update, but absent after the update (which caused our application to crash).
The Fix: We had to copy/paste all the Lucida fonts (there are 8 of them) required from the embedded JRE/lib/fonts directory into the Windows/Fonts directory to resolve the issue. We found if we did this before the 1703 update or after, our application continued to work.
The Lesson: We are going to ensure our applications use fonts that we control 100%, by copying them into Windows/Fonts during install.

Wine window is too small

After trying to build wine1.7.25 the windows which are created by wine are extremely small. And I am not able to resize them. It looks like this
You can resolve this using the winecfg program.
Open a terminal
Type winecfg
Select the Graphics tab
Move the slider bar for Screen Resolution up. For example try 200 to start with.
Press OK.
Open the application and see if it is large enough for you now. If it is too large or small, adjust the resolution with winecfg again.
It was the fault of not building wine with freetype
have you tried setting the size of the window manually?
this might have helpful info for you http://ubuntuforums.org/showthread.php?t=1526631
I had this problem, when I wasn't install llibfreetype6:i386.
Wine was showing:
ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Wine cannot find the FreeType font library. To enable Wine to
use TrueType fonts please install a version of FreeType greater than
or equal to 2.0.5.
For resolved:
sudo apt install libfreetype6:i386
I'm working on Kubuntu 18.10.

MFC icon works on Windows 7, not on Windows 8.1

I have a MFC/C++ application that is built on a Windows 7 system, where it works fine, and I want to use it on a Windows 8.1 system. It also works on Windows 8.1, but the taskbar icon is the MFC default icon (3 blocks with "M", "F" and "C"), rather than the one I designed for the app.
My icon file includes 16 x 16, 32 x 32, 24 x 24, 32 x 32, 48 x 48, all in 4-bit, 8-bit and 32-bit color--BMP format, and 256 x 256, 32-bit color--PNG format.
The app is being built with Visual Studio 2010.
What do I need to do to get the taskbar (and other icons) to work on Windows 8.1 as well? I can't find any MS documentation on the icon requirements; a pointer to these would also be helpful.
UPDATE: When Windows 8.1 was rebooted, one of my icons appeared in the task bar (don't know which resolution or color depth), so, immediate problem solved. However, I'd still like to know why icon didn't appear immediately, and which format icon is used.

Why same font style show different on windows and linux by QT

I do not use linux x11 windows system, and keep same font family on these two OS, and turn the text to image then save it.I use tahoma.ttf font in QT,set styleStrategy to NoAntialias and set font point size to 7, but on windows
"e""a" looks pretty good on windos.
But on linux :
I am pretty sure the font size is same, because if set pointsize to 8, e will cost 5x6 pixel.
I try the freetype lib on windows not using QT. The result is almost the same with QT in window, so I wonder how to make text the same with windows style.
It looks like that QT 4.7.4 have did included freetype lib, and I try the freetype interface in Qt lib, it shows the same effect with original no modifed Qt qfontengine_ft.cpp.