Skip to content

Commit

Permalink
Merge pull request #169 from codedge/font-path
Browse files Browse the repository at this point in the history
Define font via env var
  • Loading branch information
codedge authored Jul 22, 2022
2 parents 249e1fe + 463eb8b commit 11520c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ Route::get('/', function (Codedge\Fpdf\Fpdf\Fpdf $fpdf) {
});
```

### Defining fonts

FPDF comes with a set of fonts already defined and stored in the `src/Fpdf/font` directory.
If you want to add your own font, please have a look at the [Adding new fonts and encodings](http://www.fpdf.org/en/tutorial/tuto7.htm) tutorial.

You can change the font path, by using the `FPDF_FONTPATH` environment variable.

## Use in Laravel Vapor

If you want to use [Laravel Vapor](https://vapor.laravel.com) to host your application,
Expand Down
6 changes: 5 additions & 1 deletion src/FpdfServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function register()
*/
public function registerFpdf()
{
if(config('fpdf.font_path') !== null) {
define('FPDF_FONTPATH', config('fpdf.font_path'));
}

$this->app->singleton('fpdf', function()
{
return new Fpdf\Fpdf(
Expand All @@ -60,4 +64,4 @@ public function provides()
{
return ['fpdf'];
}
}
}
1 change: 1 addition & 0 deletions src/config/fpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'orientation' => 'P',
'unit' => 'mm',
'size' => 'A4',
'font_path' => env('FPDF_FONTPATH'),

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 11520c0

Please sign in to comment.