Delegate CustomFontSource
Delegate CustomFontSource
이름 공간 : Aspose.Imaging 모임: Aspose.Imaging.dll (25.5.0)
사용자 지정 문자 출처 공급자 기능
public delegate CustomFontData[] CustomFontSource(params object[] args)
Parameters
args
object
[ ] [ [ ]
그들의 논쟁들
Returns
CustomFontData [ ] [ [ ]
그림을 만드는 특정 글꼴 목록
Examples
이 예제는 특정 글꼴(s)을 사용하여 이미지 렌더링을 제공하는 사용자 지정 글꼴 출처를 보여줍니다. FontSettings.SetFontsFolders 방법과는 달리 이미지 범위에서 작동하고 여러 사용자 시나리오에서 글꼴을 제공 할 수 있습니다.
public void CustomFontSourceTest(string inputPath, string outputPath, string fileName, string fontPath)
{
var loadOptions = new Aspose.Imaging.LoadOptions();
loadOptions.AddCustomFontSource(GetFontSource, fontPath);
using (var img = Image.Load(System.IO.Path.Combine(inputPath, fileName), loadOptions))
{
Aspose.Imaging.ImageOptions.VectorRasterizationOptions vectorRasterizationOptions =
(Aspose.Imaging.ImageOptions.VectorRasterizationOptions)img.GetDefaultOptions(new object[] { Color.White, img.Width, img.Height });
vectorRasterizationOptions.TextRenderingHint = Aspose.Imaging.TextRenderingHint.SingleBitPerPixel;
vectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.None;
img.Save(System.IO.Path.Combine(outputPath, fileName + ".png"), new Aspose.Imaging.ImageOptions.PngOptions
{
VectorRasterizationOptions = vectorRasterizationOptions
});
}
}
// The custom fonts provider example.
private Aspose.Imaging.CustomFontHandler.CustomFontData[] GetFontSource(params object[] args)
{
string fontsPath = string.Empty;
if (args.Length > 0)
{
fontsPath = args[0].ToString();
}
var customFontData = new System.Collections.Generic.List<aspose.imaging.customfonthandler.customfontdata>();
foreach (var font in System.IO.Directory.GetFiles(fontsPath))
{
customFontData.Add(new Aspose.Imaging.CustomFontHandler.CustomFontData(Path.GetFileNameWithoutExtension(font), System.IO.File.ReadAllBytes(font)));
}
return customFontData.ToArray();
}</aspose.imaging.customfonthandler.customfontdata>