32
32
33
33
using System ;
34
34
using System . Diagnostics ;
35
- using System . ComponentModel ;
36
- using MigraDocCore . DocumentObjectModel . Internals ;
37
35
using PdfSharpCore . Drawing ;
38
36
39
37
namespace MigraDocCore . DocumentObjectModel
@@ -63,7 +61,7 @@ public XSize MeasureString(string text, UnitType unitType)
63
61
if ( ! Enum . IsDefined ( typeof ( UnitType ) , unitType ) )
64
62
throw new ArgumentException ( ) ;
65
63
66
- XSize size = graphics . MeasureString ( text , this . xFont ) ;
64
+ var size = graphics . MeasureString ( text , this . XFont ) ;
67
65
switch ( unitType )
68
66
{
69
67
case UnitType . Point :
@@ -99,7 +97,7 @@ public XSize MeasureString(string text, UnitType unitType)
99
97
/// <summary>
100
98
/// Returns the size of the bounding box of the specified text in point.
101
99
/// </summary>
102
- public PdfSharpCore . Drawing . XSize MeasureString ( string text )
100
+ public XSize MeasureString ( string text )
103
101
{
104
102
return MeasureString ( text , UnitType . Point ) ;
105
103
}
@@ -121,6 +119,32 @@ public Font Font
121
119
}
122
120
}
123
121
}
122
+
123
+ /// <summary>
124
+ /// Gets the xfont used for measurement.
125
+ /// </summary>
126
+ private XFont XFont
127
+ {
128
+ get {
129
+ if ( this . xFont == null )
130
+ {
131
+ var style = XFontStyle . Regular ;
132
+ if ( this . Font . Bold )
133
+ {
134
+ style |= XFontStyle . Bold ;
135
+ }
136
+ if ( this . Font . Italic )
137
+ {
138
+ style |= XFontStyle . Italic ;
139
+ }
140
+
141
+ this . xFont = new XFont ( this . Font . Name , this . Font . Size , style ) ;
142
+ }
143
+
144
+ return this . xFont ;
145
+ }
146
+ }
147
+
124
148
Font font ;
125
149
XFont xFont ;
126
150
XGraphics graphics ;
0 commit comments