Word Interop: EQ fields keep reverting Greek letters to default font even after setting Name/NameOther/NameAscii

懿 刘 0 Reputation points
2026-01-23T21:51:48.2433333+00:00

I’m converting OMML (OMath) to EQ fields in a Word add-in (C#, .NET Framework 4.7.2, Word Interop). The issue: Greek letters inside the EQ field always fall back to the document’s default font (e.g., SimSun), even though I set all font slots (Name, NameAscii, NameOther, NameBi, NameFarEast). Latin letters respect the target font.

Environment:

• .NET Framework 4.7.2, C# 7.3

• Microsoft.Office.Interop.Word

• Target font example: “Tims New Roman” (user setting EquationFontName)

What I see in logs:

• EQ code after normalization: A=πr\s\up(2)α

• Debug warning (Name comes fallback, NameOther is set):

Minimal code (simplified):

string fieldCode = ConvertOMathToEq(omath);

fieldCode = NormalizeUnicodeMathCharacters(fieldCode);
var field = doc.Fields.Add(insertRange, Word.WdFieldType.wdFieldFormula, fieldCode, false);

string fontName = _settings?.EquationFontName ?? "Times New Roman";

field.ShowCodes = true;

ApplyFieldRangeFontFamily(field.Code, fontName);

// tried also: field.Update(); ApplyFieldRangeFontFamily(field.Result, fontName);

ApplyScriptFomratToField(field, scriptReduction); // only shrinks super/subscripts

field.ShowCodes = false;

private static void ApplyFieldRangeFontFamily(Word.Range range, string fontName)

{

range.Font.Name = fontName;

range.Font.NameAscii = fontName;

range.Font.NameOther = fontName;

// tried setting NameFarEast = fontName too; no change

range.Font.NameBi = fontName;

Debug.WriteLine($"expected: {fontName}, actual: {range.Font.Name}, NameOther: {range.Font.NameOther}");

}

What I’ve already tried / know:

  1. Toggle ShowCodes true → set fonts → ShowCodes false; also tried Update then set Result fonts. Still falls back.
  2. I map math alphanumeric Unicode to regular Greek (U+03B1, etc.) to avoid Cambria Math dependency.
  3. NameOther/NameAscii/NameBi are set; Name is empty when read back; final rendering still uses default font for Greek.
  4. Applying the same ApplyFontFamily to a normal text range works (Greek uses target font). Only EQ fields misbehave.
  5. Manually selecting the field result in Word UI and changing font forces Greek to the target font. Doing it via code fails.

Questions:

• Is there a reliable way to force Greek letters inside EQ fields to use the specified Latin font (e.g., Trebuchet MS) without fallback?

• Is there a required order (ShowCodes/Update) to make the font stick on Code/Result?

• Do EQ fields have a hidden font priority for non-ASCII? Must NameFarEast/NameOther be combined in a specific way?

• Any sample code or official guidance to ensure Greek in EQ fields obeys the specified font?

Thanks for any insights. I can provide more logs/tests if needed.

Microsoft 365 and Office | Development | Microsoft 365 Developer Program

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.