aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why is list of available fonts so limited?

BARNZ opened this issue · comments

commented

I would like to use the Calibri font but doing the following causes excel to complain about worksheet errors:

$sheet->writeHeader($headings, [
    Style::FONT => [
        Style::FONT_NAME => 'Calibri',
        Style::FONT_SIZE => 10,
        Style::FONT_STYLE => Style::FONT_STYLE_BOLD,
    ]
]);

I see theres a function Style::_getFamilyFont() which has $defaultFontsNames. If I add Calibri to this array then things work, but I cant see any way to add to this array from my application code:

$defaultFontsNames = [
    'Times New Roman' => [
        'name' => 'Times New Roman',
        'family' => 1,
    ],
    'Arial' => [
        'name' => 'Arial',
        'family' => 2,
    ],
    'Courier New' => [
        'name' => 'Courier New',
        'family' => 3,
    ],
    'Comic Sans MS' => [
        'name' => 'Comic Sans MS',
        'family' => 4,
    ],

    +++++
    'Calibri' => [
        'name' => 'Calibri',
        'family' => 5,
    ],
];

2 questions:

  • Whats the reason for this list of 4 specific fonts only? And of all fonts why comic sans as one of these 4? 😆
  • Can we have a way to set the default available fonts - or rather can we just use any font we like in the style array?

FYI just found this library and am currently trying to port some exports over from the now archived box\spout library,

commented

Was resolved in v3.1.3