Wednesday, April 22, 2009

Weird MATLAB behavior when using Consolas font


I mentioned earlier that the font Consolas from Microsoft is a great font for programming. I use it for all my programming, including MATLAB. Today I noticed that  the TeX characters do not display properly when using the ylabel function and Consolas and the font size is set to 7 or 8!!

For example:

>> set(0, 'DefaultAxesFontName', 'Consolas');
>> x = 1:10;
>> y = 1:10;
>> plot(x, y, '.-')
>> xlabel('xxxx^2', 'fontsize', 8)
>> ylabel('xxxx^2', 'fontsize', 8)





















Also try:

>> xlabel('xxxxxxxxxxxxx^2', 'fontsize', 8)
>> ylabel('xxxxxxxxxxxxx^2', 'fontsize', 8)





















It is interesting that only the ylabel is affected. It is also interesting that other font sizes (5, 6, 9, 10, 11, 12, 14) work fine with Consolas. Other fonts (e.g. Monospace, SansSerif, Courier New) work fine. So it might be related to ClearType fonts; But why just a specifc font size?

Weird...

I guess if needed I would use:

>> ylabel('xxxxxxxxxxxxx^2', 'fontsize', 8, 'fontName', 'Monospaced')

UPDATE 1: 

I submitted a bug report to The Mathworks and their application support were able to verify the bug (no work around at this time). 

I am wondering what causes such a behavior...

UPDATE 2:

I tested the bug on a Vista machine. Same result. The Calibri font behaves the same way. I guess it is related to ClearType fonts.

No comments:

Post a Comment