Skip to content

Commit

Permalink
font helper broken attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Aug 21, 2013
1 parent 79d39e4 commit 2b717ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/bootstrap-sass/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Bootstrap
VERSION = '3.0.0.0'
BOOTSTRAP_SHA = 'e143c3547241a1f92f54849ffbcb0745f3f8002c'
BOOTSTRAP_SHA = 'fee05d1f3e83e3d64a630879eea592e74e06820d'
end
10 changes: 9 additions & 1 deletion tasks/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def process_stylesheet_assets
when 'variables.less'
file = insert_default_vars(file)
file = replace_all file, /(\$icon-font-path:).*(!default)/, '\1 "bootstrap/" \2'
file = append_text file, "// [converter] injected var\n$twbs-font-url-helper: font-url !default;"
when 'close.less'
# extract .close { button& {...} } rule
file = extract_nested_rule file, 'button&'
Expand All @@ -112,7 +113,7 @@ def process_stylesheet_assets
when 'glyphicons.less'
file = replace_rules(file, '@font-face') { |rule|
rule = replace_all rule, /(\$icon-font-\w+)/, '#{\1}'
replace_all rule, /url\(/, 'font-url('
replace_all rule, /url\(/, '#{$twbs-font-url-helper}('
}
end

Expand Down Expand Up @@ -352,13 +353,20 @@ def replace_file_imports(less, target_path = 'bootstrap/')
%Q(@import "#{target_path}\\1";)
end

# logged gsub that raises when there is no match
def replace_all(file, regex, replacement = nil, &block)
log_transform regex, replacement
new_file = file.gsub(regex, replacement, &block)
raise "replace_all #{regex}, #{replacement} NO MATCH" if file == new_file
new_file
end

# logged +=
def append_text(file, text)
log_transform text
"#{file}\n#{text}"
end

# @mixin a() { tr& { color:white } }
# to:
# @mixin a($parent) { tr#{$parent} { color: white } }
Expand Down
10 changes: 5 additions & 5 deletions vendor/assets/stylesheets/bootstrap/_glyphicons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
// Import the fonts
@font-face {
font-family: 'Glyphicons Halflings';
src: font-url('#{$icon-font-path}#{$icon-font-name}.eot');
src: font-url('#{$icon-font-path}#{$icon-font-name}.eot?#iefix') format('embedded-opentype'),
font-url('#{$icon-font-path}#{$icon-font-name}.woff') format('woff'),
font-url('#{$icon-font-path}#{$icon-font-name}.ttf') format('truetype'),
font-url('#{$icon-font-path}#{$icon-font-name}.svg#glyphicons-halflingsregular') format('svg');
src: #{$twbs-font-url-helper}('#{$icon-font-path}#{$icon-font-name}.eot');
src: #{$twbs-font-url-helper}('#{$icon-font-path}#{$icon-font-name}.eot?#iefix') format('embedded-opentype'),
#{$twbs-font-url-helper}('#{$icon-font-path}#{$icon-font-name}.woff') format('woff'),
#{$twbs-font-url-helper}('#{$icon-font-path}#{$icon-font-name}.ttf') format('truetype'),
#{$twbs-font-url-helper}('#{$icon-font-path}#{$icon-font-name}.svg#glyphicons-halflingsregular') format('svg');
}

// Catchall baseclass
Expand Down
3 changes: 3 additions & 0 deletions vendor/assets/stylesheets/bootstrap/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,6 @@ $container-desktop: ((940px + $grid-gutter-width)) !default;

// Large screen / wide desktop
$container-lg-desktop: ((1140px + $grid-gutter-width)) !default;

// [converter] injected var
$twbs-font-url-helper: font-url !default;

0 comments on commit 2b717ee

Please sign in to comment.