File tree Expand file tree Collapse file tree 6 files changed +26
-11
lines changed
RtfDomParser.WinFormsDemo Expand file tree Collapse file tree 6 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ static class Program
12
12
[ STAThread ]
13
13
static void Main ( )
14
14
{
15
+ Defaults . FontName = System . Windows . Forms . Control . DefaultFont . Name ;
16
+
15
17
Application . EnableVisualStyles ( ) ;
16
18
Application . SetCompatibleTextRenderingDefault ( false ) ;
17
19
Application . Run ( new frmRTFTest ( ) ) ;
Original file line number Diff line number Diff line change 8
8
*/
9
9
10
10
using System ;
11
- using System . Windows . Forms ;
12
11
13
12
namespace RtfDomParser
14
13
{
Original file line number Diff line number Diff line change
1
+ using System . Text ;
2
+
3
+ namespace RtfDomParser
4
+ {
5
+ public static class Defaults
6
+ {
7
+ public static string FontName { get ; set ; } = "Times New Roman" ;
8
+
9
+ public static void LoadEncodings ( )
10
+ {
11
+ Encoding . RegisterProvider ( CodePagesEncodingProvider . Instance ) ;
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change @@ -403,7 +403,7 @@ public System.Drawing.Font Font
403
403
}
404
404
}
405
405
406
- private string strFontName = System . Windows . Forms . Control . DefaultFont . Name ;
406
+ private string strFontName = Defaults . FontName ;
407
407
/// <summary>
408
408
/// font name
409
409
/// </summary>
@@ -801,7 +801,7 @@ public DocumentFormatInfo Clone()
801
801
802
802
public void ResetText ( )
803
803
{
804
- this . FontName = System . Windows . Forms . Control . DefaultFont . Name ;
804
+ this . FontName = Defaults . FontName ;
805
805
this . FontSize = 12 ;
806
806
this . Bold = false ;
807
807
this . Italic = false ;
@@ -861,7 +861,7 @@ public void Reset()
861
861
this . SpacingBefore = 0 ;
862
862
this . SpacingAfter = 0 ;
863
863
this . Align = 0 ;
864
- this . FontName = System . Windows . Forms . Control . DefaultFont . Name ;
864
+ this . FontName = Defaults . FontName ;
865
865
this . FontSize = 12 ;
866
866
this . Bold = false ;
867
867
this . Italic = false ;
@@ -1145,7 +1145,7 @@ public void Reset()
1145
1145
// }
1146
1146
// }
1147
1147
1148
- // private string strFontName = System.Windows.Forms.Control.DefaultFont.Name ;
1148
+ // private string strFontName = Defaults.FontName ;
1149
1149
// /// <summary>
1150
1150
// /// font name
1151
1151
// /// </summary>
@@ -1522,7 +1522,7 @@ public void Reset()
1522
1522
1523
1523
// public void ResetText()
1524
1524
// {
1525
- // this.FontName = System.Windows.Forms.Control.DefaultFont.Name ;
1525
+ // this.FontName = Defaults.FontName ;
1526
1526
// this.FontSize = 12;
1527
1527
// this.Bold = false;
1528
1528
// this.Italic = false;
@@ -1562,7 +1562,7 @@ public void Reset()
1562
1562
// this.Spacing = 0;
1563
1563
// this.LineSpacing = 0;
1564
1564
// this.Align = 0;
1565
- // this.FontName = System.Windows.Forms.Control.DefaultFont.Name ;
1565
+ // this.FontName = Defaults.FontName ;
1566
1566
// this.FontSize = 12;
1567
1567
// this.Bold = false;
1568
1568
// this.Italic = false;
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ public void WriteStartDocument()
255
255
myInfo . Clear ( ) ;
256
256
myFontTable . Clear ( ) ;
257
257
myColorTable . Clear ( ) ;
258
- myFontTable . Add ( System . Windows . Forms . Control . DefaultFont . Name ) ;
258
+ myFontTable . Add ( Defaults . FontName ) ;
259
259
}
260
260
else
261
261
{
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ internal System.Text.Encoding RuntimeEncoding
98
98
/// <summary>
99
99
/// default font name
100
100
/// </summary>
101
- private static string DefaultFontName = System . Windows . Forms . Control . DefaultFont . Name ;
101
+ private static string DefaultFontName = Defaults . FontName ;
102
102
103
103
104
104
private RTFFontTable myFontTable = new RTFFontTable ( ) ;
@@ -3440,7 +3440,7 @@ private void ReadFontTable(RTFReader reader)
3440
3440
}
3441
3441
else if ( reader . Keyword == "fnil" )
3442
3442
{
3443
- name = System . Windows . Forms . Control . DefaultFont . Name ;
3443
+ name = Defaults . FontName ;
3444
3444
nilFlag = true ;
3445
3445
}
3446
3446
else if ( reader . Keyword == RTFConsts . _fcharset )
@@ -3478,7 +3478,7 @@ private void ReadFontTable(RTFReader reader)
3478
3478
name = name . Trim ( ) ;
3479
3479
if ( string . IsNullOrEmpty ( name ) )
3480
3480
{
3481
- name = System . Windows . Forms . Control . DefaultFont . Name ;
3481
+ name = Defaults . FontName ;
3482
3482
}
3483
3483
//System.Console.WriteLine( "Index:" + index + " Name:" + name );
3484
3484
RTFFont font = new RTFFont ( index , name ) ;
You can’t perform that action at this time.
0 commit comments