Posts Tagged ‘fix’

Sub-pixel rendering in Mac OS X

Wednesday, May 5th, 2010

In OS X Snow Leopard, Apple changed the Appearances preferences so that you could either enable sub-pixel rendering (”font smoothing”) when available (i.e. if it detects that you are using an LCD monitor), or completely disable it. However, it can be a bit buggy, and often incorrectly recognises your LCD monitor as a CRT, thereby disabling sub-pixel rendering for fonts in newly started applications. Aside from the fact that it makes one’s eyes bleed, it’s also extremely irritating when half of your applications have sub-pixel rendering enabled – and the other half don’t. Let me give you an example:

With sub-pixel rendering enabled

Without sub-pixel rendering enabled

Without sub-pixel rendering enabled

Not nice. Fortunately the fix isn’t too hard; a single command in Terminal:

defaults -currentHost write -globalDomain AppleFontSmoothing -int 2

This command simply tells OS X to always use medium sub-pixel rendering, whether or not it thinks it is available. It’s fairly safe to just “set and forget”, as people very rarely use CRTs. Hopefully Apple will fix this bug properly, however, and this hack will no longer be needed.

Issues with C++ strings in OS X’s standard library

Monday, February 22nd, 2010

It seems that someone at Apple has turned on _GLIBCXX_FULLY_DYNAMIC_STRING in such a way that it is breaking _GLIBCXX_DEBUG builds. This means that (with some Xcode/GCC/OS X versions) if you try to use strings from the C++ standard library without enabling the _GLIBXX_FULLY_DYNAMIC_STRING preprocessor macro, your debug builds will have a runtime error similar to the following:

malloc: * error for object 0x10000a720: pointer being freed was
    not allocated * set a breakpoint in malloc_error_break to debug

In order to solve this issue from Xcode, you need to modify your build target information. Double-click your build target from the ‘Targets’ drop-down list in the left-hand column, navigate to the build tab, then scroll down to the ‘GCC – Preprocessing’ area, and enable fully dynamic strings by adding a new macro to the ‘Preprocessor Macros’ list: _GLIBCXX_FULLY_DYNAMIC_STRING=1

Feel free to leave a comment if you have any extra information on the issue (including fixes in newer versions/etc/etc).

References:
http://stackoverflow.com/questions/2234557/c-using-stdgetline-prints-pointer-being-freed-was-not-allocated
http://lists.apple.com/archives/cocoa-dev/2009/Sep/msg01199.html