如何在 Windows 上修改字体的样式属性?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17508/
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-15 11:06:30  来源:igfitidea点击:

How to modify the style property of a font on Windows?

windowsfonts

提问by Ashwin Nanjappa

Note that this question continues from Is it possible to coax Visual Studio 2008 into using italics for comments?

请注意,此问题继续从是否可以诱使 Visual Studio 2008 使用斜体进行注释?

If the long question title got you, here's the problem:

如果问题标题很长,问题就在这里:

How to convert the style property of the Consolas Italic font to Bold without actually modifying any of its actual glyphs? That is, we want the font to be still the same (i.e., Italic) we merely want the OS to believe that it's now a Bold font.

如何在不实际修改任何实际字形的情况下将 Consolas Italic 字体的样式属性转换为粗体?也就是说,我们希望字体仍然相同(即斜体),我们只是希望操作系统相信它现在是粗体字体。

Please just don't mention the name of a tool (Ex: fontforge), but describe the steps to achieve this or point to such a description.

请不要提及工具的名称(例如:fontforge),但请描述实现此目的的步骤或指向此类描述。

回答by Blorgbeard is out

Alright, I've successfully used FontForge to create a copy of Consolas (although this should work with any font) with the bold style actually being italics.

好的,我已经成功地使用 FontForge 创建了 Consolas 的副本(尽管这应该适用于任何字体),粗体样式实际上是斜体。

These are the steps that I followed:

这些是我遵循的步骤:

  • Install FontForge. It's a lot easier to do this on linux than on windows/cygwin. I used a Ubuntu VM ("sudo apt-get install fontforge").
  • Open Consola.ttf (the "normal" style font) in FontForge.
  • Select Element -> Font Info.
  • Change the Fontname, Family Name, and Name for Humans, all to the same thing. I used 'ConsolasVS'.
  • Click Ok. Click 'Yes' to let FontForge generate a new GUID for the font.
  • Select File -> Generate Fonts. Make sure you've got "TrueType" selected. Uncheck "Validate before saving". Click Save.
  • Now open Consolai.ttf (the italic style font) in FontForge.
  • Go back to Element -> Font Info.
  • Change the Font names as before, and where it currently says "Italic", change that to "Bold".
  • Go to the OS/2 tab, change the font weight to "700 Bold".
  • Go to the Mac tab, change the style set to Bold.
  • Click Ok. Allow a new GUID to be generated again.
  • File -> Generate Fonts, as before.
  • 安装FontForge。在 linux 上执行此操作比在 windows/cygwin 上容易得多。我使用了 Ubuntu VM(“sudo apt-get install fontforge”)。
  • 在 FontForge 中打开 Consola.ttf(“普通”样式字体)。
  • 选择元素 -> 字体信息。
  • 将 Fontname、Family Name 和 Name for Humans 更改为相同的内容。我使用了'ConsolasVS'。
  • 单击确定。单击“是”让 FontForge 为字体生成新的 GUID。
  • 选择文件 -> 生成字体。确保您选择了“TrueType”。取消选中“保存前验证”。单击保存。
  • 现在在 FontForge 中打开 Consolai.ttf(斜体样式字体)。
  • 返回元素 -> 字体信息。
  • 像以前一样更改字体名称,将当前显示为“斜体”的位置更改为“粗体”。
  • 转到 OS/2 选项卡,将字体粗细更改为“700 Bold”。
  • 转到 Mac 选项卡,将样式设置为粗体。
  • 单击确定。允许再次生成新的 GUID。
  • 文件 -> 生成字体,和以前一样。

Copy your two new ttf files into your \Windows\FONTS\ folder.

将您的两个新 ttf 文件复制到您的 \Windows\FONTS\ 文件夹中。

You can now have nice italic comments with Consolas in VS2008. Hooray!

您现在可以在 VS2008 中使用 Consolas 获得漂亮的斜体注释。万岁!

回答by DamienG

I did the italics-as-bold trick on Consolas back in July 2007 and posted a screenshot of it on my blog.

早在 2007 年 7 月,我就在 Consolas 上使用了斜体作为粗体的技巧,并在我的博客上发布了屏幕截图

I used FontLab which does a great job but a custom tool to copy and set the header would be the best bet as you can't modify and redistribute Consolas and FontLab costs $699.

我使用了 FontLab,它做得很好,但是复制和设置标题的自定义工具将是最好的选择,因为您无法修改和重新分发 Consolas,而 FontLab 需要 699 美元。

If you want to go down the FontLab route the open up the regular and italic versions and go into the File > Font Info... menu option and use the Names and Copyright section.

如果您想沿着 FontLab 路线走,请打开常规和斜体版本,然后进入文件 > 字体信息...菜单选项并使用名称和版权部分。

In there set them both fonts Family Name to a new name then flip the checkboxes on the italic version to indicate bold instead of italic and select Normal from the Weight list box and Italic in the Style Name list box.

在那里将它们的字体系列名称设置为新名称,然后翻转斜体版本上的复选框以指示粗体而不是斜体,并从粗细列表框中选择正常,在样式名称列表框中选择斜体。

Save and install :)

保存并安装:)

[)amien

[)阿米恩