Skip to content

Commit 5b1594e

Browse files
authored
Handle fonts with Unicode full repertoire (U+10000 to U+10FFFF)
1 parent a1681e9 commit 5b1594e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/FontLib/TrueType/File.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@ function utf8toUnicode($str) {
222222

223223
function getUnicodeCharMap() {
224224
$subtable = null;
225-
foreach ($this->getData("cmap", "subtables") as $_subtable) {
226-
if ($_subtable["platformID"] == 0 || ($_subtable["platformID"] == 3 && $_subtable["platformSpecificID"] == 1)) {
225+
$subtables = $this->getData("cmap", "subtables");
226+
for ($i = count($subtables) - 1; $i >= 0; $i--) {
227+
$_subtable = $subtables[$i];
228+
$platformID = $_subtable["platformID"];
229+
$platformSpecificId = $_subtable["platformSpecificID"];
230+
if (($platformID == 0 && $platformSpecificId != 5) || ($platformID == 3 && in_array($platformSpecificId, [0, 1, 10]))) {
227231
$subtable = $_subtable;
228232
break;
229233
}
@@ -235,7 +239,7 @@ function getUnicodeCharMap() {
235239

236240
$system_encodings = mb_list_encodings();
237241
$system_encodings = array_change_key_case(array_fill_keys($system_encodings, true), CASE_UPPER);
238-
foreach ($this->getData("cmap", "subtables") as $_subtable) {
242+
foreach ($subtables as $_subtable) {
239243
$encoding = null;
240244
switch ($_subtable["platformID"]) {
241245
case 3:

0 commit comments

Comments
 (0)