1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-10-28 03:38:54 +03:00

Add change font method

This commit is contained in:
Tae Won Ha 2016-07-06 19:51:31 +02:00
parent 4075b49fa7
commit 9242dd8c47
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 16 additions and 2 deletions

View File

@ -63,7 +63,8 @@ public class NeoVimView: NSView {
self.descent = self.drawer.descent
self.leading = self.drawer.leading
// FIXME: resize and redraw
// We assume that the font is valid, eg fixed width, not too small, not too big, etc..
self.resizeNeoVimUiTo(size: self.frame.size)
}
}
@ -108,6 +109,15 @@ public class NeoVimView: NSView {
Swift.print(self.grid)
}
public func setFont(font: NSFont) {
guard font.fixedPitch else {
return
}
// FIXME: check the size whether too small or too big!
self.font = font
}
override public func setFrameSize(newSize: NSSize) {
super.setFrameSize(newSize)

View File

@ -28,7 +28,10 @@
- (void)setFont:(NSFont *)font {
[_font autorelease];
_font = [font retain];
[_fontTraitCache removeAllObjects];
[_fontLookupCache removeAllObjects];
// cf. https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/FontHandling/FontHandling.html
CGFloat ascent = CTFontGetAscent((CTFontRef) _font);

View File

@ -14,7 +14,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NeoVimViewDelegate {
var neoVim: NeoVim!
@IBAction func debugSomething(sender: AnyObject!) {
self.neoVim.xpc.resizeToWidth(35, height: 13)
let font = NSFont(name: "Courier", size: 14)!
self.neoVim.view.setFont(font)
}
func applicationDidFinishLaunching(aNotification: NSNotification) {