FPDF不会正确居中文本

I am trying to use FPDF to render the cover content of a bachelor's/master thesis.

I need to be able to display czech alphabet including characters with punctuation (such as ř, č, ž, ý, ě). I have therefore generated FPDF font files on http://fpdf.fruit-lab.de/index.php from a local Times New Roman TTF font file.

I am using the following code to render the cover.

function toISO($text) {
    return iconv('UTF-8', 'ISO-8859-2', $text);
}

function buildImpressionPDF($school, $faculty, $thesisType, $firstname, $surname, $year)
{
    $pdf = new FPDF();

    $pdf->AddPage();
    $pdf->AddFont('times', '', 'times.php');
    $pdf->SetFont('times', '', 18);
    $pdf->setMargins(0, 0, 0);
    $pdf->SetAutoPageBreak(false);

    $pdf->Cell(0, 20, toISO($school), 0, 0, 'C');
    $pdf->SetY(20);
    $pdf->Cell(0, 20, toISO($faculty), 0, 0, 'C');
    $pdf->SetY(($pdf->h / 2) - 10);
    $pdf->Cell(0, 20, toISO($thesisType), 0, 0, 'C');
    $pdf->SetY(-40);
    $pdf->Cell(0, 20, toISO($firstname . ' ' . $surname), 0, 0, 'C');
    $pdf->SetY(-30);
    $pdf->Cell(0, 20, toISO($year), 0, 0, 'C');

    return $pdf;
}

The text renders fine, including punctuation, but isn't properly justified - some lines are placed more to the right than others.

I suspect that this might be a problem with the custom font. When I used the original FPDF fonts, it seemed to justify fine (but I did not investigate that thoroughly), but of course did not display punctuation properly.

What am I doing wrong?

Please use the TCPDF instead of FPDF Or try this

$pdf->Cell(20,10,'Title',1,1,'C');