How do I change the Font Style in ACE editor?

早过忘川 提交于 2019-12-03 11:09:18

问题


I am using ACE editor on my page,

<script src="ace-builds-master/src-noconflict/ace.js" type="text/javascript" charset="utf-8">
</script>
<script>
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/cobalt");
    editor.getSession().setMode("ace/mode/geco");
</script>

By default it is showing a font, I want to change my font to 'Tahoma 10pt'.

How do I do that?


回答1:


To change font you can either add a css rule for #editor. or use

editor.setOptions({
  fontFamily: "tahoma",
  fontSize: "10pt"
});

But Ace only supports monospace fonts for now, and tahoma isn't monospace, so cursor position will be wrong.




回答2:


To my knowledge there is no shortcut to directly change Ace's font family other than editor.setOptions().

However you can set the font size in pixels directly by calling:

editor.setFontSize(10) // will set font-size: 10px


来源:https://stackoverflow.com/questions/21900938/how-do-i-change-the-font-style-in-ace-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!