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

Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

Colter Roche asked in Rails

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.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,399+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.