FluText.qml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import QtQuick
  2. import QtQuick.Controls
  3. import FluentUI
  4. Text {
  5. enum FontStyle {
  6. Display,
  7. TitleLarge,
  8. Title,
  9. SubTitle,
  10. BodyStrong,
  11. Body,
  12. Caption
  13. }
  14. property int fontStyle: FluText.Body
  15. property color textColor: FluTheme.dark ? FluColors.White : FluColors.Grey220
  16. property int pixelSize : FluTheme.textSize
  17. id:text
  18. color: textColor
  19. renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
  20. font.bold: {
  21. switch (fontStyle) {
  22. case FluText.Display:
  23. return true
  24. case FluText.TitleLarge:
  25. return true
  26. case FluText.Title:
  27. return true
  28. case FluText.SubTitle:
  29. return true
  30. case FluText.BodyStrong:
  31. return true
  32. case FluText.Body:
  33. return false
  34. case FluText.Caption:
  35. return false
  36. default:
  37. return false
  38. }
  39. }
  40. font.pixelSize: {
  41. switch (fontStyle) {
  42. case FluText.Display:
  43. return text.pixelSize * 4.857
  44. case FluText.TitleLarge:
  45. return text.pixelSize * 2.857
  46. case FluText.Title:
  47. return text.pixelSize * 2
  48. case FluText.SubTitle:
  49. return text.pixelSize * 1.428
  50. case FluText.Body:
  51. return text.pixelSize * 1.0
  52. case FluText.BodyStrong:
  53. return text.pixelSize * 1.0
  54. case FluText.Caption:
  55. return text.pixelSize * 0.857
  56. default:
  57. return text.pixelSize * 1.0
  58. }
  59. }
  60. }