Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include a bootstrap glyphicon in SVG

Tags:

css

svg

I followed this SO answer to include glyphicons in my SVG but it's not working.

This is the SVG code that I want to implement the icon into:

  <text
    ng-attr-x="{{node.width/2}}"
    ng-attr-y="{{node.height/2+5}}"
    text-anchor="middle"
    ng-attr-fill="{{(node.activity.act_task==3 || node.activity.act_task==4)?'#FFFFFF':'#000000';}}">
    <tspan x="130" dy="0em">&#e003</tspan>
    <tspan x="130" dy="1.2em" ng-show="node.activity.act_type == 1 && node.height > 30"><a target="_blank" href="http://{{node.activity.act_info_url}}" style="text-decoration: underline">{{node.activity.act_info}}</a></tspan>
  </text>

and I added to my css file:

svg text{
  font-family: 'Glyphicons Halflings';
}

But that didn't work, it just shows the &#e003 as text instead of the search icon i am after which is the glyphicon-search icon. I also tried /e003 & &e003 and #e003 but without any luck.

Is there a way I can add in glyphicons into svg components?

like image 473
Naguib Ihab Avatar asked Nov 30 '16 06:11

Naguib Ihab


People also ask

How do I use downloaded bootstrap icons?

Go to the official site of Bootstrap & copy the Bootstrap CDN for CSS, JS, Popper. js, and jQuery links. Add the CDN link along with add font icon link inside the <head> tag. Add the class with bi bi-icon_name followed by the name of the icon.

Where are bootstrap Glyphicons stored?

Where to find Glyphicons? Associated CSS rules are present within bootstrap. css and bootstrap-min. css files within css folder of dist folder.


1 Answers

Your entity is wrong.

Entities are by default decimal, not hexadecimal. If you want to use hexadecimal, you have to put an x after the #.

Also, the entity must end with a semicolon. So what you should have used is:

&#xe003;
like image 133
Paul LeBeau Avatar answered Sep 30 '22 20:09

Paul LeBeau