0

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?

Lloyd
  • 29,197
  • 4
  • 84
  • 98
Roland
  • 113
  • 2
  • 11

1 Answers1

1

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));

Demo

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.

Lucas Trzesniewski
  • 50,214
  • 11
  • 107
  • 158