1

I am building a static website to use as a blog with the R blogdown package which acts as a wrapper for the Hugo static website generator.

I would like to have a line of social media icons immediately underneath the title which I have achieved somewhat using the FontAwesome toolkit which was already being used by the theme I chose.

However I would like to include some icons not present in the toolkit. Some I found in the Academions project and one I made myself as a single layer SVG in Inkscape. It is a square icon for Pocket.

enter image description here

I combined them all into a custom font (called customfonts) using the Icomoon app and placed the fonts in my Hugo static/fonts directory and the CSS file in my static/css directory. I also amended the file paths in the CSS file to point to the static/fonts directory and added in style classes which are like the ones in the FontAwesome CSS file.

I call the CSS files in my page footer and have tried to insert the icons.

When I use one of the icons originally from the Academicons font like so:

<i class="cf cf-GoogleScholar cf-3x"></i>

I get the icon but when I try to insert my custom icon like so:

<i class="cf-pocket-square cf-3x"></i>

I do not get the icon displayed.

When I inspect the HTML I can see it in the code. enter image description here

enter image description here

There must therefore be something wrong with the SVG I made. However I do not know what that is or how to fix it.

I have placed the SVG I made, the CSS file and the font files in this directory.

How can I get my icon to display?

EDIT: I have added a MWE to the directory linked above.

Here is the HTML:

<html class="wf-opensans-i3-active wf-opensans-i7-active wf-opensans-n3-active wf-opensans-n7-active wf-breeserif-n4-active wf-active" lang="en-us">
  <head>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css">
    <link rel="stylesheet" href="./customfonts.css">
  </head>
  <body>
    This one works:
    <div>
      <a href="EXAMPLE" rel="me"><i class="fa fa-twitter-square fa-3x"></i></a>
      <a href="EXAMPLE" rel="me"><i class="fa fa-facebook-square fa-3x"></i></a>
      <a href="EXAMPLE" rel="me"><i class="cf cf-GoogleScholar cf-3x"></i></a>
    </div>
    This one with my custom icon does not:
    <div>
      <a href="EXAMPLE" rel="me"><i class="fa fa-twitter-square fa-3x"></i></a>
      <a href="EXAMPLE" rel="me"><i class="fa fa-facebook-square fa-3x"></i></a>
      <a href="EXAMPLE" rel="me"><i class="cf cf-pocket-square cf-3x"></i></a>
    </div>
  </body>
</html>

This is what the output looks like:

enter image description here

This is what the top of the CSS file looks like:

@font-face {
  font-family: 'customfonts';
  src:  url('./customfonts.eot?7cqlun');
  src:  url('./customfonts.eot?7cqlun#iefix') format('embedded-opentype'),
    url('./customfonts.ttf?7cqlun') format('truetype'),
    url('./customfonts.woff?7cqlun') format('woff'),
    url('./customfonts.svg?7cqlun#customfonts') format('svg');
  font-weight: normal;
  font-style: normal;
}

.cf {
    display:inline-block;
    font:normal normal normal 14px/1 customfonts;
    font-size:inherit;
    text-rendering:auto;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
}

.cf-pocket-square .path1:before {
  content: "\e900";
  color: rgb(0, 0, 0);
}
.cf-pocket-square .path2:before {
  content: "\e901";
  margin-left: -1em;
  color: rgb(0, 0, 0);
}
.cf-pocket-square .path3:before {
  content: "\e902";
  margin-left: -1em;
  color: rgb(255, 255, 255);
}
.cf-GoogleScholar:before {
  content: "\e903";
}

+ style classes ...

Edit #2: @grinmax correctly pointed out that the HTML structure was inconsistent. Following his suggestions gave the following results:

  • Change the HTML

enter image description here

  • Change the CSS

enter image description here

While the icon is being produced it is not correct as IcoMoon appears to have separated the layers I used to create the icon. However when I look at the SVG I used to make the font I can confirm that I condensed them all into one layer so I don't know hot this is occurring. What am I missing?

enter image description here

EDIT #3: Since it appears my SVG is the problem I have been trying to get it right. I have made some progress but also asked a question here.

Community
  • 1
  • 1
G_T
  • 1,555
  • 1
  • 18
  • 34
  • I don't understand, you are displaying characters in a font.. .why do you think you can replace them with a svg? – Hogan Mar 01 '17 at 04:00
  • I am new to this sort of thing so might be wrong but as I understand it I made the new icon as an SVG and then used it to create a new font. I got this idea from this question http://stackoverflow.com/questions/17941120/how-can-i-edit-font-awesome-or-include-my-own-icons – G_T Mar 01 '17 at 04:03
  • @Hogan -- G_T used [Icomoon](https://icomoon.io/), which allows you to create custom font sets out of SVG for use on webpages. – Alexander Nied Mar 01 '17 at 04:04

2 Answers2

1

@grinmax correctly pointed out that my HTML structure was inconsistent and following his suggestions I overcame the issue of the custom icon not displaying. However it was not displaying correctly.

I realised that the font the Icomoon app had created had split the shapes in the SVG into separate glyphs, despite it being a single layer on Inkscape. I therefore redrew the SVG to be contained within a single <path> tag (see here) and regenerated the font using Icomoon.

I have created an addition to the MWE which looks like this:

enter image description here

This is what I wanted. The HTML is the same as what I presented above and the CSS is that suggested by @grinmax.

Community
  • 1
  • 1
G_T
  • 1,555
  • 1
  • 18
  • 34
0

This don't follow yor html structure

.cf-pocket-square .path1:before {
  content: "\e900";
  color: rgb(0, 0, 0);
}
.cf-pocket-square .path2:before {
  content: "\e901";
  margin-left: -1em;
  color: rgb(0, 0, 0);
}
.cf-pocket-square .path3:before {
  content: "\e902";
  margin-left: -1em;
  color: rgb(255, 255, 255);
}

Try use this html structure

<i class="cf cf-pocket-square cf-3x">
  <span class="path1"></span>
  <span class="path2"></span>
  <span class="path3"></span>
</i>

or

.cf-pocket-square:before {
  content: "\e900";
  color: rgb(0, 0, 0);
}

and show me please result

G_T
  • 1,555
  • 1
  • 18
  • 34
grinmax
  • 1,835
  • 1
  • 10
  • 13
  • Hi @grinmax, thanks for your help. I have updated my question with the results. – G_T Mar 04 '17 at 22:04
  • 1
    while your answer didn't completely answer my question it did go halfway and it set me on the right direction for the other half so I have awarded you the bounty. – G_T Mar 05 '17 at 06:17