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

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

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

gulp-iconfont: Iconfont rendering wildly different on Windows

I can't for the life of me figure out why the same font that I build using gulp-iconfont renders so wildly different on Windows vs. basically all other OSes, including mobile OSes. I've tested practically all of them through Browserstack, and consistently all browser running on Windows render the font with a massive amount of space above/below each icon while all other platforms render as expected.
I highlighted the elements using the inspector for the following screenshots:
Windows:
macOS:
I think I have narrowed it down to be the font rendering, as when I change the font-family in the css, the spacing around the characters evaporates. I have messed around with the gulp-iconfont options (fontHeight is set to 1024 and font is being normalized) without success.
Is my only option to let go of compiling my own iconfont and just using svg's, or does anyone know what I might be doing wrong? I feel the stench of defeat upon me so any faint scent of hope would make me simmer with joy.

html fonts look jagged... photoshop vs html/css version

Is it normal that fonts I used to create site layout are pixelated? I use Georgia, and in photoshop I've smooth lines everything looks great. But when I tried to slice it up and code the css, Georgia font same size looks noticeably uglier!
What are your thoughts?
p.s. I use em to declare sizes in css.
That's because photoshop is using anti-alias technique on text.
Both OS and browser will impact the appearance of text in web page.For example, Mac OS has anti-alias text on all system UI. For windows, I believe they have an option called 'ClearType', once switched on all system UI will have smooth texts.
All fonts on the web will look a little pixellated unless you're on a Mac which renders type considerably better than PC.
The best way I have found to replicate how a font will look on the web is to set the Anitialiasing in Photoshop to 'sharp'.
It is conceivable that there will be CSS markup in the future that will allow antialiasing in the browser rather than OS based.
It is a common problem.
See this article
http://jontangerine.com/log/2007/10/smoothing-out-the-creases-in-web-fonts
The alternative is to use something like Cufon that generates images for your text. Best practice would be to only use it for headings.
http://cufon.shoqolate.com/generate/
I've found this too - each browser renders fonts differently. I often find fonts look much better in IE. Sometimes I opt to use images created in PS to get that smooth look, but for the most part I think people are used to how fonts are rendered in their browser of choice.
In photoshop, there's an option to "smooth" text.
See this image. Bottom right corner.
Remove this anti-alising to have a better view (but not exact) of how the font will look in browser.

QT Framework QML Application fonts too small on Mac OS X

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.

Resources