diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 20b5bca36..b046bef30 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -567,9 +567,9 @@ describe "RootView", -> editor = null beforeEach -> editor = rootView.getActiveEditor() + editor.attachToDom() it "increases/decreases font size when increase/decrease-font-size events are triggered", -> - editor = rootView.getActiveEditor() fontSizeBefore = editor.getFontSize() rootView.trigger 'window:increase-font-size' expect(editor.getFontSize()).toBe fontSizeBefore + 1 diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a4dd22579..47517e043 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -682,29 +682,30 @@ class Editor extends View autosave: -> @save() if @getPath()? - setFontSize: (@fontSize) -> + setFontSize: (fontSize) -> headTag = $("head") styleTag = headTag.find("style.font-size") if styleTag.length == 0 styleTag = $$ -> @style class: 'font-size' headTag.append styleTag - styleTag.text(".editor {font-size: #{@fontSize}px}") + styleTag.text(".editor {font-size: #{fontSize}px}") @redraw() - getFontSize: -> @fontSize + getFontSize: -> + parseInt(@css("font-size")) - setFontFamily: (@fontFamily) -> + setFontFamily: (fontFamily) -> headTag = $("head") styleTag = headTag.find("style.font-family") if styleTag.length == 0 styleTag = $$ -> @style class: 'font-family' headTag.append styleTag - styleTag.text(".editor {font-family: #{@fontFamily}}") + styleTag.text(".editor {font-family: #{fontFamily}}") @redraw() - getFontFamily: -> @fontFamily + getFontFamily: -> @css("font-family") redraw: -> return unless @attached