Skip to main content

bad URI(is not URI?): Gotham Bold Regular.ttf error, how to fix?

Rails • Asked by Colter Roche

I followed all the steps to add a fonts folder, register it with rails, and declare the @font-face in my .scss, but the same error keeps occuring. I am using rails 5.1.4, with the foundation framework for css. Please let me know what i need to do to fix this.

gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'foundation-rails'

gem 'serviceworker-rails'

gem 'coffee-script-source', '1.8.0'

custom.scss:

$textH1: #1798CB;
$textMain: #005D7D;
$accent1: #003262;
$accent2: #83B6CD;
$accent3: #B7CDD9;
$accent4: #CEEBEF;
$accent5: #E1EBF4;
$accent6: #DFE1DF;
$accent7: #F1563F;
$accent8: #62BB46;
$accent9: #f41b49;

@font-face {
    font-family: "Gotham Bold Regular";
    src:font-url('Gotham Bold Regular.ttf') format('truetype');
}

@font-face {
    font-family: "Gotham Book Regular";
    src:font-url('Gotham Book Regular.eot') format('embedded-opentype');
}

h1 {
    color: #1798CB;
    font-family: "Gotham Bold Regular";
}

h2 {
    color: #005D7D;
    font-family: "Gotham Book Regular";
}

.top-bar {
    background-color: #003262;
}

.top-bar-section ul {
    background-color: #003262;
}


.top-bar-section ul.right {
    background-color: #003262
}
.top-bar-section li a:not(.button) {
    background-color: #003262;
}

.top-bar-section ul li.active > a {
   background-color: #003262;
}

/** Changes the hover state of non active menu items **/
.top-bar-section li:hover a {
    background-color: #003262;
}


.top-bar-section ul li > a {
    background-color: #003262;
}

Application.rb:

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Webapp
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1
    config.assets.paths << Rails.root.join("app", "assets", "fonts")
    config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
  end
end

Could you try it without spaces in the font file name? Also I am almost sure that that /font is loaded by default already.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.