QT Framework QML Application fonts too small on Mac OS X - qt

I have a QT application where font family and size is set in QML
On windows and linux it works fine. However, on OS X text appears too small. This is something that someone else wrote. It uses Segoe UI font. As I understand in QT 4.7 I can assign fallback fonts with a coma. However the defined point sizes still seem to be too small.
Is there something I can do to fix this issue without changing the way how this looks on other platforms?

If you use font.pointSize to set the size of the font then the resulting pixel size depends on the device or more generally, the dpi of the screen (as far as the system is aware of it).
This means that if you really meant the font to have the same pixel size, whatever the dpi of the screen, then you should be using font.pixelSize to set the size of your fonts instead.

Related

How can I compensate for fonts rendering differently on windows on a web page

I have a web page with text and an image. I want to place the text very precisely over the image.
I have discovered that with the font I am using, when viewing the page on windows, everything gets shifted down by about 4px. On Mac, iphone and android, it is placed correctly.
This does not happen if I use Courier New as the font, so I know that the problem is the font, however I have no choice but to use this font.
Is there a way to compensate for this purely in CSS, or do I need a javascript callback to detect windows and add a class so I can deal with it?
first of all, I would try tuning ling height, if that did not work, then I think you need to edit the font itself, you can do that using this site: https://transfonter.org/, uploading your font file and convert it to the formats you use and the important point is to check this toggle button, it adjusts some properties in the font so it has similar experience on different operating systems
if that did not work, there is a program called fontforge it gives you the ability to change font metrics, for more info you could check this question
Font Rendering / Line-Height Issue on Mac/PC (outside of element)

Whats the proper way for scaling text?

I am developing a Qt QML based application that runs on both Desktop and Mobile operating systems. I am having problems with proper fonts and components scaling- what does look good on large, desktop monitor is barely visible on a mobile phone, even though the scaling is the same.
I was wondering, what is the proper approach for this problem? I would like to run the same code on all platforms. For example, is there a way for a font to stay the same size (in mm or inches), no matter the screen resolution and size?
In QML I am always setting the font.pointSize property. It is scaled evenly, but because of that, the font are barely visible on mobile devices.
Have you tried font.pixelSize property yet?
I think this will be good for you.
"Sets the font size in pixels.
Using this function makes the font device dependent. Use pointSize to set the size of the font in a device independent manner."
https://doc.qt.io/qt-5/qml-qtquick-text.html#font.pixelSize-prop

Using the same font size or width px in Wicked pdf shows differently in MAC and Ubuntu

I use wicked pdf for generating pdf in my ruby on rails project. I set CSS in the part in show.pdf.erb.
I use the same font-size px for p or same width or height px, however, in Ubuntu system it's much bigger than in the Mac system. I set the same page_size: 'Letter', may I know how to solve this? Is that because of the resolution or retina of Mac? Even if I use em or % for the font size or width, it still looks very different in Mac and Ubuntu. I want to make a business card size div with some content inside no matter people use Mac to open and print the pdf or Ubuntu.
Wickedpdf on different platforms renders differently because of:
system fonts are different (this can be somewhat fixed by using custom web fonts)
systems have different DPI settings (this affects sizing the most, but can be tuned)
different font renderers and smoothing
For exact sizes it's better to use corresponding markup - with cm or in units.
Also for more control over resulting pdf - you may want to eliminate intermediate html render and use direct pdf rendering with something like prawn pdf

How to zoom in Rstudio help window? [duplicate]

This is not a question about changing the font size in graphs produced using RStudio. I already know how to do that.
I use RStudio under Linux on a MacBook Pro with a 'retina' display. I use KDE as my window manager. I can (and do) enlarge the default font size in the user interface of other programs in KDE. I increase the font size for the user interface in Firefox and Thunderbird using program specific tools.
How do I increase the font size in the user interface - not the console, which is easy [Options -> Appearance -> font size], but, for example, the help text, the keyboard shortcuts list, and so on. At the moment I find these very hard to read. I've fiddled with everything I can fiddle with, but had no joy.
All help gratefully appreciated!
As some people pointed out, by clicking the ctrl & + together, you can enlarge the font size for everything including for the console & code script. (You will have to do it with a help page pop up as suggested by user3619015.) Then go to the global option and resize the fonts. That changes the font size for everything except the help page. So you will have larger fonts for the help page but everything else in your normal preferred font size.
On a Mac you can do it by going to: view -> actual size or just with the key combo: cmd+= (not cmd++) to zoom in (bigger), cmd+- or zoom out or cmd+0 (zero) to go back to the actual size.
Rstudio doesn't support changing fonts yet, at least for Linux server. However, one can change fonts in browser for a specific page. At least in chrome, you can customize fonts using an extension called font changer. I think it is packed with all GNU free fonts for legal issues. But, since you have the font files in the OS, like consolas, you can practically change to whatever font and size you like. Just play with it.
I had the same problem here using a MacBook Pro although not with KDE, but you could try on the menu of RStudio:
View -> Actual size
After a couple of days struggling to read the help, this worked: increased the size of letters in all windows of RStudio.
Help, Files, Packages can be opened in a new browser window where zoom in and out options are possible. Even a selected specific package can be opened in a new window for clear view
While this is quite an old question, you can now also change your font size under Linux like that:
Tools -> Global Options... -> Appearance -> Editor font size
Here's how I got around the problem:
Simply copy and paste into your word processor or text editor. Text will be pasted in the default text.
I'm using Windows 8.1, Office 2013 and R 64 bit. Not optimal but it works.

QT: Fonts and their width

I have windows that are fixed in size, under which I have textual labels. Although I use the same font, the fonts look different on windows, mac and linux, up to the point where I can't rely on where a label will end, even though the string and the font size are a constant in my application.
Is there any solution to that? Someone mentioned embedding TTF fonts and using them, but is that really necessary?
There is no font you can rely on being available on all platforms, and height/width ratios for different strings will differ for different fonts (fixed-width being slightly better). Additionally, things like different DPI settings will cause you headaches even if using the same font. I would rather reconsider whether your widgets really should be fixed size and you need those assumptions about the font size at all. In almost all cases, your UI will be more usable, readable and consistent with the rest of the desktop if you use flexible layouts and stick to whatever font and font size the platform suggests.
You can use QFont::setPixelSize to guarantee a consistent font size across platforms.
Since the goal is to keep a line of text label from drawing over and out of the window bounds, one solution is to adjust the font size used at runtime.
QFontMetrics provides boundingRect() family of calls to find how must space a text string will take when drawing in a given font. With those, you can test if the string can fit in the space. If it doesn't fit, reduce the font size and test again.

Resources