Programatically getting the version of a font in OSX - macos

When you look at information for a font in FontBook in OSX, it lists all kinds of useful information, including Language, Version, Unique name, etc. Is there a nice way to get any/all of this information from objective C? In particular, I want to get the Version of a font.
I know how to make a CTFontDescriptorRef but I don't see any attributes on it that would give me the Version. I've looked similarly at NSFontDescriptor but not found anything, and googling hasn't helped.
I need to do this because the app I work on runs in Chinese, and I know that one font looks better than another as long as I have a "late enough" version of the font installed. So I'd like to use a particular font if the later version is installed, and otherwise fall back to another font.

Well I stumbled upon the answer five minutes after posting. I was basically looking at the wrong place, hoping to find it in CTFontDescriptorRef. It looks like the right place to look is CTFontRef, which you can create from a CTFontDescriptor via CTFontCreateWithFontDescriptor.
Then you can use CTFontCopyAttribute, and a bunch of different things are available, namely kCTFontVersionNameKey.

Related

OS X support for custom image format?

I must just be blind - can anyone point to documentation or source code for how to write a software component that allows OS X to support a custom image format system wide? (I'd like to be able for applications like Preview to be able to display my custom images.) I seems like it must be possible, but I just can't find the documentation or an example. Thanks.
Edit: I have gotten some information that leads me to believe this isn't possible. I did see the Apple sample code about making a service to convert a file, but that isn't what I'm after. I will leave this open in case someone has faced this before and has found something I can't find.

Weird characters on mac

Since a few weeks whenever some app needs our password our needs our permission for something, it no longer displays it as understandable language, but with weird characters. How can we fix this?
It is probably a problem with your language for some inputs / options.
Look at this documentation about how to change your language for specific options:
http://support.apple.com/kb/PH11251
Depending on which version of OSX you are running, you might want to try Font Book (in the Applications folder) and specifically search for Look for Enabled Duplicates. Sometimes having duplicate or misnamed fonts can cause rendering problems like this.
There are other utilities as well, such as Font Doctor that can do similar (and more extensive) searches.

trying to call EnumFontFamilies(...) for a windows store app says it's undefined. Why is that? Are there any alternatives?

I'm trying to have a list of the fonts installed on a Surface.
However, even after including , I can't call EnumFontFamilies.
Why is that? How could I, and if I can't, what can I do to achieve similar functionnality.
Thanks.
From a thread on the Dev Center forums, it looks like you could do this via C++/DirectX as a WinRT component (the code here would be a start).
or take a look at Christophe Wille's WinRT snippets project on GitHub
EnumFontFamilies() is a winapi function. Very few of which you can use in a Store app, certainly not this one. Technically you can hack the macros that stop you from using the function but then you won't pass the Store validation.
You'll find font related methods in the Windows.Globalization.Fonts namespace, but not what you are looking for. Note the namespace name, WinRT no longer ignores the fact that the fonts that are available and usable on a machine have a lot to do with the language a user speaks. Or rather, the glyphs used in written text for that language. Arbitrarily picking in font just doesn't work well for the billions of people that live in Asia.

vb6 icon location on windows

Where can I find the orginal vb6 ( or windows ) icon? (.ico files)
I need, error, warning, question, and information icons which come up on the messagebox.
Thanks a lot.
As the icons can differ for each OS version, you can get the icons from Windows using LoadIcon() passing one of the standard icon IDs.
See http://msdn.microsoft.com/en-us/library/ms648072.aspx for details.
If you want them as .ico files, you can extract them (on your development machine) from user32.dll using a resource editor.
(Updated with corrected info from Cody Gray)
The standard Windows message box icons have changed many times across the various versions of Windows. They're included with a couple of the system DLL files, but you shouldn't try and extract them dynamically yourself. As I mentioned in a comment to another answer, the ID numbers are undocumented for a reason: namely because it's possible for them to change in future versions of Windows or even in future Windows updates. There's absolutely no reason to go through the effort trying to extract them, either. Windows will already retrieve them for you, if you ask nicely.
The nice way of asking is to use the LoadIcon function, and specify the IDI identifier of the icon you want. Windows will return an HICON value, or a handle to an icon resource.
Since you mention that you're using VB.NET, you can also use the SystemIcons class, which has static properties to return any of the common icons. This is a .NET wrapper that saves you from having to P/Invoke the LoadIcon function from the Windows API yourself.
Better yet, if you just want to display a message box containing one of the icons, all you have to do is call the MessageBox API function. Tell Windows the MB_ICON value that you want, and you're off. As before, this has already been wrapped for you by the .NET Framework in the identically-named MessageBox class.
The benefit of both of these functions is that they'll always return the correct icons regardless of the current version of Windows. A comment made attempting to clarify the question seems to suggest that you want to use the old icons on a current version of Windows. But of course, you do not want to do this. The icons have been updated throughout the Windows shell for a good reason, and your application should take advantage of them. The new icons are more clear and fit in better with the overall system theme. Additionally, if your app still uses the old icons, it will be confusing to users and look very out of place. It's always best to follow standard platform conventions, rather than trying to do "something else", even if you think your "something else" is "better" for whatever reason than the platform default. Your users will not agree, and your application will reflect your shoddy craftsmanship.
Since people who ask this type of question inevitably disagree with me and insist that they must do it anyway, and that it is a "requirement" (whatever that means), I'll point out that the old icons are not available in the newer versions of Windows. The icons have been completely replaced throughout the system for a reason. It's also strictly forbidden by the licensing agreements to extract icons from system DLL files and redistribute them with your application. Don't do this.
Also, before deciding on which icon you should display in your message box, be sure to consult Microsoft's Windows User Experience Interaction Guidelines, which provide some very handy rules on selecting the proper icon to convey the right message and fit with the Windows tone. I provide more information on that in my answer here; very much recommended reading for any Windows application developer.
Edit: It's like pulling teeth to get any more details on this question. I'm not sure why you're so secretive about what you're trying to accomplish, but note that in the future, you'll have a lot better luck including these things in your question to start with, rather than hoping people will pull it out of you. Most people aren't nearly as persistent as I am.
Anyway, you finally mention that you're doing some type of interop between VB 6 code and .NET code. That should not be relevant in the case of the message box icons used. The VB 6 MsgBox function is 100% equivalent to the Win32 API MessageBox function and the .NET MessageBox class that I discussed earlier. All of them are going to use the current system icons, and it shouldn't require any extra work to make them look the same. Ensure that you've passed the same icon specifier to all of the functions. Here's a table for convenience:
VB 6 "MsgBox" Icon Constant | VB.NET "MessageBox" Icon Identifier
---------------------------------------------------------------------------------
vbCritical | MessageBoxIcon.Error
vbQuestion | MessageBoxIcon.Question (DEPRECATED -- do not use)
vbExclamation | MessageBoxIcon.Warning
vbInformation | MessageBoxIcon.Information
Note that the "Question" style icon has since been deprecated and you should not use this value. If you're still using it in the VB 6 code, you should change that code to use a different icon (or no icon at all). The above-linked Windows User Experience Interaction Guidelines provide more details on why this icon has been deprecated and how to choose a suitable replacement.

mac look n feel on other platforms?

I'm just curious whether there is a gui framework that alloys you to use a mac look n feel on other platforms. presumably frameworks that use native APIs wouldn't be helpful (eg wxwidgets).
qt uses native API partially for mac look n feel, so that isn't useful.
what about swing?
In general, don't do this. Different platforms have different conventions, and your software should follow its platform's conventions to minimize the cognitive load of the user.
Unless, I guess, you're the only person who you ever expect to use it.
Legally, you can't create the Mac look and feel on another platform. Apple owns the copyrights to it.
However, the Quaqua Java Look-and-feel implements Java widgets that have that look-and-feel. If you have a good reason to use it in a non-commercial way, it may be a solution.
Every operating system and desktop manager has a different way of implementing GUI elements. Trying to port an application that will look exactly the same as OSX onto these platforms will be difficult if you're looking to use the native controls. Secondly, like Gred stated, each one will have their own way of doing things and could cause user issues by having unusal icons, symbols and controls displayed or missing.
Though if you would like to attempt this, one of the multi-platform web browsers such as FireFox might be able to give you some idea of how to carry over the same general look and feel over the platforms.
Good luck, and hope this helps some.
To answer the last question, Swing does not ship with the Mac look and feel on platforms that aren't Mac-based. This also applied to the other platform-specific look and feel elements.
While not the greatest solution, for Java, the Nimbus L&F is a good alternative... but since it's now included in Java (as of 6u10), it's not available separately any more.
You can implement your own style in Qt [and probably GTK*] to attempt to look the same (see QStyle). However it probably isn't worth the time and effort and will piss off some users. There are some windows themes that attempt to mimic the look. I know the new version of parallels ships with something like that, but it looks rather funny as the margins, spacing, font, etc is completely wrong.

Resources