I'm trying, for the first time, to create a GUI in Ruby using Tk. I've copied a code snippet from one of the numerous web tutorials and try to change the font for one of the labels, but nothing seems to affect how the text is presented.
Here's the code:
require 'tk'
root = TkRoot.new('title'=>'MCIS')
defaultFont = TkFont.new("weight"=>'bold', "size"=>20)
Lbl = TkLabel.new(root) do
text "Boooo"
borderwidth 5
font defaultFont
foreground "red"
relief "groove"
grid('column'=>3, 'row'=>0)
end
Tk.mainloop()
I see the effects of all the parameters of the label but not the font. I've tried to change the size, the weight, give different family names, leave just one parameter; nothing works - the font stays default as it was. Surprisingly it doesn't report any errors, everything looks fine. Maybe it's versions problem? I run these:
Linux Centos 5
Tk 8.4.13
Ruby 1.8.5
ruby-tcltk 1.8.5
Also, don't know if it is important, I ran it via Xming from WinXP machine.
When I ran the above code it works as expected on my linux desktop with a connected display. If I had to guess, I'd say that Xming has extremely limited font support, maybe only supplying a handful of bitmapped (read: non-scaleable) fonts.
So, I would say the code is correct and the problem is related to the X server configuration.
Related
In this screenshot of my vimrc settings, I have installed the plugin vim-airline using vundle. After going through airlines docs, I found the set of lines to customise my airline.
The problem is the ones highlighted in red. The blue highlighted one works fine but the red one does not. The left one is same as right one. I tried using different Unicode symbols but does not work. Any workaround to this situation as this is troubling my OCD :P.
Thanks in advance.
This is a well-known issue related to the font (size and family) used in your terminal.
For a better display, you have two solutions:
Do not use arrows as separators
Configure your terminal emulator to use a patched font with the right size
If you prefer the first solution, make sure you have this code in your .vimrc:
let g:airline_right_sep = ""
let g:airline_left_sep = ""
If you prefer the other solution, take a look at this: https://github.com/powerline/fonts
I have used the Hack font with size 11 for a long time and the arrows are perfectly displayed in my editor...
I have a Matlab program where I need to include a plane icon (Zapf Dingbats 40) in the plot. Everytime I run it, it falls back to a system font.
Is there anything that I am doing wrong? This is not the exact code, but illustrates the problem:
title(char(40),'fontname','ZapfDingbats','fontsize',50);
The resulting plot always displays ( instead of the Dingbats plane icon ✈.
I verified that the font is installed and I can type with it on Word.
I am using Matlab R2013b on Mac OSX 10.9.1.
EDIT: It prints correctly to a pdf, but does not display correctly.
You may use the 'Wingdings' font for that. The following code
text(0.5, 0.5, char(81), 'fontname', 'Wingdings', 'fontsize',50);
gives
The 'ZapfDingbats' font may not be in the /Library/Font folder (but 'Wingdings' is), even if listfonts tells you that the font is there. Actually, the listfonts
function adds some extra fonts to the list of the available fonts, and I don't get the rational of that.
% always add postscipt fonts to the system fonts list.
systemfonts = [fonts;
{
'AvantGarde';
'Bookman';
'Courier';
'Helvetica';
'Helvetica-Narrow';
'NewCenturySchoolBook';
'Palatino';
'Symbol';
'Times';
'ZapfChancery';
'ZapfDingbats';
}];
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
This is a weird situation. In Xcode's IB, I have a NSTableCellView subclass that I've built. It looks like this:
And when I run the app on my Mac, it comes out exactly as I would expect:
However, if any other Mac runs my app, every text field drops by something between 5-10 pixels:
Notice how the image view on the top right, and the hairline separator remain correctly positioned. This is just the text fields.
My brain balks at solving this because I can't guess what the cause is: my Mac is retina (hence right now the larger-looking image from my Mac) but I spend most of my time developing on a non-retina LED cinema display. I've tested this on three other Macs than my own, and the results are the same; it seems my own Mac is the outlier.
Any guesses as to the cause of this layout discrepancy?
UPDATE: I am using springs and struts to lay out the app. But I also tried using AutoLayout on one of my NIBs in case that was related. But the results were identical.
Found the answer! Turns out I had an additional copy of Avenir installed on my Mac which nobody else had. That Avenir has different metrics associated with it, and once I disabled the non-system-provided Avenir, my Mac is now showing the same screwed-up layout as every other computer does. Yay?
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.