Skip to content

Define font via env var #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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