SvgFontFace.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. #pragma warning disable
  6. namespace Svg
  7. {
  8. [SvgElement("font-face")]
  9. public class SvgFontFace : SvgElement
  10. {
  11. [SvgAttribute("alphabetic")]
  12. public float Alphabetic
  13. {
  14. get { return (this.Attributes["alphabetic"] == null ? 0 : (float)this.Attributes["alphabetic"]); }
  15. set { this.Attributes["alphabetic"] = value; }
  16. }
  17. [SvgAttribute("ascent")]
  18. public float Ascent
  19. {
  20. get
  21. {
  22. if (this.Attributes["ascent"] == null)
  23. {
  24. var font = this.Parent as SvgFont;
  25. return (font == null ? 0 : this.UnitsPerEm - font.VertOriginY);
  26. }
  27. else
  28. {
  29. return (float)this.Attributes["ascent"];
  30. }
  31. }
  32. set { this.Attributes["ascent"] = value; }
  33. }
  34. [SvgAttribute("ascent-height")]
  35. public float AscentHeight
  36. {
  37. get { return (this.Attributes["ascent-height"] == null ? this.Ascent : (float)this.Attributes["ascent-height"]); }
  38. set { this.Attributes["ascent-height"] = value; }
  39. }
  40. [SvgAttribute("descent")]
  41. public float Descent
  42. {
  43. get
  44. {
  45. if (this.Attributes["descent"] == null)
  46. {
  47. var font = this.Parent as SvgFont;
  48. return (font == null ? 0 : font.VertOriginY);
  49. }
  50. else
  51. {
  52. return (float)this.Attributes["descent"];
  53. }
  54. }
  55. set { this.Attributes["descent"] = value; }
  56. }
  57. /// <summary>
  58. /// Indicates which font family is to be used to render the text.
  59. /// </summary>
  60. [SvgAttribute("font-family")]
  61. public override string FontFamily
  62. {
  63. get { return this.Attributes["font-family"] as string; }
  64. set { this.Attributes["font-family"] = value; }
  65. }
  66. /// <summary>
  67. /// Refers to the size of the font from baseline to baseline when multiple lines of text are set solid in a multiline layout environment.
  68. /// </summary>
  69. [SvgAttribute("font-size")]
  70. public override SvgUnit FontSize
  71. {
  72. get { return (this.Attributes["font-size"] == null) ? SvgUnit.Empty : (SvgUnit)this.Attributes["font-size"]; }
  73. set { this.Attributes["font-size"] = value; }
  74. }
  75. /// <summary>
  76. /// Refers to the style of the font.
  77. /// </summary>
  78. [SvgAttribute("font-style")]
  79. public override SvgFontStyle FontStyle
  80. {
  81. get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.All : (SvgFontStyle)this.Attributes["font-style"]; }
  82. set { this.Attributes["font-style"] = value; }
  83. }
  84. /// <summary>
  85. /// Refers to the varient of the font.
  86. /// </summary>
  87. [SvgAttribute("font-variant")]
  88. public override SvgFontVariant FontVariant
  89. {
  90. get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.Inherit : (SvgFontVariant)this.Attributes["font-variant"]; }
  91. set { this.Attributes["font-variant"] = value; }
  92. }
  93. /// <summary>
  94. /// Refers to the boldness of the font.
  95. /// </summary>
  96. [SvgAttribute("font-weight")]
  97. public override SvgFontWeight FontWeight
  98. {
  99. get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.Inherit : (SvgFontWeight)this.Attributes["font-weight"]; }
  100. set { this.Attributes["font-weight"] = value; }
  101. }
  102. [SvgAttribute("panose-1")]
  103. public string Panose1
  104. {
  105. get { return this.Attributes["panose-1"] as string; }
  106. set { this.Attributes["panose-1"] = value; }
  107. }
  108. [SvgAttribute("units-per-em")]
  109. public float UnitsPerEm
  110. {
  111. get { return (this.Attributes["units-per-em"] == null ? 1000 : (float)this.Attributes["units-per-em"]); }
  112. set { this.Attributes["units-per-em"] = value; }
  113. }
  114. [SvgAttribute("x-height")]
  115. public float XHeight
  116. {
  117. get { return (this.Attributes["x-height"] == null ? float.MinValue : (float)this.Attributes["x-height"]); }
  118. set { this.Attributes["x-height"] = value; }
  119. }
  120. public override SvgElement DeepCopy()
  121. {
  122. return base.DeepCopy<SvgFontFace>();
  123. }
  124. }
  125. }
  126. #pragma warning restore