I need to render some text in my Metal app. Rather then doing it manually, I'd like to use Apple's text rendering API.
Calling this code in a simple empty window's drawRect
prints the string:
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,[NSColor blackColor], NSForegroundColorAttributeName, nil];
NSAttributedString * s = [[NSAttributedString alloc] initWithString:@"Hello!"
attributes: attributes];
[s drawAtPoint:NSMakePoint(300, 300)];
But this doesn't work in a window with a Metal view. I guess everything gets flushed?
Is it possible? And the same thing with displaying a button (NSButton) on top of a Metal view.
Thanks.