changeset 22210:4a958bd08920

Select the first charmap in the font, if FreeType did not autoselect any. This happens, for example, with fonts only having an Apple Roman charmap.
author eugeni
date Thu, 15 Feb 2007 22:03:09 +0000
parents 5add218bb6c3
children 7c9d838fc788
files help/help_mp-en.h libass/ass_font.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/help/help_mp-en.h	Thu Feb 15 21:53:28 2007 +0000
+++ b/help/help_mp-en.h	Thu Feb 15 22:03:09 2007 +0000
@@ -2049,3 +2049,5 @@
 #define MSGTR_LIBASS_GlyphNotFoundReselectingFont "[ass] Glyph 0x%X not found, reselecting font for (%s, %d, %d)\n"
 #define MSGTR_LIBASS_GlyphNotFound "[ass] Glyph 0x%X not found in font for (%s, %d, %d)\n"
 #define MSGTR_LIBASS_ErrorOpeningMemoryFont "[ass] Error opening memory font: %s\n"
+#define MSGTR_LIBASS_NoCharmaps "[ass] font face with no charmaps\n"
+#define MSGTR_LIBASS_NoCharmapAutodetected "[ass] no charmap autodetected, trying the first one\n"
--- a/libass/ass_font.c	Thu Feb 15 21:53:28 2007 +0000
+++ b/libass/ass_font.c	Thu Feb 15 22:03:09 2007 +0000
@@ -47,9 +47,19 @@
 		unsigned eid = cmap->encoding_id;
 		if (pid == 3 /*microsoft*/ && (eid == 1 /*unicode bmp*/ || eid == 10 /*full unicode*/)) {
 			FT_Set_Charmap(face, cmap);
-			break;
+			return;
 		}
 	}
+
+	if (!face->charmap) {
+		if (face->num_charmaps == 0) {
+			mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_NoCharmaps);
+			return;
+		}
+		mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_NoCharmapAutodetected);
+		FT_Set_Charmap(face, face->charmaps[0]);
+		return;
+	}
 }
 
 /**