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

Fatal Error triggered when previewing templates when using characters such as é #301

Open
markcummins opened this issue Jun 20, 2022 · 0 comments

Comments

@markcummins
Copy link
Contributor

Steps to Reproduce

  1. Go to the backend and create a new certificate template
  2. Set the 'Certified Message' field to be 'This is to certify that é has completed the course'
  3. Preview the certificate
  4. See the 'Fatal Error' wp error message

What's happening is that first of all, in class-woothemes-sensei-certificate-templates.php, it sees that the font has a weird character set, and it returns 'mb'.

Then it sets the font to 'Deja Vu', because the font type is 'mb'

// Set the field text styling based on the font type
$fonttype = '';
if (!$custom_font) {
	$fonttype = $this->get_font_type($value);
	switch ($fonttype) {
	        case 'mb':
			$fpdf->SetFont('DejaVu', '', $font['font_size']);
			break;
		case 'latin':
			$fpdf->SetFont($font['font_family'], $font['font_style'], $font['font_size']);
			break;
		default:
			$fpdf->SetFont($font['font_family'], $font['font_style'], $font['font_size']);
			break;
	}
}

Then in '/sensei-certificates/lib/tfpdf/tFPDF/PDF.php', it triggers the fatal error, because 'DejaVu' is not in the arr_core_fonts array

if (in_array($str_family, $this->arr_core_fonts)) {
    if ($str_family == 'symbol' || $str_family == 'zapfdingbats') {
        $str_style = '';
    }
    $str_font_key = $str_family . $str_style;
    if (!isset($this->arr_fonts[$str_font_key])) {
        $this->AddFont($str_family, $str_style);
    }
} else {
    $this->Error('Undefined font: ' . $str_family . ' ' . $str_style);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant