ttf: Fix cmap subtable priority order.
authorSebastian Rasmussen <[email protected]>
Mon, 28 Apr 2025 22:59:22 +0000 (00:59 +0200)
committerSebastian Rasmussen <[email protected]>
Tue, 29 Apr 2025 10:21:32 +0000 (12:21 +0200)
Compare with pdf_load_simple_font() which prioritizes according to:

 * if not a symbolic font, any unicode cmap (platform == 3)
 * it showf not a symbolic font, any macintosh cmap (platform == 1)
 * a symbolic cmap

With this commit the subsetting code prioritizes the cmaps in the
same order.

This fixes:
tests_private/pdf/sumatra/1815_-_Type0_font_embedded_encoding_ignored.pdf

source/fitz/subset-ttf.c

index a4d6e324ec2c165750ca0bcf9a4ae7da15f6c652..785342ed9a613e95e50bf12e331f33259e4cbee0 100644 (file)
@@ -755,14 +755,14 @@ load_encoding(fz_context *ctx, ttf_t *ttf, fz_stream *stm)
        {
                if (ttf->symbolic)
                {
-                       /* For symbolic fonts, we look for (1,0) as per PDF Spec, then (3,0). */
-                       enc = load_enc(ctx, t, 1, 0);
+                       /* For symbolic fonts, we look for (3,0) as per PDF Spec, then (1,0). */
+                       enc = load_enc(ctx, t, 3, 0);
                        if (!enc)
-                               enc = load_enc(ctx, t, 3, 0);
+                               enc = load_enc(ctx, t, 1, 0);
                }
                else
                {
-                       /* For non symbolic fonts, we look for (3,1) then (1,0). */
+                       /* For non symbolic fonts, we look for (3,1) then (1,0), then (0,1), and finally (0,3). */
                        enc = load_enc(ctx, t, 3, 1);
                        if (!enc)
                                enc = load_enc(ctx, t, 1, 0);