ExportFont.LinuxDefault.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #if WITHOUT_UNISCRIBE && !SKIA
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using FastReport.Fonts;
  6. using FastReport.Utils;
  7. namespace FastReport.Export.TTF
  8. {
  9. internal partial class ExportTTFFont
  10. {
  11. private TrueTypeFont GetTrueTypeFont(Font sourceFont)
  12. {
  13. return Config.FontCollection[sourceFont];
  14. }
  15. public void FillOutlineTextMetrix()
  16. {
  17. if (sourceFont != null)
  18. {
  19. TrueTypeFont font = GetTrueTypeFont(sourceFont);
  20. if (font != null)
  21. font.GetOutlineTextMetrics(ref textMetric);
  22. }
  23. }
  24. // libgdiplus version has no support for font fallback and returns one run.
  25. // Also support of complex scripts is almost non-existing.
  26. private List<RunInfo> LayoutString(string str, bool rtl, Font originalFont)
  27. {
  28. int maxGlyphs = str.Length * 3;
  29. var run = new RunInfo(maxGlyphs)
  30. {
  31. Font = originalFont,
  32. };
  33. for (int i = 0; i < str.Length; i++)
  34. {
  35. run.GlyphToUnicode[i] = str[i].ToString();
  36. }
  37. TrueTypeFont font = Config.FontCollection[sourceFont];
  38. if (rtl)
  39. font.Script = "arab";
  40. int actualLength = font.GetGlyphIndices(str, sourceFont.Size / 0.75f, out run.Glyphs, out run.Widths, out run.Kernings, rtl);
  41. Array.Resize<ushort>(ref run.Glyphs, actualLength);
  42. Array.Resize<string>(ref run.GlyphToUnicode, actualLength);
  43. Array.Resize<float>(ref run.Widths, actualLength);
  44. Array.Resize<float>(ref run.Kernings, actualLength);
  45. List<RunInfo> result = new List<RunInfo>();
  46. result.Add(run);
  47. return result;
  48. }
  49. private void InternalInit()
  50. {
  51. dpiFX = 1;
  52. }
  53. partial void InternalDispose();
  54. }
  55. }
  56. #endif