* RTF.cs: Added method to allow setting the default font for the RTF
document. This font will be used if the document does not contain
a font table.
* Font.cs: Added method to delete font with a given number;
changed set_Num to call this method (to allow replacing fonts
with the same number, particulary the default font)
svn path=/trunk/mcs/; revision=54761
+2005-12-22 Peter Dennis Bartok <pbartok@novell.com>
+
+ * RTF.cs: Added method to allow setting the default font for the RTF
+ document. This font will be used if the document does not contain
+ a font table.
+ * Font.cs: Added method to delete font with a given number;
+ changed set_Num to call this method (to allow replacing fonts
+ with the same number, particulary the default font)
+
2005-09-04 Peter Dennis Bartok <pbartok@novell.com>
* Charcode.cs: Created; provides StandardCharCode <-> character
private int type;
private int codepage;
private Font next;
+ private RTF rtf;
#endregion // Local Variables
#region Constructors
public Font(RTF rtf) {
+ this.rtf = rtf;
num = -1;
lock (rtf) {
}
set {
+ // Whack any previous font with the same number
+ DeleteFont(rtf, value);
num = value;
}
}
#endregion // Properties
#region Methods
+ static public bool DeleteFont(RTF rtf, int font_number) {
+ Font f;
+ Font prev;
+
+ lock (rtf) {
+ f = rtf.Fonts;
+ prev = null;
+ while ((f != null) && (f.num != font_number)) {
+ prev = f;
+ f = f.next;
+ }
+
+ if (f != null) {
+ if (f == rtf.Fonts) {
+ rtf.Fonts = f.next;
+ } else {
+ if (prev != null) {
+ prev.next = f.next;
+ } else {
+ rtf.Fonts = f.next;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
static public Font GetFont(RTF rtf, int font_number) {
Font f;
#endregion // Properties
#region Methods
+ /// <summary>Set the default font for documents without font table</summary>
+ public void DefaultFont(string name) {
+ Font font;
+
+ font = new Font(this);
+ font.Num = 0;
+ font.Name = name;
+ }
+
/// <summary>Read the next character from the input</summary>
private char GetChar() {
char c;