summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2012-05-07 16:34:51 +0100
committerChris Liddell <chris.liddell@artifex.com>2012-05-07 16:34:51 +0100
commitfee1ab3e7e38c3e2bd82a855d7bdec2c18751320 (patch)
tree0ff6a1e94db8890edfb337bacb691f4e6a827ec6
parent7b81312d205a2f9b89f40da4b4f6b67bcacd8ef1 (diff)
Bug 693023: fix $Blend in Type 1 font serialization
When serializing a MultipleMaster font, we were writing both a 'boiler plate' $Blend procedure, and a broken $Blend from the font dictionary - broken because the code to read the procedure from the dictionary ignored name objects. In general, this was fine, as all the current FAPI scalers ignore the $Blend. A problem arose because the code which calculated size of the procedure did handle PS name objects, so we ended up with unitialized bytes trailing the dictionary data, which could cause the scaler to error. No cluster differences.
-rw-r--r--gs/psi/write_t1.c29
-rw-r--r--gs/psi/zfapi.c7
2 files changed, 26 insertions, 10 deletions
diff --git a/gs/psi/write_t1.c b/gs/psi/write_t1.c
index 5ed1c401f..132d43fd0 100644
--- a/gs/psi/write_t1.c
+++ b/gs/psi/write_t1.c
@@ -300,15 +300,26 @@ static void write_main_dictionary(FAPI_font* a_fapi_font,WRF_output* a_output, i
WRF_wstring(a_output, "] def\n");
}
WRF_wstring(a_output,"end readonly def\n");
- WRF_wstring(a_output,"/$Blend {");
- x = a_fapi_font->get_word(a_fapi_font,FAPI_FONT_FEATURE_DollarBlend_length,0);
- if(a_output->m_count)
- a_output->m_count += x;
- x = a_fapi_font->get_proc(a_fapi_font,FAPI_FONT_FEATURE_DollarBlend,0,(char *)a_output->m_pos);
- if(a_output->m_pos)
- a_output->m_pos += x;
- WRF_wstring(a_output,"} def\n");
- WRF_wstring(a_output,"/$Blend {0.1 mul exch 0.45 mul add exch 0.17 mul add add} def\n");
+
+ /* Previously we tried to write $Blend twice - the "real" one from the font,
+ * and the boiler plate one below.
+ * For now, I assume there was a good reason for including the second, but it may
+ * be because the "get_proc" method below was missing the code to handle PS name
+ * objects.
+ */
+ if ((x = a_fapi_font->get_word(a_fapi_font,FAPI_FONT_FEATURE_DollarBlend_length,0)) > 0) {
+ WRF_wstring(a_output,"/$Blend {");
+
+ if(a_output->m_count)
+ a_output->m_count += x;
+ x = a_fapi_font->get_proc(a_fapi_font,FAPI_FONT_FEATURE_DollarBlend,0,(char *)a_output->m_pos);
+ if(a_output->m_pos)
+ a_output->m_pos += x;
+ WRF_wstring(a_output,"} def\n");
+ }
+ else {
+ WRF_wstring(a_output,"/$Blend {0.1 mul exch 0.45 mul add exch 0.17 mul add add} def\n");
+ }
WRF_wstring(a_output,"/WeightVector [");
x = a_fapi_font->get_word(a_fapi_font,FAPI_FONT_FEATURE_WeightVector_count,0);
for (i = 0;i < x;i++) {
diff --git a/gs/psi/zfapi.c b/gs/psi/zfapi.c
index bc05e755d..29ec6d40b 100644
--- a/gs/psi/zfapi.c
+++ b/gs/psi/zfapi.c
@@ -817,7 +817,7 @@ static int FAPI_FF_get_proc(FAPI_font *ff, fapi_font_feature var_id, int index,
switch((int)var_id) {
case FAPI_FONT_FEATURE_DollarBlend:
- { ref *DBlend, Element;
+ { ref *DBlend, Element, string;
int i;
char Buf[32];
if (dict_find_string(pdr, "$Blend", &DBlend) <= 0)
@@ -827,6 +827,11 @@ static int FAPI_FF_get_proc(FAPI_font *ff, fapi_font_feature var_id, int index,
if (array_get(ff->memory, DBlend, i, &Element) < 0)
return 0;
switch (r_btype(&Element)) {
+ case t_name:
+ name_string_ref(ff->memory, &Element, &string);
+ strncpy(ptr, string.value.const_bytes, r_size(&string));
+ ptr += r_size(&string);
+ break;
case t_real:
sprintf(Buf, "%f", Element.value.realval);
strcpy(ptr, Buf);