Reputation: 113
I have to increase all the fonts in an RTF string with a factor.
The font size is defined as e.g. \fs120
(would mean 60 pt) in the RTF string.
How can in go through all font sizes in the RTF string and multiply it with a factor to replace the original value with the new calculated?
Upvotes: 0
Views: 641
Reputation: 51420
Since you tagged this as C#:
Regex.Replace(input,
@"\\fs([0-9]+)\b",
m => string.Format(@"\fs{0}", int.Parse(m.Groups[1].Value) * 2));
The used pattern is: \\fs([0-9]+)\b
. It matches the font size construct and captures the size. The Replace
function simply replaces the matched string by a new value using a callback that doubles the font size.
Upvotes: 1