Hi,
I want to copy the font settings from one run to another (in the same document). What isn’t clear is in which order the font settings have to be copied.
I’m assuming the correct order is to first copy the theme settings, then set style, and then copy the remaining font properties, given that theme settings, style and font settings interact. Here’s the code I have right now:
public static void CopyFrom(this Font target, Font source) {
// First set style, then font properties...
target.ThemeFont = source.ThemeFont;
target.ThemeFontAscii = source.ThemeFontAscii;
target.ThemeFontBi = source.ThemeFontBi;
target.ThemeFontFarEast = source.ThemeFontFarEast;
target.ThemeFontOther = source.ThemeFontOther;
target.ThemeColor = source.ThemeColor;
target.Style = source.Style;
target.AllCaps = source.AllCaps;
target.Bidi = source.Bidi;
target.Bold = source.Bold;
target.BoldBi = source.BoldBi;
target.Border.Color = source.Border.Color;
target.Border.DistanceFromText = source.Border.DistanceFromText;
target.Border.LineStyle = source.Border.LineStyle;
target.Border.LineWidth = source.Border.LineWidth;
target.Border.Shadow = source.Border.Shadow;
target.Color = source.Color;
target.ComplexScript = source.ComplexScript;
target.DoubleStrikeThrough = source.DoubleStrikeThrough;
target.Emboss = source.Emboss;
target.EmphasisMark = source.EmphasisMark;
target.Engrave = source.Engrave;
target.Hidden = source.Hidden;
target.HighlightColor = source.HighlightColor;
target.Italic = source.Italic;
target.ItalicBi = source.ItalicBi;
target.Kerning = source.Kerning;
target.LocaleId = source.LocaleId;
target.LocaleIdBi = source.LocaleIdBi;
target.LocaleIdFarEast = source.LocaleIdFarEast;
target.Name = source.Name;
target.NameAscii = source.NameAscii;
target.NameBi = source.NameBi;
target.NameFarEast = source.NameFarEast;
target.NameOther = source.NameOther;
target.NoProofing = source.NoProofing;
target.Outline = source.Outline;
target.Position = source.Position;
target.Scaling = source.Scaling;
target.Shading.BackgroundPatternColor = source.Shading.BackgroundPatternColor;
target.Shading.ForegroundPatternColor = source.Shading.ForegroundPatternColor;
target.Shading.Texture = source.Shading.Texture;
target.Shadow = source.Shadow;
target.Size = source.Size;
target.SizeBi = source.SizeBi;
target.SmallCaps = source.SmallCaps;
target.SnapToGrid = source.SnapToGrid;
target.Spacing = source.Spacing;
target.StrikeThrough = source.StrikeThrough;
target.Subscript = source.Subscript;
target.Superscript = source.Superscript;
target.TextEffect = source.TextEffect;
try {
target.TintAndShade = source.TintAndShade; // Fails if ThemeColor is not set
} catch {}
target.Underline = source.Underline;
target.UnderlineColor = source.UnderlineColor;
}
Is my approach correct?
Thanks,
Christophe