[TxMt] Re: tm_query --setting fontName
Allan Odgaard
mailinglist at textmate.org
Wed Jul 12 20:48:30 UTC 2017
On 12 Jul 2017, at 17:22, じょいすじょん wrote:
> The defaults keys you provided also do not exist by default on my
> system.
Correct, this would only be if the user has explicitly changed the
default fixed width font.
> Core Text and AppKit are both kind of vague.
> The solution there seems to be to start with a font and apply the
> fixed width trait to get a descriptor for a font that comes close to
> matching somehow (who knows how? personal taste?) or present a UI and
> let a user select something. Still does not give a default does it?
> How loopy these APIs can be :(
`NSFont` has a method to return the default fixed width font, from
Python you can use this code to obtain it:
#!/usr/bin/python
import objc
from AppKit import NSFont
font = NSFont.userFixedPitchFontOfSize_(0)
print("family: %s, name: %s, size: %.1f" % (font.familyName(),
font.fontName(), font.pointSize()))
On my system it prints:
family: Menlo, name: Menlo-Regular, size: 11.0
I deliberetly hardcoded the shebang to call `/usr/bin/python` as PyObjC
(the Cocoa bridge used here) may not be installed for a custom python on
the user’s system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20170712/0f3887e2/attachment.html>
More information about the textmate
mailing list