Bootstrap comes with 180 icons (glyphicons) in form of ttf, svg and woff files. Old one only has 140.

Old bootstrap used sprite image, so
'render' => 'sprite'
should probably change, but I don't know to what.

New bootstrap needs glyphicon class so I implemented this hook: bootstrap_preprocess_icon (why aren't preprocess functions called from included files? I had to put it template.php to get it working...). I don't know if it's the proper way to do that.


markcarver’s picture

Preprocess functions aren't called from because that file is loaded only when needed with the Icon API. This is to help not bloat the memory footprint, so putting the preprocess function in template.php is required, yes.

A few minor issues:

  1. +++ b/includes/
    @@ -32,146 +32,206 @@ function bootstrap_icon_bundles() {
           'tag' => 'i',
         'icons' => array(

    I know that the glypicons are now font based. They should remain "sprite" (which just means CSS). I'm not sure though if maybe we need to also figure out a way to disable them if the "font" directory is not detected. Maybe wrap the entire hook_icon_bundles() in an if?

  2. +++ b/template.php
    @@ -307,3 +307,19 @@ function bootstrap_bootstrap_search_form_wrapper(&$variables) {
    +  ¶

    All the icons and this line have whitespace at the end of the line. Please remove them. Also I would recommend downloading and installing Dreditor and view the above patch for yourself to see how quickly these are discovered :)

kslonka’s picture

new16.34 KB

Removed whitespace and prepared if statement.

markcarver’s picture

+++ b/includes/
@@ -20,159 +20,227 @@ function bootstrap_icon_providers() {
+  global $theme_path;
+  $cnd = theme_get_setting('cdn_bootstrap');
+  // TODO: check if font folder exists, don't know how exactly do that, should be something like this (uncomment):
+  if( $cnd == 1
+     // || ($cnd == 0 && is_dir(getcwd().'/sites/all/'.$theme_path.'/bootstrap/fonts'))
+    ) {

A sub-theme may actually have their own fonts, we need to specifically check whether glyphicons exists (with using Drupal to find the theme path, this assumes we know it's in sites/all/themes). Here is what I'm thinking (not tested, just wrote here. PS: the variable should be named $cdn):

global $theme;
$cdn = (bool) theme_get_setting('cdn_bootstrap');
if ($cdn || (!$cdn && file_exists(drupal_get_path('theme', $theme) . '/fonts/glyphicons-halflings-regular.ttf')) {
markcarver’s picture

Any chance to work on this?

kslonka’s picture

Once I finish other projects I will :)

ionmedia’s picture

is now a way to use font icons with cdn enabled by default ?

kslonka’s picture

Mark: Can you write what needs to be done, before this gets commited?

kslonka’s picture

new15.39 KB

Tested and should be working.

markcarver’s picture

Status:Needs work» Fixed

Thanks @kslonka!

Committed 33a1d6e to 7.x-3.x.

Committed 9425e4f to 7.x-3.x.

kslonka’s picture

Mark: While doing this I found a bug in less files, more info: could you reopen that issue?

markcarver’s picture

Version:7.x-3.x-dev» 7.x-3.0-beta1

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.