Jump to content

Recommended Posts

Posted

  UniServerModule.CustomFiles.Add('<link rel="stylesheet" href="fonts/css/all.css">');
  s:= 'i { '+
        '    color: red; '+
        '    vertical-align: sub; '+
        '    font-size: 50px; '+
        '  } '+
        'i::before { '+
        '  font-size: 30px; '+
        '  } ';
UniServerModule.CustomCSS.Add(s);

HtmlMemo text: '... and record (<i class="fa fa-bookmark" aria-hidden="true"></i>) location<br> ...'

Please show how to embed Font Awesome Symbols within HtmlMemo text - thanks.

Posted
3 hours ago, andyhill said:

Please show how to embed Font Awesome Symbols within HtmlMemo text - thanks.

You can try to use this approach:

1. UniHTMLMemo.ClientEvents.ExtEvents ->

function initialize(sender, eOpts) 
{
    var _link;
    document.getElementsByTagName('head')[0].childNodes.forEach(function(el) {
        if (el.tagName == 'LINK' && el.href.toString().search('/font-awesome/') > -1) {
            _link = el.outerHTML;
        }
    });

    if (_link) {
        sender.iframeEl.dom.contentDocument.head.innerHTML += _link;
    }
}

2. And add like this:

<i class="fa fa-bookmark" aria-hidden="true"></i>

 

Posted

Thank you Sherzod, however it is not working, what have I missed:-

SERVERMODULE

procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject);
begin

  //////////////////////////////////////////////////////////////////////////////
  // Init
  IgnoreAccessViolation:= False;

  //////////////////////////////////////////////////////////////////////////////
  UniServerModule.CustomFiles.Add('<link rel="stylesheet" href="fonts/css/all.css">');
  //
  UniServerModule.CustomCSS.Add('.redIcon { color: red; }');
  //
  UniServerModule.CustomCSS.Add('i { '+
                                '    color: red; '+
                                '    vertical-align: sub; '+
                                '    font-size: 50px; '+
                                '  } '+

                                'i::before { '+
                                '  font-size: 30px; '+
                                '  } ');

  //////////////////////////////////////////////////////////////////////////////

EDITORFORM

procedure TfEditor.UniFormCreate(Sender: TObject);
var
  s: String;
begin

  //////////////////////////////////////////////////////////////////////////////
  HtmlMemo.ClientEvents.ExtEvents.Clear;
  // Font Awesome
  s:= 'initialize=function initialize(sender, eOpts) '+
      '{ '+
      '  var _link; '+
      '  document.getElementsByTagName(''head'')[0].childNodes.forEach(function(el) '+
      '  { '+
      '    if (el.tagName == ''LINK'' && el.href.toString().search(''/font-awesome/'') > -1) '+
      '    { '+
      '      _link = el.outerHTML; '+
      '    } '+
      '  }); '+
      '  if (_link) '+
      '  { '+
      '    sender.iframeEl.dom.contentDocument.head.innerHTML += _link; '+
      '  } '+
      '} ';
  HtmlMemo.ClientEvents.ExtEvents.Add(s);

  //////////////////////////////////////////////////////////////////////////////

 

FontAwesome.png

HtmlMemoBookmark0.jpg

HtmlMemoBookmark1.jpg

Posted
7 hours ago, andyhill said:

// Font Awesome   s:= 'initialize=function initialize(sender, eOpts) '+       '{ '+       '  var _link; '+       '  document.getElementsByTagName(''head'')[0].childNodes.forEach(function(el) '+       '  { '+       '    if (el.tagName == ''LINK'' && el.href.toString().search(''/font-awesome/'') > -1) '+       '    { '+       '      _link = el.outerHTML; '+       '    } '+       '  }); '+       '  if (_link) '+       '  { '+       '    sender.iframeEl.dom.contentDocument.head.innerHTML += _link; '+       '  } '+       '} ';   HtmlMemo.ClientEvents.ExtEvents.Add(s);

This is correct.

7 hours ago, andyhill said:

////////////////////////////////////////////////////////////////////////////// UniServerModule.CustomFiles.Add('<link rel="stylesheet" href="fonts/css/all.css">'); // UniServerModule.CustomCSS.Add('.redIcon { color: red; }'); // UniServerModule.CustomCSS.Add('i { '+ ' color: red; '+ ' vertical-align: sub; '+ ' font-size: 50px; '+ ' } '+ 'i::before { '+ ' font-size: 30px; '+ ' } '); //////////////////////////////////////////////////////////////////////////////

Not sure,
I have no "fonts/css/all.css" to check. Please make a simple testcase if possible.

Posted
9 minutes ago, andyhill said:

"fonts" are the free font awesome files

fonts.zip

OK Andy,

I guess you don't need to include this, because, we already include the font in the initialize event: initialize=function initialize(sender, eOpts)...

8 hours ago, andyhill said:

however it is not working, what have I missed

If it doesn't work for you, please create a full test app to check.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...