Font-family attribute for default font

4 posts, 0 answers
  1. HSLaw
    HSLaw avatar
    159 posts
    Member since:
    Jan 2006

    Posted 06 Mar 2013 Link to this post


    How to enable the font family attribute for the default font?

    We have an editor for user to construct their email to send email newsletter.

    The default font is Arial so when user select Arial, it doesn't have the font tag.

    The problem comes when recipient receive the email in Outlook or other email clients that uses Times New Roman as default font.
    This will render the text as Times New Roman since there is no font-tag in the email.


  2. Rumen
    Rumen avatar
    14324 posts

    Posted 11 Mar 2013 Link to this post


    The problem that you experience is explained in the following KB article: No FONT tags are applied when I type text in the editor. The FontSize and FontName tools will not apply a font tag to the selected content, if the user selects the same font size and font name as the default one of the browser (content area).

    You can use the following code solution to wrap the initial content or the empty content of RadEditor in a span tag with Arial 14px, e.g.

    Copy Code
    <telerik:radeditor runat="server"OnClientLoad="OnClientLoad"ID="RadEditor1">
    <script type="text/javascript">
    function OnClientLoad(editor) {
    setTimeout(function() {
    var tool = editor.getToolByName("RealFontSize");
    var args = newTelerik.Web.UI.EditorCommandEventArgs("RealFontSize", null, "14px");"RealFontSize", args);"FontName", { value: "Arial"});
    }, 0);

    Another way is to wrap the obtained content on the server in a span tag having the desired font-size style in pixels, e.g.

    RadEditor1.Content = "<span style='font-family: Arial;font-size: 14px;'>" + RadEditor1.Content + "</span>";

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Charles
    Charles avatar
    33 posts
    Member since:
    Feb 2013

    Posted 06 Sep 2017 in reply to Rumen Link to this post

    The script above does not work when the editor is in a radPageView. The getToolByName returns null and the .set_value throws an error. Can you come up with a workaround?
  4. Rumen
    Rumen avatar
    14324 posts

    Posted 06 Sep 2017 Link to this post

    Hi Charles,

    You can try the following approach:

    <telerik:RadTabStrip ID="RadTab1" runat="server" OnClientTabSelected="OnClientTabSelecting" SelectedIndex="0" MultiPageID="RadMultiPage1">
            <telerik:RadTab runat="server" PageViewID="RadPageView1"  Text="RadTab1">
            <telerik:RadTab runat="server" PageViewID="RadPageView2" Text="RadTab2">
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server">
        <telerik:RadPageView ID="RadPageView1" Selected="true" runat="server">
            <telerik:RadEditor ID="RadEditor1" runat="server"OnClientLoad="OnClientLoad"></telerik:RadEditor>
        <telerik:RadPageView ID="RadPageView2" runat="server">
            <telerik:RadEditor ID="RadEditor2" runat="server" ></telerik:RadEditor>
        function OnClientLoad(editor) {
            try {
                setTimeout(function () {
                    var tool = editor.getToolByName("RealFontSize");
                    var args = newTelerik.Web.UI.EditorCommandEventArgs("RealFontSize"null"13px");
          "RealFontSize", args);
          "FontName", { value: "Tahoma" });
            catch (err) { }
        function OnClientTabSelecting(sender, args) {
            var tab = args.get_tab();
            if (tab.get_text() == "RadTab2") {
                setTimeout(function () {
                    var editor2 = $find("<%=RadEditor2.ClientID%>");
                var args = new Telerik.Web.UI.EditorCommandEventArgs("RealFontSize",null"13px");
      "RealFontSize", args);
                    var tool = editor2.getToolByName("RealFontSize");
          "FontName", { value: "Tahoma" });
                }, 100);

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top