Calibri fontnames are all uppercase in Shared/Font.php #2273
Closed
Description
This is:
A bug report
What is the expected behavior?
When adding the following lines to my code and pair it with setAuto things should work.
Font::setTrueTypeFontPath("/usr/share/fonts/msttcore/");
Font::setAutoSizeMethod(Font::AUTOSIZE_METHOD_EXACT);
...
// Apply auto size to all columns
foreach (range('A',$workSheetMaxColumns) as $col) { $worksheet->getColumnDimension($col)->setAutoSize(true); }
What is the current behavior?
When running this on my web server (CentOS) I had 2 issues:
- TrueType fonts were not installed on the CentOS system. I was able to have our admin install the msttcore fonts.
- Now the real issue is that starting on line 43 some of the fonts are in all uppercase. Since Linux is case sensitive an exception is raised at line 514 since the font can not be found. In the msttcore directory all the *.tff files are lowercase.
Which versions of PhpSpreadsheet and PHP are affected?
version 1.18.0 and master branch
Suggested Fixes
- Lowercase the CALIBRI font names (Line 48-51) (most other font filenames are all lowercase)
const CALIBRI = 'CALIBRI.TTF';
const CALIBRI_BOLD = 'CALIBRIB.TTF';
const CALIBRI_ITALIC = 'CALIBRII.TTF';
const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF';
- Change line 512 to lowercase the $fontFile string (probably not the best solution)
$fontFile = self::$trueTypeFontPath . strtolower($fontFile);
Metadata
Assignees
Labels
No labels