From 498f309d436a07cc96452a33162a0b579e007c39 Mon Sep 17 00:00:00 2001 From: gragrance Date: Mon, 4 Dec 2017 18:10:16 +0800 Subject: [PATCH] Font size changing did not take effect before restarting program --- Captuocr/RecognizeBoxViewModel.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Captuocr/RecognizeBoxViewModel.swift b/Captuocr/RecognizeBoxViewModel.swift index b887367..21ab031 100644 --- a/Captuocr/RecognizeBoxViewModel.swift +++ b/Captuocr/RecognizeBoxViewModel.swift @@ -16,9 +16,9 @@ class RecognizeBoxViewModel { extension RecognizeBoxViewController { func bindViewModel() { - if let setting = AppDelegate.container.resolve(Settings.self) { - textArea.font = NSFont.userFont(ofSize: CGFloat(setting.appearence.fontsize)) - } + combineLatest(viewmodel.recognizedText, viewmodel.image).observeNext { (_) in + self.performFontSize() + }.dispose(in: imageArea.reactive.bag) viewmodel.recognizedText.bind(to: textArea.reactive.string).dispose(in: layout.bag) viewmodel.image.map { (base64) -> NSImage? in if let data = Data(base64Encoded: base64, options: Data.Base64DecodingOptions(rawValue: 0)) { @@ -27,4 +27,10 @@ extension RecognizeBoxViewController { return nil }.bind(to: imageArea.reactive.image) } + + func performFontSize() { + if let setting = AppDelegate.container.resolve(Settings.self) { + textArea.font = NSFont.userFont(ofSize: CGFloat(setting.appearence.fontsize)) + } + } }