font not working

51 views
Skip to first unread message

fugee ohu

unread,
Dec 6, 2015, 3:03:46 PM12/6/15
to Ruby on Rails: Talk
I can't get my fonts to work

Having trouble getting fonts to work I was using Berlin Sans Serif but it was working so I tried downloading another font to replace it but that's not working either

I placed the font in app/assets/fonts and in my stylesheet i put the following:

    p@font-face {
        font-family: "negro";
        src: url(/assets/fonts/ufonts.com_metrolis-negro-opentype.otf) format("truetype");
    }


#larger_blue_text {
     color: #0000FF;
     font-family: "negro";
}

And in my view i put:

 <span id="larger_blue_text"> Some text</span>

Colin Law

unread,
Dec 6, 2015, 3:13:44 PM12/6/15
to Ruby on Rails: Talk
I think you might have to setup config.assets.path, though I am not
certain. See
https://gist.github.com/anotheruiguy/7379570

Colin

fugee ohu

unread,
Dec 6, 2015, 5:10:38 PM12/6/15
to Ruby on Rails: Talk
So then I have to add to my assets.rb file something beginning with Rails.application.config.assets.precompile += %w(     ?

fugee ohu

unread,
Dec 6, 2015, 5:58:53 PM12/6/15
to Ruby on Rails: Talk
It said to add
config.assets.paths << Rails.root.join("app", "assets", "fonts")
to application.rb, i did that and restarted the server but it didn't help
It also said for rails 4 you don't have to do anything but place the font
file in assets/fonts but otherwise for rails 4.2+ I'm using rails 4.18 and
it doesn't say anything specifically to 4.1+ so can i assume my version should
be treated as 4, i don't know

On Sunday, December 6, 2015 at 3:13:44 PM UTC-5, Colin Law wrote:

fugee ohu

unread,
Dec 6, 2015, 6:27:51 PM12/6/15
to Ruby on Rails: Talk
I changed
src: url(/assets/fonts/ufonts.com_
metrolis-negro-opentype.otf) format("truetype");
to
src: font-url(/assets/fonts/ufonts.com_
metrolis-negro-opentype.otf) format("truetype");
and that got me a syntax error expected ")" was ".otf..."
that error goes away and the page comes back if i put single quotes
src: url('/assets/fonts/ufonts.com_
metrolis-negro-opentype.otf') format("truetype");
but the font still doesn't get applied



On Sunday, December 6, 2015 at 3:13:44 PM UTC-5, Colin Law wrote:

nanaya

unread,
Dec 6, 2015, 11:50:32 PM12/6/15
to rubyonra...@googlegroups.com
Hi,

On Mon, Dec 7, 2015, at 08:27, fugee ohu wrote:
> I changed
> src: url(/assets/fonts/ufonts.com_
> metrolis-negro-opentype.otf) format("truetype");
> to
> src: font-url(/assets/fonts/ufonts.com_
> metrolis-negro-opentype.otf) format("truetype");
> and that got me a syntax error expected ")" was ".otf..."
> that error goes away and the page comes back if i put single quotes
> src: url('/assets/fonts/ufonts.com_
> metrolis-negro-opentype.otf') format("truetype");
> but the font still doesn't get applied
>
>

font-url automatically resolves the path to `/assets/fonts` for you so
all you need is:

src: font-url("ufonts.com_metrolis-negro-opentype.otf")
format("truetype");

Colin Law

unread,
Dec 7, 2015, 4:01:38 AM12/7/15
to Ruby on Rails: Talk
On 6 December 2015 at 22:58, fugee ohu <fuge...@gmail.com> wrote:
> It said to add
>
> config.assets.paths << Rails.root.join("app", "assets", "fonts")
> to application.rb, i did that and restarted the server but it didn't help
> It also said for rails 4 you don't have to do anything but place the font
> file in assets/fonts but otherwise for rails 4.2+ I'm using rails 4.18 and
> it doesn't say anything specifically to 4.1+ so can i assume my version
> should
> be treated as 4, i don't know

There is no Rails 4.18

Colin

>
>
> On Sunday, December 6, 2015 at 3:13:44 PM UTC-5, Colin Law wrote:
>>
>> On 6 December 2015 at 20:03, fugee ohu <fuge...@gmail.com> wrote:
>> > I can't get my fonts to work
>> >
>> > Having trouble getting fonts to work I was using Berlin Sans Serif but
>> > it
>> > was working so I tried downloading another font to replace it but that's
>> > not
>> > working either
>> >
>> > I placed the font in app/assets/fonts and in my stylesheet i put the
>> > following:
>> >
>> > p@font-face {
>> > font-family: "negro";
>> > src: url(/assets/fonts/ufonts.com_metrolis-negro-opentype.otf)
>> > format("truetype");
>> > }
>> >
>> >
>> > #larger_blue_text {
>> > color: #0000FF;
>> > font-family: "negro";
>> > }
>> >
>> > And in my view i put:
>> >
>> > <span id="larger_blue_text"> Some text</span>
>>
>> I think you might have to setup config.assets.path, though I am not
>> certain. See
>> https://gist.github.com/anotheruiguy/7379570
>>
>> Colin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/b55e973b-bef4-46ab-8e92-580da262d5aa%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages