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

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

问题描述

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

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>

默认情况下它显示一种字体,我想将字体更改为Tahoma 10pt".

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

我该怎么做?

推荐答案

要更改字体,您可以为 #editor 添加 css 规则.或使用

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

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

但是 Ace 目前只支持等宽字体,而 tahoma 不是等宽字体,所以光标位置会出错.

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

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

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