Delegate CustomFontSource

Delegate CustomFontSource

Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)

커스텀 폰트 소스 제공자 함수

public delegate CustomFontData[] CustomFontSource(params object[] args)

매개변수

args object[]

인수입니다.

반환값

CustomFontData[]

이미지를 렌더링할 특정 폰트 목록입니다.

예제

이 예제는 이미지 렌더링을 위해 특정 폰트를 사용하기 위한 커스텀 폰트 소스 제공을 보여줍니다. FontSettings.SetFontsFolders 메서드와는 달리, 이는 이미지 범위 내에서 작동하며 다중 사용자 시나리오에서 폰트를 제공할 수 있습니다.```csharp [C#]

                                                                                                                                                                                                                                                 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
                                                                                                                                                                                                                                                         });
                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                 }

                                                                                                                                                                                                                                                 // 커스텀 폰트 제공자 예제.
                                                                                                                                                                                                                                                 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>
 한국어