summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2012-10-07 23:50:54 +1030
committerAdrian Johnson <ajohnson@redneon.com>2012-10-07 23:50:54 +1030
commit9c2a92c70836b8534ef8c26d943fa17f891da105 (patch)
tree64c1d0a704563967f0888d67736e90a9316da037
parent0d5f63755e7ceb1bb5678fcf1f4661f3435470fb (diff)
downloadcairo-9c2a92c70836b8534ef8c26d943fa17f891da105.tar.gz
type1: convert '.' to locale specific decimal point before using sscanf
-rw-r--r--src/cairo-type1-subset.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 56e659a8b..4926cd8de 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -53,6 +53,7 @@
#include "cairo-output-stream-private.h"
#include <ctype.h>
+#include <locale.h>
#define TYPE1_STACKSIZE 24 /* Defined in Type 1 Font Format */
@@ -304,8 +305,17 @@ cairo_type1_font_subset_get_matrix (cairo_type1_font_subset_t *font,
double *d)
{
const char *start, *end, *segment_end;
- int ret;
+ 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_len = strlen (decimal_point);
+
+ assert (decimal_point_len != 0);
segment_end = font->header_segment + font->header_segment_size;
start = find_token (font->header_segment, segment_end, name);
@@ -316,12 +326,23 @@ cairo_type1_font_subset_get_matrix (cairo_type1_font_subset_t *font,
if (end == NULL)
return CAIRO_INT_STATUS_UNSUPPORTED;
- s = malloc (end - start + 1);
+ s_max = end - start + 5*decimal_point_len + 1;
+ s = malloc (s_max);
if (unlikely (s == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- strncpy (s, start, end - start);
- s[end - start] = 0;
+ i = 0;
+ j = 0;
+ while (i < end - start && j < s_max - decimal_point_len) {
+ if (start[i] == '.') {
+ strncpy(s + j, decimal_point, decimal_point_len);
+ i++;
+ j += decimal_point_len;
+ } else {
+ s[j++] = start[i++];
+ }
+ }
+ s[j] = 0;
start = strpbrk (s, "{[");
if (!start) {
@@ -357,11 +378,13 @@ cairo_type1_font_subset_get_bbox (cairo_type1_font_subset_t *font)
if (unlikely (status))
return status;
+ printf("/FontBBox %f %f %f %f\n", x_min, y_min, x_max, y_max);
status = cairo_type1_font_subset_get_matrix (font, "/FontMatrix",
&xx, &yx, &xy, &yy);
if (unlikely (status))
return status;
+ printf("/FontMatrix %f %f %f %f\n", xx, yx, xy, yy);
if (yy == 0.0)
return CAIRO_INT_STATUS_UNSUPPORTED;