Fixing an Issue with Glyphicons with a Bootswatch Theme in XPages

In this post, I’ll describe an issue that I had with glyphicons when using a Bootswatch theme in XPages and how to fix it.

When you use a Bootswatch theme, you do not need to separately include the original
bootstrap.css file. In fact, it would be inefficient to do so, because the styling is provided by the Bootswatch CSS file.

When adding any additional Javascript libraries or CSS to an XPages application, I generally put them in their own folder under WebContent and then include the library or stylesheet via the application theme.


However, I noticed an issue when doing this recently. The Bootswatch theme styling loaded fine, but glyphicons on the page were
not displayed properly; the unrecognized font character symbol was displayed instead.

Glyphicons are loaded as a font (much like Font Awesome), so I looked through the stylesheet to see how the font was included. As you can see, the reference is relative to the current directory, assuming a standard Bootstrap directory structure.

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');

There are two ways to go about fixing this:

  1. You can update the font references to be relative to the actual directory structure.
  2. Much more simply, you can move the bootswatch CSS file into the css directory under the bootstrap directory so the relative font file references work without being modified.


9 responses to “Fixing an Issue with Glyphicons with a Bootswatch Theme in XPages”

  1. Brian Gleeson says :

    You might want to check that the icons work okay when aggregation is turned on as well. We ran into issues with that ourselves when adding Bootstrap to the Extension Library.

    • Brad Balassaitis says :

      Thanks for the tip. The icons did fail when I enabled resource aggregation.

      Is there a better solution than just disabling the aggregation?

      • bgleesonie says :

        We changed the urls to “src: url(‘/xsp/.ibmxspres/.extlib/responsive/bootstrap-3.2.0-dist/fonts/glyphicons-halflings-regular.eot’);”, which loads whether aggregation is on or off. In your case with the resources inside the NSF, I think you could use “src: url(‘/bootswatch/fonts/glyphicons-halflings-regular.eot’);

      • Brad Balassaitis says :

        Thank you very much!

  2. edm00se says :

    I was going to suggest a third potential fix being to use a CDN, but watch out which one you use. I loaded an example using the cerulian bootswatch theme from CDNJS, but it’s not loading the glyphicons due to a response of a 404 for the glyphicon font files (a known issue open on CDNJS’s GH repo, relating to their mapping of the fonts path). Others, like using the link to bootswatch’s demo page, work fine.

  3. Pantelis Botsas says :

    We tried several ways to get this thing working either in XPiNC or Web-Browser.

    Finally we included the fonts as base64-encoded string, which fixed all font issues in XPinC and Web-Browser.

    Sure it is an efford to encode the font-file (whatever type it is) every time when a new version is released, but this solution also has an positive effect on load performance.

    @font-face {
    font-family: ‘MyCoolFont’;
    font-style: normal;
    font-weight: normal;
    /* src: url(‘../font/mycoolfont.woff’) format(‘woff’); */
    src: url(data:application/x-font-woff;base64,{putYourBase64EncodedFontStringHere}) format(‘woff’);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: