Skip to content
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.gitattributes export-ignore
/utils export-ignore
/tests export-ignore
/packages export-ignore

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ jobs:
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Install fonts"
run: "composer require mpdf/font-bundle-lite --no-interaction --no-progress"

- name: "Code coverage"
run: composer coverage
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@ jobs:
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Install fonts"
run: "composer require mpdf/font-bundle-lite --no-interaction --no-progress"

- name: "Tests"
run: composer test
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@
"source": "https://github.com/mpdf/mpdf",
"docs": "https://mpdf.github.io"
},
"repositories": [
{
"type": "path",
"url": "packages/*"
}
],
"require": {
"php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
"ext-gd": "*",
"ext-json": "*",
"ext-mbstring": "*",
"mpdf/psr-http-message-shim": "^1.0 || ^2.0",
"mpdf/psr-log-aware-trait": "^2.0 || ^3.0",
Expand All @@ -34,6 +41,7 @@
},
"require-dev": {
"mockery/mockery": "^1.3.0",
"mpdf/font-bundle-all": "*",
"mpdf/qrcode": "^1.1.0",
"squizlabs/php_codesniffer": "^3.5.0",
"tracy/tracy": "~2.5",
Expand All @@ -43,8 +51,11 @@
"ext-bcmath": "Needed for generation of some types of barcodes",
"ext-zlib": "Needed for compression of embedded resources, such as fonts",
"ext-xml": "Needed mainly for SVG manipulation",
"ext-imagick": "Needed if developing the Mpdf library"
},
"ext-imagick": "Needed if developing the Mpdf library",
"mpdf/font-bundle-all": "All official mPDF fonts that offers coverage for common and uncommon scripts worldwide. Uses 110MB of disk space.",
"mpdf/font-bundle-lite": "A subset of official mPDF fonts that offers coverage for most common scripts. Uses 30MB of disk space.",
"mpdf/font-dejavu-family": "A unicode font family with reasonable coverage of common scripts. Uses 10MB of disk space."
},
"autoload": {
"psr-4": {
"Mpdf\\": "src/"
Expand Down
34 changes: 34 additions & 0 deletions packages/Aboriginal-Family/Languages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Mpdf\Fonts\AboriginalFamily;

use Mpdf\Language\LanguageToFontInterface;

class Languages implements LanguageToFontInterface
{
public function getLanguageOptions($mode, $adobeCJK)
{
$tags = explode('-', $mode);
$language = strtolower($tags[0]);

switch ($language) {
// CHEROKEE
case 'chr':

// Ojibwe; Chippewa
case 'oj':
case 'oji':

// Cree CANADIAN_ABORIGINAL
case 'cr':
case 'cre':

// Inuktitut
case 'iu':
case 'iku':
return 'aboriginalsans';
}

return '';
}
}
71 changes: 71 additions & 0 deletions packages/Aboriginal-Family/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# mPDF Font Package

## Introduction

This font package contains a collection of fonts that support scripts used by North American Aboriginals, and is used with the [mPDF library](https://github.com/mpdf/mpdf).

**Supported Scripts**:
* Cherokee
* Candian Aboriginal
* Latin

## Installation

```bash
composer require mpdf/font-aboriginal-family
```

## Usage

This package automatically registers the following fonts with mPDF:

- `aboriginalsans` (sans-serif)
- `aboriginalserif` (serif)

Example usage in mPDF:
```php
<?php

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('
<style>
body {
font-family: aboriginalsans;
}

.h1 {
font-family: aboriginalserif;
}
</style>

<h1>Hello World in aboriginalserif</h1>

<p>Some text in the aboriginalsans font-family</p>
');

$mpdf->OutputHttpDownload('example.pdf');
```

## Advanced Installation

To manually register the font package with mPDF, you can initialize the package's `Registration` class and pass it to the `FontRegistry` constructor:

```php
<?php

use Mpdf\Mpdf;
use Mpdf\Fonts\FontRegistry;
use Mpdf\Fonts\AboriginalFamily\Registration as AboriginalFamilyRegistration;

$registry = new FontRegistry([
new AboriginalFamilyRegistration(),
]);

$mpdf = new Mpdf([
'fontRegistry' => $registry
]);
```

## License

This package is licensed under the MIT License. Fonts are licensed separately by their authors, and can be found in the [`/fonts/LICENSE.txt`](./fonts/LICENSE.txt) file.
112 changes: 112 additions & 0 deletions packages/Aboriginal-Family/Registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace Mpdf\Fonts\AboriginalFamily;

use Mpdf\Fonts\FontRegistration;

class Registration extends FontRegistration
{
/**
* Get the absolute path to the fonts directory
*
* @return string
*/
public function getDirectory()
{
return __DIR__ . '/fonts';
}

/**
* Get the fonts to be registered with mPDF
*
* Return an array listing the file name(s) of the TrueType .ttf or .otf font files for
* each variant of the (internal mPDF) font-family name.
*
* ['R'] = Regular (Normal),
* ['B'] = Bold
* ['I'] = Italics
* ['BI'] = Bold Italics
*
* ['sip-ext'] = 'sun-extb', name a related font file containing SIP characters
* ['useOTL'] => 0xFF, Enable use of OTL features.
* ['useKashida'] => 75, Enable use of kashida for text justification in Arabic text
*
* If a .ttc TrueType collection file is referenced, the number of the font
* within the collection is required. Fonts in the collection are numbered
* starting at 1, as they appear in the .ttc file.
*
* @return array{
* 'R': string,
* 'B'?: string,
* 'I'?: string,
* 'BI'?: string,
* 'sip-ext'?: string,
* 'useOTL'?: int,
* 'useKashida'?: int,
* 'TTCfontID'?: array{
* 'R': int,
* 'B'?: int,
* 'I'?: int,
* 'BI'?: int,
* }
* }
*/
public function getFonts()
{
return [
'aboriginalsans' => [
'R' => 'AboriginalSansREGULAR.ttf',
'B' => 'AboriginalSansBOLD.ttf',
'I' => 'AboriginalSansITALIC.ttf',
'BI' => 'AboriginalSansBOLDITALIC.ttf',
],

'aboriginalserif' => [
'R' => 'AboriginalSerifREGULAR.ttf',
'B' => 'AboriginalSerifBOLD.ttf',
'I' => 'AboriginalSerifITALIC.ttf',
'BI' => 'AboriginalSerifBOLDITALIC.ttf',
],
];
}

/**
* Get the Language Package LanguageToFont implementation
*
* @return \Mpdf\Language\LanguageToFontInterface|null
*/
public function getLanguageToFont()
{
return new Languages();
}

/**
* Define fonts to be used for character substitution, when the useSubstitutions configuration option enabled
*
* @return array The list of fonts to exclude using the keys found in $this->getFontData()
*/
public function getBackupSubsFonts()
{
return [
'aboriginalsans',
];
}

/**
* Get a list of substituted fonts used when a font is not available in mPDF
*
* @return array Multidimensional array with keys 'sans_fonts', 'serif_fonts', and 'mono_fonts'
*/
public function getFontFamilySubstitution()
{
return [
'sans_fonts' => [
'aboriginalsans',
],

'serif_fonts' => [
'aboriginalserif',
],
];
}
}
22 changes: 22 additions & 0 deletions packages/Aboriginal-Family/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{

"name": "mpdf/font-aboriginal-family",
"version": "0.1",
"type": "library",
"description": "The Aboriginal family of fonts for mPDF. Includes sans and serif varieties. Supported scripts include: Cherokee, Candian Aboriginal, and Latin.",
"keywords": ["mpdf", "mpdf-fonts"],
"license": ["MIT"],
"autoload": {
"psr-4": {
"Mpdf\\Fonts\\AboriginalFamily\\": ""
}
},
"require": {
"mpdf/mpdf": "*"
},
"extra": {
"mpdf": {
"fonts": "\\Mpdf\\Fonts\\AboriginalFamily\\Registration"
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading