Fonts 如何在Pango和Mono中设置文件字体
我有一个简单的应用程序,可以打印文本并确定其大小(以像素为单位)Fonts 如何在Pango和Mono中设置文件字体,fonts,mono,cairo,pango,Fonts,Mono,Cairo,Pango,我有一个简单的应用程序,可以打印文本并确定其大小(以像素为单位) static void Main(string[] args) { Application.Init(); var screen = Screen.Default; var layout = new Pango.Layout(PangoHelper.ContextGetForScreen(screen)); layout.FontDescription = new FontDescription
static void Main(string[] args)
{
Application.Init();
var screen = Screen.Default;
var layout = new Pango.Layout(PangoHelper.ContextGetForScreen(screen));
layout.FontDescription = new FontDescription();
layout.FontDescription.Family = "Times New Roman";
layout.FontDescription.Size = Units.FromPixels(18);
layout.SetText("My Text");
int width;
int height;
layout.GetPixelSize(out width, out height);
Console.WriteLine("{0} - width:{1} height:{2}", layout.Text, width, height);
Console.ReadLine();
}
但是我想用我自己的字体。如何从文件中加载自己的字体并在Mono的Pango中使用它?简短的回答是:您不能在Pango中使用卸载的字体:( 更长的答案是:如果您使用的是fontconfig后端(PangoFc; 在这种情况下,您需要先调用fontconfig 使用Pango,使字体可用于fontconfig。但是,我没有 认为Fontconfig有Mono绑定
所以,恐怕你在这里运气不好。这仍然是真的吗?有人教过关于“对fontconfig的几个调用”的教程。像往常一样,糟糕的GTK堆栈文档让我在这里丧命。