我试图在我的 IMagick 项目中更改字体。我想使用自定义字体,但显然它不起作用!
这是我的代码:
PrivateFontCollection modernFont = new PrivateFontCollection();
modernFont.AddFontFile(path);
var readSettings = new MagickReadSettings()
{
FontFamily = "Walrus Bold",
FontPointsize = 130,
TextGravity = Gravity.Center,
StrokeColor = MagickColors.White,
StrokeWidth = 4,
BackgroundColor = MagickColors.Transparent,
Height = 150,
Width = 600
};
using (var image = new MagickImage(path))
{
using (var caption = new MagickImage($"caption:{idolname}", readSettings))
{
image.Composite(caption, textWidth + 90, textHeight + 155, CompositeOperator.Over);
image.Write(path);
}
}
我已经打印了字体的名称,就像modernfont.Families
方法中的那样。我尝试在其他东西中使用该字体并且它在那里工作。
任何人都知道我该如何实现它?