如何在ACE编辑器中更改字体样式? [英] How do I change the Font Style in ACE editor?

查看:1514
本文介绍了如何在ACE编辑器中更改字体样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上使用ACE编辑器,

 < 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>

默认情况下,它显示的是字体,我想将字体更改为 Tahoma 10pt。 / p>

我该怎么做?

解决方案

要更改字体,您可以要么为 #editor 添加一个CSS规则。
或使用

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

但是Ace目前仅支持等宽字体,而tahoma不是等宽字体,因此光标位置将是错误。


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?

解决方案

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.

这篇关于如何在ACE编辑器中更改字体样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆