如何仅在 C# 中的 ActiveMdiChild 中设置字体系列或字体大小

How to Only set the Font Family or the Font Size in a ActiveMdiChild in C#

所以我尝试使用菜单条来仅更改字体系列或字体大小。但如您所见,我必须将字体大小设为 12 才能使其正常工作。如何在保持当前字体大小或字体系列

的同时自行更改字体系列或字体大小
private void arialToolStripMenuItem_Click(object sender, EventArgs e)
{
     if (ActiveMdiChild != null)
     {
          ActiveMdiChild.Controls["richTextBox1"].Font = new Font("Arial", 12);
     }
}

正如您在 documentation 中看到的,您不能直接设置 Font.Size 属性 所以最好的选择可能是这种方法:

var currentFont = ActiveMdiChild.Controls["richTextBox1"].Font;
currentFont = new Font(currentFont.FontFamily, 12);