fonts.tcl 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #
  2. # Font specifications.
  3. #
  4. # This file, [source]d at initialization time, sets up the following
  5. # symbolic fonts based on the current platform:
  6. #
  7. # TkDefaultFont -- default for GUI items not otherwise specified
  8. # TkTextFont -- font for user text (entry, listbox, others)
  9. # TkFixedFont -- standard fixed width font
  10. # TkHeadingFont -- headings (column headings, etc)
  11. # TkCaptionFont -- dialog captions (primary text in alert dialogs, etc.)
  12. # TkTooltipFont -- font to use for tooltip windows
  13. # TkIconFont -- font to use for icon captions
  14. # TkMenuFont -- used to use for menu items
  15. #
  16. # In Tk 8.5, some of these fonts may be provided by the TIP#145 implementation
  17. # (On Windows and Mac OS X as of Oct 2007).
  18. #
  19. # +++ Platform notes:
  20. #
  21. # Windows:
  22. # The default system font changed from "MS Sans Serif" to "Tahoma"
  23. # in Windows XP/Windows 2000.
  24. #
  25. # MS documentation says to use "Tahoma 8" in Windows 2000/XP,
  26. # although many MS programs still use "MS Sans Serif 8"
  27. #
  28. # Should use SystemParametersInfo() instead.
  29. #
  30. # Mac OSX / Aqua:
  31. # Quoth the Apple HIG:
  32. # The _system font_ (Lucida Grande Regular 13 pt) is used for text
  33. # in menus, dialogs, and full-size controls.
  34. # [...] Use the _view font_ (Lucida Grande Regular 12pt) as the default
  35. # font of text in lists and tables.
  36. # [...] Use the _emphasized system font_ (Lucida Grande Bold 13 pt)
  37. # sparingly. It is used for the message text in alerts.
  38. # [...] The _small system font_ (Lucida Grande Regular 11 pt) [...]
  39. # is also the default font for column headings in lists, for help tags,
  40. # and for small controls.
  41. #
  42. # Note that the font for column headings (TkHeadingFont) is
  43. # _smaller_ than the default font.
  44. #
  45. # There does not appear to be any recommendations for fixed-width fonts.
  46. #
  47. # X11:
  48. # Need a way to tell if Xft is enabled or not.
  49. # For now, assume patch #971980 applied.
  50. #
  51. # "Classic" look used Helvetica bold for everything except
  52. # for entry widgets, which use Helvetica medium.
  53. # Most other toolkits use medium weight for all UI elements,
  54. # which is what we do now.
  55. #
  56. # Font size specified in pixels on X11, not points.
  57. # This is Theoretically Wrong, but in practice works better; using
  58. # points leads to huge inconsistencies across different servers.
  59. #
  60. namespace eval ttk {
  61. variable tip145 [catch {font create TkDefaultFont}]
  62. catch {font create TkTextFont}
  63. catch {font create TkHeadingFont}
  64. catch {font create TkCaptionFont}
  65. catch {font create TkTooltipFont}
  66. catch {font create TkFixedFont}
  67. catch {font create TkIconFont}
  68. catch {font create TkMenuFont}
  69. catch {font create TkSmallCaptionFont}
  70. if {!$tip145} {
  71. variable F ;# miscellaneous platform-specific font parameters
  72. switch -- [tk windowingsystem] {
  73. win32 {
  74. # In safe interps there is no osVersion element.
  75. if {[info exists tcl_platform(osVersion)]} {
  76. if {$tcl_platform(osVersion) >= 5.0} {
  77. set F(family) "Tahoma"
  78. } else {
  79. set F(family) "MS Sans Serif"
  80. }
  81. } else {
  82. if {[lsearch -exact [font families] Tahoma] != -1} {
  83. set F(family) "Tahoma"
  84. } else {
  85. set F(family) "MS Sans Serif"
  86. }
  87. }
  88. set F(size) 8
  89. font configure TkDefaultFont -family $F(family) -size $F(size)
  90. font configure TkTextFont -family $F(family) -size $F(size)
  91. font configure TkHeadingFont -family $F(family) -size $F(size)
  92. font configure TkCaptionFont -family $F(family) -size $F(size) \
  93. -weight bold
  94. font configure TkTooltipFont -family $F(family) -size $F(size)
  95. font configure TkFixedFont -family Courier -size 10
  96. font configure TkIconFont -family $F(family) -size $F(size)
  97. font configure TkMenuFont -family $F(family) -size $F(size)
  98. font configure TkSmallCaptionFont -family $F(family) -size $F(size)
  99. }
  100. aqua {
  101. set F(family) "Lucida Grande"
  102. set F(fixed) "Monaco"
  103. set F(menusize) 14
  104. set F(size) 13
  105. set F(viewsize) 12
  106. set F(smallsize) 11
  107. set F(labelsize) 10
  108. set F(fixedsize) 11
  109. font configure TkDefaultFont -family $F(family) -size $F(size)
  110. font configure TkTextFont -family $F(family) -size $F(size)
  111. font configure TkHeadingFont -family $F(family) -size $F(smallsize)
  112. font configure TkCaptionFont -family $F(family) -size $F(size) \
  113. -weight bold
  114. font configure TkTooltipFont -family $F(family) -size $F(smallsize)
  115. font configure TkFixedFont -family $F(fixed) -size $F(fixedsize)
  116. font configure TkIconFont -family $F(family) -size $F(size)
  117. font configure TkMenuFont -family $F(family) -size $F(menusize)
  118. font configure TkSmallCaptionFont -family $F(family) -size $F(labelsize)
  119. }
  120. default -
  121. x11 {
  122. if {![catch {tk::pkgconfig get fontsystem} F(fs)] && $F(fs) eq "xft"} {
  123. set F(family) "sans-serif"
  124. set F(fixed) "monospace"
  125. } else {
  126. set F(family) "Helvetica"
  127. set F(fixed) "courier"
  128. }
  129. set F(size) -12
  130. set F(ttsize) -10
  131. set F(capsize) -14
  132. set F(fixedsize) -12
  133. font configure TkDefaultFont -family $F(family) -size $F(size)
  134. font configure TkTextFont -family $F(family) -size $F(size)
  135. font configure TkHeadingFont -family $F(family) -size $F(size) \
  136. -weight bold
  137. font configure TkCaptionFont -family $F(family) -size $F(capsize) \
  138. -weight bold
  139. font configure TkTooltipFont -family $F(family) -size $F(ttsize)
  140. font configure TkFixedFont -family $F(fixed) -size $F(fixedsize)
  141. font configure TkIconFont -family $F(family) -size $F(size)
  142. font configure TkMenuFont -family $F(family) -size $F(size)
  143. font configure TkSmallCaptionFont -family $F(family) -size $F(ttsize)
  144. }
  145. }
  146. unset -nocomplain F
  147. }
  148. }
  149. #*EOF*