TextHelper.cs 804 B

1234567891011121314151617181920212223242526272829
  1. using System.Globalization;
  2. using System.Windows;
  3. using System.Windows.Media;
  4. namespace HandyControl.Tools.Helper;
  5. internal class TextHelper
  6. {
  7. public static FormattedText CreateFormattedText(string text, FlowDirection flowDirection, Typeface typeface, double fontSize)
  8. {
  9. #if NET40 || NET45 || NET451 || NET452 || NET46 || NET461
  10. var formattedText = new FormattedText(
  11. text,
  12. CultureInfo.CurrentUICulture,
  13. flowDirection,
  14. typeface,
  15. fontSize, Brushes.Black);
  16. #else
  17. var formattedText = new FormattedText(
  18. text,
  19. CultureInfo.CurrentUICulture,
  20. flowDirection,
  21. typeface,
  22. fontSize, Brushes.Black, DpiHelper.DeviceDpiX);
  23. #endif
  24. return formattedText;
  25. }
  26. }