Skip to content

Commit

Permalink
Handle fonts with Unicode full repertoire (U+10000 to U+10FFFF)
Browse files Browse the repository at this point in the history
  • Loading branch information
romaincazier authored Mar 14, 2024
1 parent a1681e9 commit 5b1594e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/FontLib/TrueType/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ function utf8toUnicode($str) {

function getUnicodeCharMap() {
$subtable = null;
foreach ($this->getData("cmap", "subtables") as $_subtable) {
if ($_subtable["platformID"] == 0 || ($_subtable["platformID"] == 3 && $_subtable["platformSpecificID"] == 1)) {
$subtables = $this->getData("cmap", "subtables");
for ($i = count($subtables) - 1; $i >= 0; $i--) {
$_subtable = $subtables[$i];
$platformID = $_subtable["platformID"];
$platformSpecificId = $_subtable["platformSpecificID"];
if (($platformID == 0 && $platformSpecificId != 5) || ($platformID == 3 && in_array($platformSpecificId, [0, 1, 10]))) {
$subtable = $_subtable;
break;
}
Expand All @@ -235,7 +239,7 @@ function getUnicodeCharMap() {

$system_encodings = mb_list_encodings();
$system_encodings = array_change_key_case(array_fill_keys($system_encodings, true), CASE_UPPER);
foreach ($this->getData("cmap", "subtables") as $_subtable) {
foreach ($subtables as $_subtable) {
$encoding = null;
switch ($_subtable["platformID"]) {
case 3:
Expand Down

0 comments on commit 5b1594e

Please sign in to comment.