Questions tagged [nsfont]

NSFont objects represent fonts to an application, providing access to characteristics of the font and assistance in laying out glyphs relative to one another. Font objects are also used to establish the current font for drawing text directly into a graphics context, using the 'set' method.

74 questions
16
votes
5 answers

Adding a custom font to macOS app using Swift

I followed a bunch of tutorials but it doesn’t work: I simply want to add a custom font to a macOS app. What I tried essentially: Added the .ttf font-files to my project: Target Membership is set and I also made sure that the files are copied using…
ixany
  • 5,433
  • 9
  • 41
  • 65
9
votes
2 answers

What is the NSFont name for the font 'SF Mono'?

A new font titled 'SF Mono' was introduced with Xcode 8. It's a font that I personally find very readable, and I would like to use it in a NSTextView. However, to set a font for an NSTextView, it is required to use an NSFont object. The problem is…
perhapsmaybeharry
  • 874
  • 3
  • 13
  • 32
7
votes
1 answer

NSFont - How to get the right font?

I would like to make a NSFont to describe Arial, normal, 30pt in height. So far I have: NSNumber *weight = [NSNumber numberWithFloat:1.0]; NSNumber *slant = [NSNumber numberWithFloat:1.0]; NSDictionary *fontTraits = [NSDictionary…
Justin808
  • 20,859
  • 46
  • 160
  • 265
6
votes
2 answers

Check if NSFont is bold in Swift

I am writting unit test checking the format of a generated NSAttributedString. I can extract the font like this: if let font = attributedString.attributesAtIndex(0, effectiveRange: nil) as? NSFont { ... } Given this NSFont instance, how can I…
Martin Delille
  • 11,360
  • 15
  • 65
  • 132
6
votes
1 answer

Unable to add a custom font in Mac app (OSX 10.9+ Xcode5+)

I have gone through these SO posts: Embed font in a mac bundle Custom font in a Cocoa application I tried exactly same (rechecked multiple times), but I am not able to add a custom font to my Mac App. All details are shown in attached…
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
6
votes
2 answers

How to set font in NSTextView?

As simple as it seems, I simply CANNOT find ANY way to do that (setFont: is not working) : Have a NSTextView Set its font to some NSFont. Hint : (Pretty obvious, but whatever... ) IF the user adds any text, the new text is supposed to 'inherit'…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
4
votes
1 answer

What values can be used in NSFont.TextStyleOptionKey

I haven't been able to find valid values for NSFont.TextStyleOptionKey. More specifically I want to use NSFont.preferredFont(forTextStyle:options:) to have dynamic (dynamic point size) type, but I would like to change the weight of the font.
vicegax
  • 4,709
  • 28
  • 37
4
votes
1 answer

How to find the default font for East Asian character in MacOS

When using a text edit application, a font (such as "Menlo") is selected to present glyphs, when the selected font doesn't contain a special glyph(such as “”, it's a simple Chinese glyph, "Menlo" doesn't contain it), Application will pick up a font…
Qing
  • 313
  • 4
  • 15
4
votes
2 answers

10.9 replacement for [NSFont systemFontOfSize: weight:]

I would like to implement a replacement method for [NSFont systemFontOfSize:13 weight:NSFontWeightLight] that works on Mac OS 10.9 and 10.10. I can get the font descriptor by [[NSFont systemFontOfSize:13] fontDescriptor]. However, I could not figure…
Yoav
  • 5,962
  • 5
  • 39
  • 61
3
votes
4 answers

Name and size from NSFont

i've tried to find something in the Internet, but right now I don't have an answer, so it would be great if you can help me! So far I have a NSFont object, but I would like the name (as NSString) and size of the font, so I can output that! It's…
qwertz
  • 14,614
  • 10
  • 34
  • 46
3
votes
1 answer

Is there a mapping between NSFont.Weight and the integer values?

The NSFont API has two different ways to specify a weight. First, there is a struct NSFont.Weight which contains a floating point rawValue property. It's used in functions like: NSFont.systemFont(ofSize fontSize: CGFloat, weight: NSFont.Weight) ->…
Rob N
  • 15,024
  • 17
  • 92
  • 165
3
votes
1 answer

sizeWithAttributes gives the wrong height with NSFont on a mac when the point size is very small

I am working on a mac app that lets the user zoom pretty far in on the content. I need to measure the size of text that I render. When I scale the font for the zoom the point size of the font is very small (i.e. 0.001). When I use [NSString…
Stephen Johnson
  • 5,293
  • 1
  • 23
  • 37
3
votes
0 answers

Xcode plugin for selecting font?

Is there some handy Xcode plugin allowing us to select fonts the way ColorSense allows us to conveniently work with colors in code? Something that would e.g. display a font dialog and return the appropriate NSFont initializer call as text in the…
cacau
  • 3,606
  • 3
  • 21
  • 42
3
votes
3 answers

Change NSTextField's height according to Font/Size

Ok, here's my situation : I've got an NSTextField, set up as Multi-line Text Label The NSTextField is supposed to be holding just ONE line of text (even if it's a multi-line one) The NSTextField has a fixed height. The Font and Font Size are…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
2
votes
1 answer

How to create custom font at runtime using NSFont

I'm writing a Mac application that needs to be able to create, load, and use custom fonts at runtime using Cocoa. I've researched the NSFont class thoroughly, and all I can find is API's to load existing fonts and change simple parameters (E.G.…
exists-forall
  • 4,148
  • 4
  • 22
  • 29
1
2 3 4 5