summaryrefslogtreecommitdiff
path: root/src/cairo-scaled-font-subsets.c
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2011-08-06 00:24:55 +0930
committerAdrian Johnson <ajohnson@redneon.com>2011-08-06 00:24:55 +0930
commit8a6d7643f09946b31d14e9bd57276747b025604a (patch)
treee856f1ee610a57f2f4bee2ee09efc6bb42f3468b /src/cairo-scaled-font-subsets.c
parent1a4714b61f194d6b69855cfd48dd1a6aff4efda5 (diff)
downloadcairo-8a6d7643f09946b31d14e9bd57276747b025604a.tar.gz
subsets: use show_text_glyphs supplied utf8 to determine latin character
PS files printed from PDF do not have a cmap in the subsetted fonts. If the unicode mapping has ben supplied by _show_text_glyphs we should use this instead of the reverse lookup to determine if the glyph is a latin chartacter.
Diffstat (limited to 'src/cairo-scaled-font-subsets.c')
-rw-r--r--src/cairo-scaled-font-subsets.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 0e9880a00..2ac258909 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -606,13 +606,38 @@ _cairo_sub_font_map_glyph (cairo_sub_font_t *sub_font,
int latin_character;
status = _cairo_sub_font_glyph_lookup_unicode (sub_font->scaled_font,
- scaled_font_glyph_index,
- &font_unicode,
- &font_utf8,
- &font_utf8_len);
+ scaled_font_glyph_index,
+ &font_unicode,
+ &font_utf8,
+ &font_utf8_len);
if (unlikely(status))
return status;
+ /* If the supplied utf8 is a valid single character, use it
+ * instead of the font lookup */
+ if (text_utf8 != NULL && text_utf8_len > 0) {
+ uint32_t *ucs4;
+ int ucs4_len;
+
+ status = _cairo_utf8_to_ucs4 (text_utf8, text_utf8_len,
+ &ucs4, &ucs4_len);
+ if (status == CAIRO_STATUS_SUCCESS) {
+ if (ucs4_len == 1) {
+ font_unicode = ucs4[0];
+ free (font_utf8);
+ font_utf8 = malloc (text_utf8_len + 1);
+ if (font_utf8 == NULL) {
+ free (ucs4);
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ }
+ memcpy (font_utf8, text_utf8, text_utf8_len);
+ font_utf8[font_utf8_len] = 0;
+ font_utf8_len = text_utf8_len;
+ }
+ free (ucs4);
+ }
+ }
+
/* If glyph is in the winansi encoding and font is not a user
* font, put glyph in the latin subset. If glyph is .notdef
* the latin subset is preferred but only if the latin subset