Is there a way to override Rich Text Area field font-family with apex code? My first attempt was with !important key-word in inline style for tag, but the style was erased.
Steps to reproduce:
SELECT Notes__c FROM Account
<span style="font-family: simsun;">123</span>
Then execute code in Dev Console:
Account a = [SELECT Notes__c FROM Account LIMIT 1];
a.Notes__c = '<span style="font-family: Montserrat !important;">' + a.Notes__c + '</span>';
update a;
Then retrieve Notes once more:
SELECT Notes__c FROM Account
<span style=""><span style="font-family: simsun;">123</span></span>
NOTE 1:
If I update Rich Text Area field without !important
it looks like:
<span style="font-family: Montserrat;"><span style="font-family: simsun;">123</span></span>
But it does not override inner font-family (as expected).
NOTE 2:
I see the possibility with parsing Rich Text Area field content and removing all occurrences of font-family:...;
from it, but I try to find an easier way.
NOTE 3: (related to @arut's answer)
I do have different font-families, so font-family: simsun;
was just for example. Therefore, I cannot use replace.