如何在 Eclipse 中更改行高/行距?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1014454/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:47:53  来源:igfitidea点击:

How can I change line height / line spacing in Eclipse?

eclipseideeditor

提问by Vamsee

I am using Eclipse for Java programming but lines in the editor look too close together.

我正在使用 Eclipse 进行 Java 编程,但编辑器中的行看起来太靠近了。

I want to change the amount spacing/gap between lines. Is there an option in Eclipse that I can use to do this?

我想更改行之间的间距/间距。Eclipse 中是否有可以用来执行此操作的选项?

回答by josef.van.niekerk

I've cloned and installed the font from

我已经克隆并安装了字体

https://github.com/andreberg/Meslo-Font

https://github.com/andreberg/Meslo-Font

and made it my IDE editor font for Eclipse. Line spacing is much better now!

并将其作为 Eclipse 的 IDE 编辑器字体。行距现在好多了!

回答by Alex Salauyou

After trying various alternative fonts, I've took original Consolasand increased line height in font editor, installed resulting ConsolasHighfont package into system and set it as default in Eclipse editor:

在尝试了各种替代字体后,我Consolas在字体编辑器中采用了原始和增加的行高,将生成的ConsolasHigh字体包安装到系统中,并在 Eclipse 编辑器中将其设置为默认值:

enter image description here

在此处输入图片说明

Check out: https://github.com/Salauyou/Consolas-High-Line

退房:https: //github.com/Salauyou/Consolas-High-Line

回答by steamer25

You could configure a formatter (Preferences | Java | Code Style) to inject extra empty lines. Otherwise, you might be able to find a font (Preferences | General | Appearance | Colors and Fonts) with a lot of built-in whitespace. On Windows, I like 'consolas'--it's not particularly whitespace-y but it is a nice mono-spaced, readable font.

您可以配置一个格式化程序(Preferences | Java | Code Style)来注入额外的空行。否则,您可能会找到带有大量内置空白的字体(首选项 | 常规 | 外观 | 颜色和字体)。在 Windows 上,我喜欢“consolas”——它不是特别的空白,但它是一种不错的等宽、可读字体。

回答by Phil Troy

Create your own bitmap font that uses all of the rows at the top of the font. It does work, and seems to save about up to 4 rows of pixels in a 17 point font. I did it as follows:

创建您自己的位图字体,使用字体顶部的所有行。它确实有效,并且似乎可以在 17 磅字体中最多保存 4 行像素。我是这样做的:

  • install otf2bdf
    • go to font folder, presumably in root terminal
    • Clone your favorite font (presumably a truetype font) using otf2bdf to the size you want it
    • install fontforge
    • edit the font so that it uses all of the rows above the line for the capital letters
      • typically there are about 3 lines of pixels that are left blank and that is why there is so much space between rows
      • should you wish you can also uses some of the rows below the line but I think these are typically used for lower case letters like y which drop below the line (not so important when programming)
    • install the font by:
      • saving it into one of the font folders such as /usr/local/share/fonts
      • updating the font chache In a root terminal with fc-cache -f -v
    • use the new font
  • 安装otf2bdf
    • 转到字体文件夹,大概在根终端
    • 使用 otf2bdf 将您最喜欢的字体(大概是 truetype 字体)克隆到您想要的大小
    • 安装 fontforge
    • 编辑字体,使其使用该行上方的所有行作为大写字母
      • 通常有大约 3 行像素留空,这就是行与行之间有这么多空间的原因
      • 如果您希望您也可以使用该行下方的一些行,但我认为这些通常用于小写字母,例如 y 落在该行下方(编程时不太重要)
    • 通过以下方式安装字体:
      • 将其保存到字体文件夹之一,例如 /usr/local/share/fonts
      • 使用 fc-cache -f -v 在根终端中更新字体 chache
    • 使用新字体

回答by user736786

With respect to my response above, I can now provide more detail as to how to create the font, along with suggestions for creating a nicer font (starting with a truetype font):

关于我上面的回答,我现在可以提供有关如何创建字体的更多详细信息,以及创建更好字体的建议(从 truetype 字体开始):

  • Pick a truetype font you wish to use (I used an arial font)
  • Downloaded and install fontforge
  • Start fontforge and open the font file; I used a root terminal so that I could be sure to save the file in protected font folder
  • Select all the characters (Edit/Select/Select All)
  • Element Font Info PS Names
  • Specify names - I called it ArialMTVerticallyTighter; make sure you change all of the names on this tab or it may use the new font instead of the old font where you don't want it to
    • Element transformations transform
    • origin glyph origin
    • scale uniformly 120 %
      (more will be too big, use less if you want more spacing between lines)
  • Element General 1792 256 2048 Scale -142 150
  • OS/2 Metrics
    • Turn off is offset all over tab and t
    • Turn on really use typo metrics
    • 1792 512 1792 -512 0 1792 -512 0
  • File Generate Fonts - true type - into font folder - use new font name
  • File save (in case you screwed up so you can go back) to new name
  • Open new font file (in nautilus) with font viewer (by double clicking)
  • Install it
  • Start Eclipse
  • Set it as font in eclipse
    (window>preference>general>appearance>java editor>text font to new font)
  • 选择您想使用的 truetype 字体(我使用的是 arial 字体)
  • 下载并安装fontforge
  • 启动fontforge,打开字体文件;我使用了一个根终端,这样我就可以确保将文件保存在受保护的字体文件夹中
  • 选择所有字符(编辑/选择/全选)
  • 元素字体信息 PS 名称
  • 指定名称 - 我称之为 ArialMTVerticallyTighter;确保更改此选项卡上的所有名称,否则它可能会使用新字体而不是您不希望使用的旧字体
    • 元素变换变换
    • 起源字形起源
    • 统一缩放 120%
      (更多会太大,如果你想要更多的行间距,请使用更少)
  • 元素 一般 1792 256 2048 比例 -142 150
  • OS/2 指标
    • 关闭是整个选项卡和 t 偏移
    • 打开真正使用错字指标
    • 1792 512 1792 -512 0 1792 -512 0
  • File Generate Fonts - true type - 进入字体文件夹 - 使用新的字体名称
  • 文件保存(万一你搞砸了所以你可以回去)到新名字
  • 使用字体查看器(双击)打开新字体文件(在 nautilus 中)
  • 安装它
  • 启动日食
  • 在eclipse中设置为字体
    (window>preference>general>appearance>java editor>text font to new font)

Remember that the font size you see in eclipse for a particular setting e.g. 9 actually corresponds to about an 11 point font with less space between the lines

请记住,您在 eclipse 中针对特定设置(例如 9)看到的字体大小实际上对应于大约 11 磅的字体,行之间的间距较小

回答by Farmboy

you could put overly high characters in some comment somewhere, try "|?ág$??????????ДАБψ". As soon as Eclipse sees this in a file, it'll increase the line-separation for the whole file to properly display thos characters.

您可以在某些评论中放置过高的字符,请尝试“|?ág$??????????ДАБψ”。一旦 Eclipse 在文件中看到它,它就会增加整个文件的行分隔以正确显示这些字符。

回答by Andrew Niefer

On linux with gtk you can also play with a .gtkrc file. See hereand hereas examples.

在带有 gtk 的 linux 上,您还可以使用 .gtkrc 文件。请参阅此处此处作为示例。

Of course this doesn't help anything on windows :)

当然,这对 Windows 没有任何帮助:)