Font Rendering difference in windows and Linux, Qt Cpp - c++

I have,
QFontMetrics m_fm(QFont("Arial",14)); and
m_fm.width("Existing LAN IP Address from Project Network");
returns '297' (on windows)
can anyone tell me what it returns on linux compiler?
and if its different on linux then why so?
and how can we have same font rendering on windows as well as in linux.
Update:
I have a QTableView cell , in which I am writing data from multiple strings collectively, I have to show data in 2 Lines in single row. (using .append("\n")).
Lets say column width is 140,
so I need data to fit in 140 pixels of the cell for one line
Therefore , i need to have data whose pixel width is less than 140, so that it can be shown properly. in such case, depending on font(Arial) I am computing m_fm.width("Existing LAN IP Address from Project Network"); but it differs in Linux, as windows Arial font is not available. By any chance can I get proper pixel width , without installing Arial font in Linux system ?
Thanks in Advance !

Try to load font on main.cpp QFontDatabase. Maybe You havent got the same font. Add font to resource file. Check DPI on screen or enable High antyaliasing on start app.

Related

GetTextExtentPoint32W returns different values in different computers

I'm trying to adjust button width depending on the current language that is set in comboBox. For some language like spanish some of the texts are just too long to be fitted into PUSHBUTTON. All controls are in .rc file. To calculate PUSHBUTTON width I'm using RECT (rect.right - rect.left) and to calculate text widht I'm using GetTextExtentPoint32W but unfortunately this method is giving me different values depending in what PC is running. In my laptop where resolution is set to 1920x1080 and scalling100% (recommended is 125%) text width is around 25% bigger than in PC with the same configuration
It depends on the Device Context which may be different across PCs.
Also, you need to be DPI-Aware (since your scalling is not 100%) and GDI isn't.
Suggestion: move to Direct2D.

Custom cursor scaling with windows accessibility settings

I have implemented 32x32 custom cursors with bitmaps using the following approach (in Qt 6.1.1):
this->setCursor(QCursor(QBitmap(":/Cursors/arrow_up.bmp"), QBitmap(":/Cursors/arrow_up_mask.bmp"), 3, 0));
The cursors work as expected if the Windows display setting for size of apps and text is set to 100%. However, if the size of apps and text setting is increased, Qt scales up the custom cursors accordingly and they become pixelated (e.g. if 150% is selected, Qt increases the size of the custom cursors by 50%).
Is there a way to prevent Qt from resizing the custom cursors? Alternatively, is there a way to know what the user has selected in Windows for the size of apps and text, so that I can provide cursors at the correct resolution?
Try this :
QCursor cursor = QCursor(QIcon(":/Cursors/arrow_up.bmp").pixmap(32, 32), 0, 0);
this->setCursor(cursor);
means that use QIcon instead of QBitmap and set its size by pixmap(32, 32).
Another things that may help you :
put this line in your main.cpp file :
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Read this Document . As I understand setting AA_EnableHighDpiScaling flag Enables high-DPI scaling in Qt on supported platforms (see also High DPI Displays). Supported platforms are X11, Windows and Android. Enabling makes Qt scale the main (device independent) coordinate system according to display scale factors provided by the operating system. This corresponds to setting the QT_AUTO_SCREEN​_SCALE_FACTOR environment variable to 1.

Set console font size in fullscreen mode

I use SetConsoleDisplayMode() to switch the console into fullscreen mode. It is 80x25, centered in the middle with quite a small font, which I'd like to enlarge.
I still work on WinXP, so SetCurrentConsoleFontEx() is not an option for me. I found this link which describes some undocumented functions including SetConsoleFont(). They work great: the GetNumberOfConsoleFonts() returns 9 usable fonts on my system and I can pick some, however under fullscreen 0 font were found, which means it is not supported.
I also tried to create shortcut to the program and set the console there, but there's no fullscreen option and after switching to fullscreen all font settings are discarded.
I'd like to convince the screen to show nice big text font, just like in sci-fi movies or in good old BIOS assembly coding. Is it possible under XP?
The full-screen console mode switches the display adapter into 80x25 VGA text mode.
Thus font-rendering is completely different. In a normal console window the font is rendered using GDI; in full-screen mode Windows writes a character code to the display buffer and the hardware renders the font.
VGA supports loadable fonts and Windows uses this feature to support its different language versions. I don't remember if the font is fixed by the language version of Windows or if its chosen to match the current code page. (Full-screen mode doesn't work on x64 and I don't have a 32-bit system handy to try it.)
I'm not aware of you getting any kind of choice in the VGA font used, though there's probably some mileage in overwriting the VGA fonts in the Fonts directory. Though obviously this isn't something you'd want to be doing in production.
Finally, it might be possible to change the font using an actual DOS app! I know Windows NT traps some video-related IOs and passes them through to the hardware. This isn't much use though.
Did you try to write out GetLastError()? My opinion is that this will not be working on windows 7 or later.
Maybe you could try this: #define _WIN32_WINNT 0x0601
Cheers!

get xorg.conf serverLayout with c++

I am currently working on a multi window application that spans over multiple screens. The software is written with xlib and runs on ubuntu 10.10, gnome desktop.
To get the position of every window I'd like to access the /etc/X11/xorg.conf file, expecially the section SeverLayout. It looks somehow like this:
Section "ServerLayout"
Identifier "aticonfig Layout"
Screen "screen0" 0 0
Screen "screen1" 1920 0
Screen "screen2" 3840 0
Screen "screen3" 5760 0
EndSection
I'd like to get the X values of each screen (0, 1920, ... ) Does xlib somehow provide access to this information?
thanks
Information about layout of multiple monitors in X, especially when they're combined into a single logical screen, is available via the libXrandr and libXinerama API's. Unfortunately, the multi-screen API's added to libXrandr in version 1.2 aren't covered in the man page, but require looking at the extension spec and Xrandr.h header file.
You can use XWidthOfScreen and XHeightOfScreen functions.
Use XScreenCount (to get number of screens) and XScreenOfDisplay to get appropriate screen structure.
A better way is to get the root window of a screen and parse it's geometry using XParseGeometry function.

What is the maximum width of a widget that's allowed to be created in Windows CE

We are trying to create a widget of width larger than 2^15 pixels and the widget gets only black (no content shown) when we pass the 2^15 pixel barrier. Is there any documented maximum size limits imposed on widgets?
Any help is appreciated. Not only CE but I am interested in desktop Windows as well.
P.S: Using C++
The only thing I could find on MSDN Control.Size was this:
On Windows Server 2003 systems, the
size of a Form is restricted by the
maximum pixel width and height of the
monitor.
I imagine the same would be true on a handheld running Windows CE.