Racoon
Racoon

Reputation: 9

Laravel Font face in layout and other blade

I have layout view with one css and two fonts in header, and yield header for another blade views:

{{ HTML::style('css/style1.css') }}
@yield('header')
<style type="text/css">@font-face { font-family:nav-font; src: url('font/brandon_grotesque_medium.ttf'); }</style>
<style type="text/css">@font-face { font-family:Noto-Sans; src: url('font/NotoSans-Bold.ttf'); }</style>

They both work fine in in this layout view. But i have another view:

@extends('layout')
@section('header')
{{ HTML::style('css/posts/style2.css') }}
@stop
@section('content')
    My content here.
@stop

style2 Css works fine in my second view, but fonts are missing. I have tried to put font scripts in header section in my second view, but still nothing. What can be the problem?

Upvotes: 0

Views: 6492

Answers (1)

lagbox
lagbox

Reputation: 50491

You could use the asset() Helper for an example.

<style type="text/css">@font-face { 
    font-family:nav-font; src: url('{{ asset('font/brandon_grotesque_medium.ttf') }}'); 
}</style>
<style type="text/css">@font-face { 
    font-family:Noto-Sans; src: url('{{ asset('font/NotoSans-Bold.ttf') }}'); 
}</style>

This type of approach will remove the need for the relative pathing as it will resolve to an absolute Url. This will remove the "relative sorcery" as zwacky had mentioned in the comments.

Upvotes: 2

Related Questions