Skip to content

Commit e6ae53e

Browse files
committed
Define font via env var
1 parent 249e1fe commit e6ae53e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ Route::get('/', function (Codedge\Fpdf\Fpdf\Fpdf $fpdf) {
3636
});
3737
```
3838

39+
### Defining fonts
40+
41+
FPDF comes with a set of fonts already defined and stored in the `src/Fpdf/font` directory.
42+
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.
43+
44+
You can change the font path, by using the `FPDF_FONTPATH` environment variable.
45+
3946
## Use in Laravel Vapor
4047

4148
If you want to use [Laravel Vapor](https://vapor.laravel.com) to host your application,

src/FpdfServiceProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function register()
4343
*/
4444
public function registerFpdf()
4545
{
46+
if(config('fpdf.font_path') !== null) {
47+
define('FPDF_FONTPATH', config('fpdf.font_path'));
48+
}
49+
4650
$this->app->singleton('fpdf', function()
4751
{
4852
return new Fpdf\Fpdf(
@@ -60,4 +64,4 @@ public function provides()
6064
{
6165
return ['fpdf'];
6266
}
63-
}
67+
}

src/config/fpdf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'orientation' => 'P',
1515
'unit' => 'mm',
1616
'size' => 'A4',
17+
'font_path' => env('FPDF_FONTPATH'),
1718

1819
/*
1920
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)