字符串中的下标字符

subscript characters in String

在我的 WPF C# 项目中,我使用 docX 库创建 word 文档。 有了这个 .NET 库,我可以创建字符串并将其作为段落添加到 docx 文件中。 我的docx需要有一些下标字符,例如:

Fb(b为下标)

我知道下标有Unicode字符和数字,但有些字符不包括在内。 那么,如何在 C# 字符串中添加该下标字符?

根据这个 How to write text as Subscript? DocX 论坛 post,您需要创建一个新的 Novacode.Formatting 对象。来自链接页面:

You need to create a new formatting and assign the values you want to the font.

Dim fotext As New Novacode.Formatting

fotext.Script = Script.subscript

p.InsertText("Text here", False,fotext)

p being the paragraph that you're wanting to insert text into.

在 C# 中,这将是这样的:

Novacode.Formatting fotext = new Novacode.Formatting();
fotext.Script = Script.subscript;
p.InsertText("Text here", false, fotext);