Skip to content
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

Calibri fontnames are all uppercase in Shared/Font.php #2273

Closed
cwolcott opened this issue Aug 15, 2021 · 1 comment
Closed

Calibri fontnames are all uppercase in Shared/Font.php #2273

cwolcott opened this issue Aug 15, 2021 · 1 comment

Comments

@cwolcott
Copy link

cwolcott commented Aug 15, 2021

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);
@cwolcott cwolcott changed the title Calibri fontname are all uppercase in Shared/Font.php Calibri fontnames are all uppercase in Shared/Font.php Aug 15, 2021
oleibman pushed a commit that referenced this issue Oct 16, 2021
@PowerKiKi
Copy link
Member

Fixed in 1.19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants