I am using a RT field in my web-based form because I can control the size with the HTML attributes. However, when a document is in read mode, the font defaults to Times New Roman (or something).
How do I change the font?
I am using a RT field in my web-based form because I can control the size with the HTML attributes. However, when a document is in read mode, the font defaults to Times New Roman (or something).
How do I change the font?
Subject: change font in rich text fields? (web)
I wrote the following code in a button on a web form that reformatted the font in a rich text field to the Font I wanted (in this case it was Garamond). You can also use it with a blank rich text field to add a new font to the list of selectable fonts on the web.
When the document is opened, the font of the text stays the same as the way it was saved.
In this code, my rich text field name is ‘Details’.
Hope it helps you.
Alex
var rtForm = window.document;
var html_text = “”;
var new_html_text = “”;
var checkChar = “”;
var sectionHTML = “”;
var checkSection = “0”;
var form = rtForm.forms[0];
// this makes sure there is an applet on the form somewhere
appletName = “lnaDetails”;
if (rtForm.applets[appletName] != null)
{
// Get the existing text/html code
html_text = rtForm.applets[appletName].getText("text/html");
if (fullTrim(html_text) != "")
{
// Check and reformat the text so that we can convert the font
for (k = 0; k < html_text.length; k++)
{
// check the character
checkChar = html_text.charAt(k);
if (checkChar == "<")
{
// Beginning of a new HTML code section
checkSection = "1";
sectionHTML = "<";
}
else if (checkChar == ">")
{
// Check if this is a FONT section
if (sectionHTML.search("FONT") != -1 || sectionHTML.search("/FONT") != -1)
{
// Do not add sections which relate to font as we put these at the beginning and end of the text
}
else
{
sectionHTML = sectionHTML + ">";
// Append the word to the new formatted text
new_html_text = new_html_text + sectionHTML;
}
// Rest the HTML section flag
checkSection = "0";
}
else
{
if (checkSection == "1")
{
sectionHTML = sectionHTML + checkChar
}
else
{
new_html_text = new_html_text + checkChar;
}
}
}
// Add the FONT to the beginning and end of the TEXT/HTML
new_html_text = "<FONT SIZE=4 FACE='Garamond'>" + new_html_text + "</FONT>";
// alert(html_text + " < ****** > " + new_html_text);
// Put the text back in formatted
rtForm.applets[appletName].setText("text/html", new_html_text);
}
}
Subject: RE: change font in rich text fields? (web)
I didn’t fully explain. I am not using the RT applet, just the HTML version.
I guess I’ll just use field translation and put some font tags around the text.