Why same font size show different actual size in different editors? - macos

Environment: Mac OS El Capitan; MBP 2012-Mid 15'.
Same problem on both built-in LCD and external LCDs. I have tried with 3 external monitors. Also same problem on another MBP with Retina internal LCD. Also, same problem occurs no matter the resolution is scaled, not scaled, or HiDPI.
As the screenshot shows, same font name + same font size + same text + same screen has different visual width in different text editors. I have tried to tune one of the font size to be like 14.1/13.9/etc, but not works, the text is either too small/narrow or too big/wide; what's more, some editors cannot use fraction font size.
Q1: How to show exactly same visual size for same font size?
Q2: Looks like there are two font rendering engines in the OS? If yes, how to specify which one to use for specified app or for all apps?
Thanks a lot.

Related

Different QTextEdit line height on Mac and Windows

I am developing a text editor application based on QTextEdit/QGraphicsTextItem and noticed that the results of QTextEdit on Windows are different to the ones on Mac.
Specifically, when testing with a multi line text snippet in the "Text Edit" sample of Qt 4.8.5:
When using large font sizes (48pt) the text layout is pretty much identical
When using small font sizes (8pt) the text snippet has a noticeably larger height on Windows
I've found a couple of related StackOverflow questions but didn't find a suitable answer in them. Thus I tried to dig deeper and figured out the following:
Font size 48pt: the line height on Mac and Windows are very close to each other (both about 60%)
Font size 8pt: the line height on Mac is about 50%. On Windows it is about 75%
When referring to "line height" I compared the ascent height (i.e. height of "T") against the height between them (between two text lines).
Here is a screenshot showing the problem. The red lines are the base lines of the Mac text lines.:
It seems that the line height causes the text layout to be different on Mac and Windows. Is there any way in Qt to enforce an identical text layout on Mac and Windows (Microsoft Word manages to do so)? Or does anybody have other suggestions about this?
If I'm not mistaken, Qt 4.8 in Mac uses system rendering engine & Windows and other platform uses Harfbuzz. Qt 5.X uses Qt Harfbuzz for all platforms. Two different rendering engine not likely to have same rendering out put. Try with Qt 5.2 if you can.

Matlab GUI Compatibility Between Mac and Windows (Display)

For some time now, I've been working on a series of GUIs. I use a Mac running OSX to write all of my code, and the problem I've encountered is that it there are deviations in appearance when the GUIs are used in windows, some of which are minor, and some of which are very significant.
1) The text in the windows version is substantially larger overall. This results in some of my button titles simply going off the button, or panel titles moving beyond the panel.
2) Axes appear to be different dimensions between Mac and Windows. i.e. An axis that appears square on my Mac will appear elongated or rectangular on windows, and vice versa.
3) Graphical displays are different. This is the real problem. Some of my GUIs use axes to display text and model chemical reaction animations. On the Mac, they look perfectly fine, but on the windows system, the sizing is completely off.
I've set all "Units" to "characters" as suggested by the Mathworks help page, and I do not specify any fonts to allow each system to use its default. I have however, specified font sizes, but apparently, 12 point font on windows appears very different from 12 point font on mac.
Are there any ways around these problems? I thought setting a specified font size and allowing for use of default fonts would fix this, but it hasn't, and I'm a little dry for ideas at this point.
Try working in 'pixels' or absolute size units instead of 'characters', and apply a scaling factor to your font sizes.
Setting 'Units' to 'characters' is probably the wrong way to go for portability, and could be the main cause of your display sizing issues. Which specific Matlab page recommended that you do so? Was it talking about cross-platform portability? The characters unit is very convenient to work with, but it is tied to the font metrics for the default system font. (See the doco for Units property at http://www.mathworks.com/help/matlab/ref/axes_props.html). That's going to differ between different operating systems. Working with 'pixels' or inches/centimeters/points, which are absolute, will probably give you more uniform results across operating systems.
And you're not wrong: OS X tends to display fonts of a given size on screen smaller than Windows does. (Generally; YMMV depending on your display DPI and system settings and other things.) For example, I run my terminals and text editors at 10 or 12 points in Windows, but 14 point or larger on Mac. So apply a scaling factor to the font sizes you set in your GUI. Figure out what looks good on Mac, and then scale it in your code to something like windows_font_size = floor(mac_font_size * 0.8) and see how it goes.
If you want to be more precise in scaling, you could grab the ScreenPixelsPerInch and ScreenSize root properties with get(0,...). You may also be able to call down in to Java code to get precise font metrics info to help with font scaling choices.
Either way, you're going to have to test your code on both systems instead of just expecting it to work portably. If you don't have ready access to a Windows development system, consider setting up a Windows VM on your Mac. With file sharing between the two sides, you'll be able to try your code out on both platforms right as you work with it.
I encountered this problem as well.
Calling this function within the FUNCTIONNAME_OpeningFcn might alleviate your issues:
function decreaseFontSizesIfReq(handles)
% make all fonts smaller on a non-mac-osx computer
persistent fontSizeDecreased
fontSizeDecreased = [];
if ~ismac()
% No MAC OSX detected; decrease font sizes
if isempty(fontSizeDecreased)
for afield = fieldnames(handles)'
afield = afield{1}; %#ok<FXSET>
try %#ok<TRYNC>
set(handles.(afield),'FontSize',get(handles.(afield),'FontSize')*0.75); % decrease font size
end
end
fontSizeDecreased=1; % do not perform this step again.
end
end

WP7 - Splash Screen doesn't display correctly on launch

What I'm trying to do:
I've added a splash screen to an application I'm creating for Windows Phone 7. I did this simply by replacing the pre-existing splash screen file with my own.
What goes wrong:
The splash screen is not displayed like it should be - it is being down sampled to an 8 bit image or something weird:
-
The image I'm using
-
The image that gets displayed
It's a bit hard to see depending on your monitor, but on a phone it's reasonably obvious. There are fuzzy greenish lines that appear - basically like the image is being down sampled or the quality worsened.
Any idea what I'm doing wrong, or what might be happening?
Thanks.
Try forcing the app to display images at 32 bits per pixel (instead of the default of 16)
Add an attribute of BitsPerPixel="32" to the app element in WMAppManifest.xml
See http://forums.create.msdn.com/forums/p/85960/520394.aspx#520394
The problem is that the gradient on your splash screen is causing banding, which you can solve by dithering. Robby Ingebretsen has an action for PhotoShop that you can use: http://nerdplusart.com/photoshop-action-for-windows-phone-7-dithering
I suspect the emulator. Run the emulator at full size or run the app on an actual device.
Windows Phone is currently only supporting a color depth of 16bit, causing especially some gradients displaying downsampled for 24bit images. Some first generation firmwares by HTC had a "bug" that also allowed 24bit. Theoretically it is just a registry key, but you cannot commonly change it. Microsoft has limited the color depth to 16bit for the benefit of performance, but as far as I knnow there are some second-generation models without this limitation now.
You may try to downsample the image in Photoshop to 16bit and optimize it for this color depth.

How to change the Icon of a MFC-Application without changing each sub-image?

when I open the application icon of a MFC-project with Visual Studio 2008 there are 13 images (different sizes, different color palette). How would you change the icon of your MFC-application without changing each image?
Thanks!
I like to use the Icons file type extension with Paint.NET. When you open a .ICO file it will prompt you for which image to open - select only the largest / highest-bit image. Make your changes, and then save. You will be prompted for which sizes and bitness to save - select the same list that was present in the original icon.
Using this method, you will get automatically scaled and dithered icons at the smaller sizes. A designer would actually tweak the icons at each size to get the best look, but for most applications this technique produces something that is usable.
An icon resource typically contains many different versions of an icon. For an application icon you would expect 16x16, 32x32, 48x48 and 256x256. You'd also expect to see the 3 smaller ones at 32 bit colour, 8 bit colour 4 bit colour. Or some variant on that. Microsoft publishes guidelines.
Why so many different versions of the same icon?
Well, the icon will be drawn in different settings. On a window caption bar, the 16px version will typically be shown. On the Windows 7 taskbar the 48px version will be shown. When usint ALT+TAB in XP the 32px will be shown. In Vista/7 explorer with ultra large icon view, the 256px will be shown.
To obtain the best visual appearance you must have different versions of the image for different sizes because small raster images aren't easy to scale. What's more, you may present a slightly different version of the icon at different resolutions. For example you may use 3D effects only on larger resolution, partial transparency versions.
When using remote desktop, lower colour depths may be used if the connection is bandwidth challenged.
The MS guidelines go into these issues in detail.
The normal practice of for the graphic designer to design the icon and once you are happy with it the designer will produce rasterised versions for all the required sizes and colour depths, typically in a single .ico file.

Why flash on Mac does not display font correctly?

We have standard flex 3 project, and We have left everything as default, no change in style at all, and we deployed our project and noticed that on Mac the character spacing is very bad and overall look and feel is not as clear as that of windows.
Here is the difference, left one is Windows and right one is Mac.. the default flex font chosen by Adobe is "Verdana", the left one looks pretty, but right one looks as its width and character spacing, everything is incorrect. I assume verdana font may not be available on Mac, but in that case I supposed adobe should have given default standard font of good quality.
alt text http://akashkava.com/images/MacFlashFontProblem.png
What can we do to resolve this? Will embedding Verdana font in flex project style will help?
Mac OS X and Windows have different text rendering engines. I've heard it said that Mac OS X tries to preserve the character shape while Windows tries to align with screen pixels at small sizes.
That's going to result in differences between how fonts are rendered, and there's really no way to work around it.
Personally, I think the example on the right looks much nicer; the one on the left looks square, like it's being rendered at too small a size, while the one on the right looks more like the font is supposed to look.
It's not a solution, but Verdana is available on every OS X box. See this Apple doc for 10.5; I couldn't find one on 10.6 but there is one.

Resources