No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FontDataDrawer.cs 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace UnityEditor.UI
  4. {
  5. [CustomPropertyDrawer(typeof(FontData), true)]
  6. /// <summary>
  7. /// This is a PropertyDrawer for FontData. It is implemented using the standard Unity PropertyDrawer framework
  8. /// </summary>
  9. public class FontDataDrawer : PropertyDrawer
  10. {
  11. static private class Styles
  12. {
  13. public static GUIStyle alignmentButtonLeft = new GUIStyle(EditorStyles.miniButtonLeft);
  14. public static GUIStyle alignmentButtonMid = new GUIStyle(EditorStyles.miniButtonMid);
  15. public static GUIStyle alignmentButtonRight = new GUIStyle(EditorStyles.miniButtonRight);
  16. public static GUIContent m_EncodingContent;
  17. public static GUIContent m_LeftAlignText;
  18. public static GUIContent m_CenterAlignText;
  19. public static GUIContent m_RightAlignText;
  20. public static GUIContent m_TopAlignText;
  21. public static GUIContent m_MiddleAlignText;
  22. public static GUIContent m_BottomAlignText;
  23. public static GUIContent m_LeftAlignTextActive;
  24. public static GUIContent m_CenterAlignTextActive;
  25. public static GUIContent m_RightAlignTextActive;
  26. public static GUIContent m_TopAlignTextActive;
  27. public static GUIContent m_MiddleAlignTextActive;
  28. public static GUIContent m_BottomAlignTextActive;
  29. static Styles()
  30. {
  31. m_EncodingContent = EditorGUIUtility.TrTextContent("Rich Text", "Use emoticons and colors");
  32. // Horizontal Alignment Icons
  33. m_LeftAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left", "Left Align");
  34. m_CenterAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_center", "Center Align");
  35. m_RightAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_right", "Right Align");
  36. m_LeftAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left_active", "Left Align");
  37. m_CenterAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_center_active", "Center Align");
  38. m_RightAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_right_active", "Right Align");
  39. // Vertical Alignment Icons
  40. m_TopAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_top", "Top Align");
  41. m_MiddleAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_center", "Middle Align");
  42. m_BottomAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_bottom", "Bottom Align");
  43. m_TopAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_top_active", "Top Align");
  44. m_MiddleAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_center_active", "Middle Align");
  45. m_BottomAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_bottom_active", "Bottom Align");
  46. FixAlignmentButtonStyles(alignmentButtonLeft, alignmentButtonMid, alignmentButtonRight);
  47. }
  48. static void FixAlignmentButtonStyles(params GUIStyle[] styles)
  49. {
  50. foreach (GUIStyle style in styles)
  51. {
  52. style.padding.left = 2;
  53. style.padding.right = 2;
  54. }
  55. }
  56. }
  57. private enum VerticalTextAligment
  58. {
  59. Top,
  60. Middle,
  61. Bottom
  62. }
  63. private enum HorizontalTextAligment
  64. {
  65. Left,
  66. Center,
  67. Right
  68. }
  69. private const int kAlignmentButtonWidth = 20;
  70. static int s_TextAlignmentHash = "DoTextAligmentControl".GetHashCode();
  71. private SerializedProperty m_SupportEncoding;
  72. private SerializedProperty m_Font;
  73. private SerializedProperty m_FontSize;
  74. private SerializedProperty m_LineSpacing;
  75. private SerializedProperty m_FontStyle;
  76. private SerializedProperty m_ResizeTextForBestFit;
  77. private SerializedProperty m_ResizeTextMinSize;
  78. private SerializedProperty m_ResizeTextMaxSize;
  79. private SerializedProperty m_HorizontalOverflow;
  80. private SerializedProperty m_VerticalOverflow;
  81. private SerializedProperty m_Alignment;
  82. private SerializedProperty m_AlignByGeometry;
  83. private float m_FontFieldfHeight = 0f;
  84. private float m_FontStyleHeight = 0f;
  85. private float m_FontSizeHeight = 0f;
  86. private float m_LineSpacingHeight = 0f;
  87. private float m_EncodingHeight = 0f;
  88. private float m_ResizeTextForBestFitHeight = 0f;
  89. private float m_ResizeTextMinSizeHeight = 0f;
  90. private float m_ResizeTextMaxSizeHeight = 0f;
  91. private float m_HorizontalOverflowHeight = 0f;
  92. private float m_VerticalOverflowHeight = 0f;
  93. private float m_AlignByGeometryHeight = 0f;
  94. protected void Init(SerializedProperty property)
  95. {
  96. m_SupportEncoding = property.FindPropertyRelative("m_RichText");
  97. m_Font = property.FindPropertyRelative("m_Font");
  98. m_FontSize = property.FindPropertyRelative("m_FontSize");
  99. m_LineSpacing = property.FindPropertyRelative("m_LineSpacing");
  100. m_FontStyle = property.FindPropertyRelative("m_FontStyle");
  101. m_ResizeTextForBestFit = property.FindPropertyRelative("m_BestFit");
  102. m_ResizeTextMinSize = property.FindPropertyRelative("m_MinSize");
  103. m_ResizeTextMaxSize = property.FindPropertyRelative("m_MaxSize");
  104. m_HorizontalOverflow = property.FindPropertyRelative("m_HorizontalOverflow");
  105. m_VerticalOverflow = property.FindPropertyRelative("m_VerticalOverflow");
  106. m_Alignment = property.FindPropertyRelative("m_Alignment");
  107. m_AlignByGeometry = property.FindPropertyRelative("m_AlignByGeometry");
  108. }
  109. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  110. {
  111. Init(property);
  112. m_FontFieldfHeight = EditorGUI.GetPropertyHeight(m_Font);
  113. m_FontStyleHeight = EditorGUI.GetPropertyHeight(m_FontStyle);
  114. m_FontSizeHeight = EditorGUI.GetPropertyHeight(m_FontSize);
  115. m_LineSpacingHeight = EditorGUI.GetPropertyHeight(m_LineSpacing);
  116. m_EncodingHeight = EditorGUI.GetPropertyHeight(m_SupportEncoding);
  117. m_ResizeTextForBestFitHeight = EditorGUI.GetPropertyHeight(m_ResizeTextForBestFit);
  118. m_ResizeTextMinSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMinSize);
  119. m_ResizeTextMaxSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMaxSize);
  120. m_HorizontalOverflowHeight = EditorGUI.GetPropertyHeight(m_HorizontalOverflow);
  121. m_VerticalOverflowHeight = EditorGUI.GetPropertyHeight(m_VerticalOverflow);
  122. m_AlignByGeometryHeight = EditorGUI.GetPropertyHeight(m_AlignByGeometry);
  123. var height = m_FontFieldfHeight
  124. + m_FontStyleHeight
  125. + m_FontSizeHeight
  126. + m_LineSpacingHeight
  127. + m_EncodingHeight
  128. + m_ResizeTextForBestFitHeight
  129. + m_HorizontalOverflowHeight
  130. + m_VerticalOverflowHeight
  131. + EditorGUIUtility.singleLineHeight * 3
  132. + EditorGUIUtility.standardVerticalSpacing * 10
  133. + m_AlignByGeometryHeight;
  134. if (m_ResizeTextForBestFit.boolValue)
  135. {
  136. height += m_ResizeTextMinSizeHeight
  137. + m_ResizeTextMaxSizeHeight
  138. + EditorGUIUtility.standardVerticalSpacing * 2;
  139. }
  140. return height;
  141. }
  142. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  143. {
  144. Init(property);
  145. Rect rect = position;
  146. rect.height = EditorGUIUtility.singleLineHeight;
  147. EditorGUI.LabelField(rect, "Character", EditorStyles.boldLabel);
  148. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  149. ++EditorGUI.indentLevel;
  150. {
  151. Font font = m_Font.objectReferenceValue as Font;
  152. rect.height = m_FontFieldfHeight;
  153. EditorGUI.BeginChangeCheck();
  154. EditorGUI.PropertyField(rect, m_Font);
  155. if (EditorGUI.EndChangeCheck())
  156. {
  157. font = m_Font.objectReferenceValue as Font;
  158. if (font != null && !font.dynamic)
  159. m_FontSize.intValue = font.fontSize;
  160. }
  161. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  162. rect.height = m_FontStyleHeight;
  163. using (new EditorGUI.DisabledScope(!m_Font.hasMultipleDifferentValues && font != null && !font.dynamic))
  164. {
  165. EditorGUI.PropertyField(rect, m_FontStyle);
  166. }
  167. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  168. rect.height = m_FontSizeHeight;
  169. EditorGUI.PropertyField(rect, m_FontSize);
  170. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  171. rect.height = m_LineSpacingHeight;
  172. EditorGUI.PropertyField(rect, m_LineSpacing);
  173. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  174. rect.height = m_EncodingHeight;
  175. EditorGUI.PropertyField(rect, m_SupportEncoding, Styles.m_EncodingContent);
  176. }
  177. --EditorGUI.indentLevel;
  178. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  179. rect.height = EditorGUIUtility.singleLineHeight;
  180. EditorGUI.LabelField(rect, "Paragraph", EditorStyles.boldLabel);
  181. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  182. ++EditorGUI.indentLevel;
  183. {
  184. rect.height = EditorGUIUtility.singleLineHeight;
  185. DoTextAligmentControl(rect, m_Alignment);
  186. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  187. rect.height = m_HorizontalOverflowHeight;
  188. EditorGUI.PropertyField(rect, m_AlignByGeometry);
  189. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  190. rect.height = m_HorizontalOverflowHeight;
  191. EditorGUI.PropertyField(rect, m_HorizontalOverflow);
  192. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  193. rect.height = m_VerticalOverflowHeight;
  194. EditorGUI.PropertyField(rect, m_VerticalOverflow);
  195. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  196. rect.height = m_ResizeTextMaxSizeHeight;
  197. EditorGUI.PropertyField(rect, m_ResizeTextForBestFit);
  198. if (m_ResizeTextForBestFit.boolValue)
  199. {
  200. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  201. rect.height = m_ResizeTextMinSizeHeight;
  202. EditorGUI.PropertyField(rect, m_ResizeTextMinSize);
  203. rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
  204. rect.height = m_ResizeTextMaxSizeHeight;
  205. EditorGUI.PropertyField(rect, m_ResizeTextMaxSize);
  206. }
  207. }
  208. --EditorGUI.indentLevel;
  209. }
  210. private void DoTextAligmentControl(Rect position, SerializedProperty alignment)
  211. {
  212. GUIContent alingmentContent = EditorGUIUtility.TrTextContent("Alignment");
  213. int id = EditorGUIUtility.GetControlID(s_TextAlignmentHash, FocusType.Keyboard, position);
  214. EditorGUIUtility.SetIconSize(new Vector2(15, 15));
  215. EditorGUI.BeginProperty(position, alingmentContent, alignment);
  216. {
  217. Rect controlArea = EditorGUI.PrefixLabel(position, id, alingmentContent);
  218. float width = kAlignmentButtonWidth * 3;
  219. float spacing = Mathf.Clamp(controlArea.width - width * 2, 2, 10);
  220. Rect horizontalAligment = new Rect(controlArea.x, controlArea.y, width, controlArea.height);
  221. Rect verticalAligment = new Rect(horizontalAligment.xMax + spacing, controlArea.y, width, controlArea.height);
  222. DoHorizontalAligmentControl(horizontalAligment, alignment);
  223. DoVerticalAligmentControl(verticalAligment, alignment);
  224. }
  225. EditorGUI.EndProperty();
  226. EditorGUIUtility.SetIconSize(Vector2.zero);
  227. }
  228. private static void DoHorizontalAligmentControl(Rect position, SerializedProperty alignment)
  229. {
  230. TextAnchor ta = (TextAnchor)alignment.intValue;
  231. HorizontalTextAligment horizontalAlignment = GetHorizontalAlignment(ta);
  232. bool leftAlign = (horizontalAlignment == HorizontalTextAligment.Left);
  233. bool centerAlign = (horizontalAlignment == HorizontalTextAligment.Center);
  234. bool rightAlign = (horizontalAlignment == HorizontalTextAligment.Right);
  235. if (alignment.hasMultipleDifferentValues)
  236. {
  237. foreach (var obj in alignment.serializedObject.targetObjects)
  238. {
  239. Text text = obj as Text;
  240. horizontalAlignment = GetHorizontalAlignment(text.alignment);
  241. leftAlign = leftAlign || (horizontalAlignment == HorizontalTextAligment.Left);
  242. centerAlign = centerAlign || (horizontalAlignment == HorizontalTextAligment.Center);
  243. rightAlign = rightAlign || (horizontalAlignment == HorizontalTextAligment.Right);
  244. }
  245. }
  246. position.width = kAlignmentButtonWidth;
  247. EditorGUI.BeginChangeCheck();
  248. EditorToggle(position, leftAlign, leftAlign ? Styles.m_LeftAlignTextActive : Styles.m_LeftAlignText, Styles.alignmentButtonLeft);
  249. if (EditorGUI.EndChangeCheck())
  250. {
  251. SetHorizontalAlignment(alignment, HorizontalTextAligment.Left);
  252. }
  253. position.x += position.width;
  254. EditorGUI.BeginChangeCheck();
  255. EditorToggle(position, centerAlign, centerAlign ? Styles.m_CenterAlignTextActive : Styles.m_CenterAlignText, Styles.alignmentButtonMid);
  256. if (EditorGUI.EndChangeCheck())
  257. {
  258. SetHorizontalAlignment(alignment, HorizontalTextAligment.Center);
  259. }
  260. position.x += position.width;
  261. EditorGUI.BeginChangeCheck();
  262. EditorToggle(position, rightAlign, rightAlign ? Styles.m_RightAlignTextActive : Styles.m_RightAlignText, Styles.alignmentButtonRight);
  263. if (EditorGUI.EndChangeCheck())
  264. {
  265. SetHorizontalAlignment(alignment, HorizontalTextAligment.Right);
  266. }
  267. }
  268. private static void DoVerticalAligmentControl(Rect position, SerializedProperty alignment)
  269. {
  270. TextAnchor ta = (TextAnchor)alignment.intValue;
  271. VerticalTextAligment verticalTextAligment = GetVerticalAlignment(ta);
  272. bool topAlign = (verticalTextAligment == VerticalTextAligment.Top);
  273. bool middleAlign = (verticalTextAligment == VerticalTextAligment.Middle);
  274. bool bottomAlign = (verticalTextAligment == VerticalTextAligment.Bottom);
  275. if (alignment.hasMultipleDifferentValues)
  276. {
  277. foreach (var obj in alignment.serializedObject.targetObjects)
  278. {
  279. Text text = obj as Text;
  280. TextAnchor textAlignment = text.alignment;
  281. verticalTextAligment = GetVerticalAlignment(textAlignment);
  282. topAlign = topAlign || (verticalTextAligment == VerticalTextAligment.Top);
  283. middleAlign = middleAlign || (verticalTextAligment == VerticalTextAligment.Middle);
  284. bottomAlign = bottomAlign || (verticalTextAligment == VerticalTextAligment.Bottom);
  285. }
  286. }
  287. position.width = kAlignmentButtonWidth;
  288. // position.x += position.width;
  289. EditorGUI.BeginChangeCheck();
  290. EditorToggle(position, topAlign, topAlign ? Styles.m_TopAlignTextActive : Styles.m_TopAlignText, Styles.alignmentButtonLeft);
  291. if (EditorGUI.EndChangeCheck())
  292. {
  293. SetVerticalAlignment(alignment, VerticalTextAligment.Top);
  294. }
  295. position.x += position.width;
  296. EditorGUI.BeginChangeCheck();
  297. EditorToggle(position, middleAlign, middleAlign ? Styles.m_MiddleAlignTextActive : Styles.m_MiddleAlignText, Styles.alignmentButtonMid);
  298. if (EditorGUI.EndChangeCheck())
  299. {
  300. SetVerticalAlignment(alignment, VerticalTextAligment.Middle);
  301. }
  302. position.x += position.width;
  303. EditorGUI.BeginChangeCheck();
  304. EditorToggle(position, bottomAlign, bottomAlign ? Styles.m_BottomAlignTextActive : Styles.m_BottomAlignText, Styles.alignmentButtonRight);
  305. if (EditorGUI.EndChangeCheck())
  306. {
  307. SetVerticalAlignment(alignment, VerticalTextAligment.Bottom);
  308. }
  309. }
  310. private static bool EditorToggle(Rect position, bool value, GUIContent content, GUIStyle style)
  311. {
  312. int hashCode = "AlignToggle".GetHashCode();
  313. int id = EditorGUIUtility.GetControlID(hashCode, FocusType.Keyboard, position);
  314. Event evt = Event.current;
  315. // Toggle selected toggle on space or return key
  316. if (EditorGUIUtility.keyboardControl == id && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter))
  317. {
  318. value = !value;
  319. evt.Use();
  320. GUI.changed = true;
  321. }
  322. if (evt.type == EventType.KeyDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
  323. {
  324. GUIUtility.keyboardControl = id;
  325. EditorGUIUtility.editingTextField = false;
  326. HandleUtility.Repaint();
  327. }
  328. bool returnValue = GUI.Toggle(position, id, value, content, style);
  329. return returnValue;
  330. }
  331. private static HorizontalTextAligment GetHorizontalAlignment(TextAnchor ta)
  332. {
  333. switch (ta)
  334. {
  335. case TextAnchor.MiddleCenter:
  336. case TextAnchor.UpperCenter:
  337. case TextAnchor.LowerCenter:
  338. return HorizontalTextAligment.Center;
  339. case TextAnchor.UpperRight:
  340. case TextAnchor.MiddleRight:
  341. case TextAnchor.LowerRight:
  342. return HorizontalTextAligment.Right;
  343. case TextAnchor.UpperLeft:
  344. case TextAnchor.MiddleLeft:
  345. case TextAnchor.LowerLeft:
  346. return HorizontalTextAligment.Left;
  347. }
  348. return HorizontalTextAligment.Left;
  349. }
  350. private static VerticalTextAligment GetVerticalAlignment(TextAnchor ta)
  351. {
  352. switch (ta)
  353. {
  354. case TextAnchor.UpperLeft:
  355. case TextAnchor.UpperCenter:
  356. case TextAnchor.UpperRight:
  357. return VerticalTextAligment.Top;
  358. case TextAnchor.MiddleLeft:
  359. case TextAnchor.MiddleCenter:
  360. case TextAnchor.MiddleRight:
  361. return VerticalTextAligment.Middle;
  362. case TextAnchor.LowerLeft:
  363. case TextAnchor.LowerCenter:
  364. case TextAnchor.LowerRight:
  365. return VerticalTextAligment.Bottom;
  366. }
  367. return VerticalTextAligment.Top;
  368. }
  369. // We can't go through serialized properties here since we're showing two controls for a single SerializzedProperty.
  370. private static void SetHorizontalAlignment(SerializedProperty alignment, HorizontalTextAligment horizontalAlignment)
  371. {
  372. foreach (var obj in alignment.serializedObject.targetObjects)
  373. {
  374. Text text = obj as Text;
  375. VerticalTextAligment currentVerticalAligment = GetVerticalAlignment(text.alignment);
  376. Undo.RecordObject(text, "Horizontal Alignment");
  377. text.alignment = GetAnchor(currentVerticalAligment, horizontalAlignment);
  378. EditorUtility.SetDirty(obj);
  379. }
  380. }
  381. private static void SetVerticalAlignment(SerializedProperty alignment, VerticalTextAligment verticalAlignment)
  382. {
  383. foreach (var obj in alignment.serializedObject.targetObjects)
  384. {
  385. Text text = obj as Text;
  386. HorizontalTextAligment currentHorizontalAligment = GetHorizontalAlignment(text.alignment);
  387. Undo.RecordObject(text, "Vertical Alignment");
  388. text.alignment = GetAnchor(verticalAlignment, currentHorizontalAligment);
  389. EditorUtility.SetDirty(obj);
  390. }
  391. }
  392. private static TextAnchor GetAnchor(VerticalTextAligment verticalTextAligment, HorizontalTextAligment horizontalTextAligment)
  393. {
  394. TextAnchor ac = TextAnchor.UpperLeft;
  395. switch (horizontalTextAligment)
  396. {
  397. case HorizontalTextAligment.Left:
  398. switch (verticalTextAligment)
  399. {
  400. case VerticalTextAligment.Bottom:
  401. ac = TextAnchor.LowerLeft;
  402. break;
  403. case VerticalTextAligment.Middle:
  404. ac = TextAnchor.MiddleLeft;
  405. break;
  406. default:
  407. ac = TextAnchor.UpperLeft;
  408. break;
  409. }
  410. break;
  411. case HorizontalTextAligment.Center:
  412. switch (verticalTextAligment)
  413. {
  414. case VerticalTextAligment.Bottom:
  415. ac = TextAnchor.LowerCenter;
  416. break;
  417. case VerticalTextAligment.Middle:
  418. ac = TextAnchor.MiddleCenter;
  419. break;
  420. default:
  421. ac = TextAnchor.UpperCenter;
  422. break;
  423. }
  424. break;
  425. default:
  426. switch (verticalTextAligment)
  427. {
  428. case VerticalTextAligment.Bottom:
  429. ac = TextAnchor.LowerRight;
  430. break;
  431. case VerticalTextAligment.Middle:
  432. ac = TextAnchor.MiddleRight;
  433. break;
  434. default:
  435. ac = TextAnchor.UpperRight;
  436. break;
  437. }
  438. break;
  439. }
  440. return ac;
  441. }
  442. }
  443. }