summaryrefslogtreecommitdiff
path: root/src/cairo-type1-subset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-type1-subset.c')
-rw-r--r--[-rwxr-xr-x]src/cairo-type1-subset.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 8453cbd7d..81a1bdbc1 100755..100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -53,7 +53,6 @@
#include "cairo-output-stream-private.h"
#include <ctype.h>
-#include <locale.h>
#define TYPE1_STACKSIZE 24 /* Defined in Type 1 Font Format */
@@ -309,12 +308,10 @@ cairo_type1_font_subset_get_matrix (cairo_type1_font_subset_t *font,
const char *start, *end, *segment_end;
int ret, s_max, i, j;
char *s;
- struct lconv *locale_data;
const char *decimal_point;
int decimal_point_len;
- locale_data = localeconv ();
- decimal_point = locale_data->decimal_point;
+ decimal_point = cairo_get_locale_decimal_point ();
decimal_point_len = strlen (decimal_point);
assert (decimal_point_len != 0);
@@ -407,6 +404,7 @@ cairo_type1_font_subset_get_fontname (cairo_type1_font_subset_t *font)
const char *start, *end, *segment_end;
char *s;
int i;
+ cairo_status_t status;
segment_end = font->header_segment + font->header_segment_size;
start = find_token (font->header_segment, segment_end, "/FontName");
@@ -419,6 +417,9 @@ cairo_type1_font_subset_get_fontname (cairo_type1_font_subset_t *font)
if (end == NULL)
return CAIRO_INT_STATUS_UNSUPPORTED;
+ while (end > start && _cairo_isspace(end[-1]))
+ end--;
+
s = malloc (end - start + 1);
if (unlikely (s == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -447,13 +448,9 @@ cairo_type1_font_subset_get_fontname (cairo_type1_font_subset_t *font)
if (unlikely (font->base.base_font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- s = font->base.base_font;
- while (*s && !is_ps_delimiter(*s))
- s++;
-
- *s = 0;
+ status = _cairo_escape_ps_name (&font->base.base_font);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
static cairo_status_t
@@ -1133,8 +1130,9 @@ write_used_glyphs (cairo_type1_font_subset_t *font,
cairo_status_t status;
char buffer[256];
int length;
- int subset_id;
+ unsigned int subset_id;
int ch;
+ const char *wa_name;
if (font->glyphs[glyph_number].subset_index < 0)
return CAIRO_STATUS_SUCCESS;
@@ -1146,12 +1144,18 @@ write_used_glyphs (cairo_type1_font_subset_t *font,
* font with the standard name.
**/
subset_id = font->glyphs[glyph_number].subset_index;
- if (subset_id > 0) {
+ /* Any additional glyph included for use by the seac operator
+ * will either have subset_id >= font->scaled_font_subset->num_glyphs
+ * or will not map to a winansi name (wa_name = NULL). In this
+ * case the original name is used.
+ */
+ if (subset_id > 0 && subset_id < font->scaled_font_subset->num_glyphs) {
ch = font->scaled_font_subset->to_latin_char[subset_id];
- name = _cairo_winansi_to_glyphname (ch);
- if (name == NULL)
- return CAIRO_STATUS_NULL_POINTER;
- name_length = strlen(name);
+ wa_name = _cairo_winansi_to_glyphname (ch);
+ if (wa_name) {
+ name = wa_name;
+ name_length = strlen(name);
+ }
}
}
@@ -1263,21 +1267,21 @@ cairo_type1_font_subset_write_private_dict (cairo_type1_font_subset_t *font,
* the actual glyph definitions (charstrings).
*
* What we do here is scan directly to the /Subrs token, which
- * marks the beginning of the subroutines. We then read in all the
- * subroutines then move on to the /CharString token, which marks
- * the beginning of the glyph definitions, and read in the chastrings.
+ * marks the beginning of the subroutines. We read in all the
+ * subroutines, then move on to the /CharString token, which marks
+ * the beginning of the glyph definitions, and read in the charstrings.
*
- * The charstrings are parsed to extracts glyph widths, work out
- * which subroutines are called, and too see if any extra glyphs
+ * The charstrings are parsed to extract glyph widths, work out
+ * which subroutines are called, and to see if any extra glyphs
* need to be included due to the use of the seac glyph combining
* operator.
*
- * Finally the private dict is copied to the subset font minus the
+ * Finally, the private dict is copied to the subset font minus the
* subroutines and charstrings not required.
*/
/* Determine lenIV, the number of random characters at the start of
- each encrypted charstring. The defaults is 4, but this can be
+ each encrypted charstring. The default is 4, but this can be
overridden in the private dict. */
font->lenIV = 4;
if ((lenIV_start = find_token (font->cleartext, font->cleartext_end, "/lenIV")) != NULL) {
@@ -1313,6 +1317,7 @@ cairo_type1_font_subset_write_private_dict (cairo_type1_font_subset_t *font,
if (subrs == NULL) {
font->subset_subrs = FALSE;
p = font->cleartext;
+ array_start = NULL;
goto skip_subrs;
}