Font.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
  21. //
  22. // Authors:
  23. // Peter Bartok ([email protected])
  24. //
  25. //
  26. // COMPLETE
  27. namespace System.Windows.Forms.RTF {
  28. internal class Font {
  29. #region Local Variables
  30. private string name;
  31. private string alt_name;
  32. private int num;
  33. private int family;
  34. private CharsetType charset;
  35. private int pitch;
  36. private int type;
  37. private int codepage;
  38. private Font next;
  39. #endregion // Local Variables
  40. #region Constructors
  41. public Font(RTF rtf) {
  42. num = -1;
  43. lock (rtf) {
  44. if (rtf.Fonts == null)
  45. rtf.Fonts = this;
  46. else {
  47. Font f = rtf.Fonts;
  48. while (f.next != null)
  49. f = f.next;
  50. f.next = this;
  51. }
  52. }
  53. }
  54. #endregion // Constructors
  55. #region Properties
  56. public string Name {
  57. get {
  58. return name;
  59. }
  60. set {
  61. name = value;
  62. }
  63. }
  64. public string AltName {
  65. get {
  66. return alt_name;
  67. }
  68. set {
  69. alt_name = value;
  70. }
  71. }
  72. public int Num {
  73. get {
  74. return num;
  75. }
  76. set {
  77. num = value;
  78. }
  79. }
  80. public int Family {
  81. get {
  82. return family;
  83. }
  84. set {
  85. family = value;
  86. }
  87. }
  88. public CharsetType Charset {
  89. get {
  90. return charset;
  91. }
  92. set {
  93. charset = value;
  94. }
  95. }
  96. public int Pitch {
  97. get {
  98. return pitch;
  99. }
  100. set {
  101. pitch = value;
  102. }
  103. }
  104. public int Type {
  105. get {
  106. return type;
  107. }
  108. set {
  109. type = value;
  110. }
  111. }
  112. public int Codepage {
  113. get {
  114. return codepage;
  115. }
  116. set {
  117. codepage = value;
  118. }
  119. }
  120. #endregion // Properties
  121. #region Methods
  122. static public Font GetFont(RTF rtf, int font_number) {
  123. Font f;
  124. lock (rtf) {
  125. f = GetFont(rtf.Fonts, font_number);
  126. }
  127. return f;
  128. }
  129. static public Font GetFont(Font start, int font_number) {
  130. Font f;
  131. if (font_number == -1) {
  132. return start;
  133. }
  134. f = start;
  135. while ((f != null) && (f.num != font_number)) {
  136. f = f.next;
  137. }
  138. return f;
  139. }
  140. #endregion // Methods
  141. }
  142. }