mirror of
https://github.com/qvacua/vimr.git
synced 2024-10-28 12:11:55 +03:00
Add change font method
This commit is contained in:
parent
4075b49fa7
commit
9242dd8c47
@ -63,7 +63,8 @@ public class NeoVimView: NSView {
|
|||||||
self.descent = self.drawer.descent
|
self.descent = self.drawer.descent
|
||||||
self.leading = self.drawer.leading
|
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)
|
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) {
|
override public func setFrameSize(newSize: NSSize) {
|
||||||
super.setFrameSize(newSize)
|
super.setFrameSize(newSize)
|
||||||
|
|
||||||
|
@ -28,7 +28,10 @@
|
|||||||
|
|
||||||
- (void)setFont:(NSFont *)font {
|
- (void)setFont:(NSFont *)font {
|
||||||
[_font autorelease];
|
[_font autorelease];
|
||||||
|
|
||||||
_font = [font retain];
|
_font = [font retain];
|
||||||
|
[_fontTraitCache removeAllObjects];
|
||||||
|
[_fontLookupCache removeAllObjects];
|
||||||
|
|
||||||
// cf. https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/FontHandling/FontHandling.html
|
// cf. https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/FontHandling/FontHandling.html
|
||||||
CGFloat ascent = CTFontGetAscent((CTFontRef) _font);
|
CGFloat ascent = CTFontGetAscent((CTFontRef) _font);
|
||||||
|
@ -14,7 +14,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NeoVimViewDelegate {
|
|||||||
var neoVim: NeoVim!
|
var neoVim: NeoVim!
|
||||||
|
|
||||||
@IBAction func debugSomething(sender: AnyObject!) {
|
@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) {
|
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||||
|
Loading…
Reference in New Issue
Block a user