summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pdf/pdf_font3.c')
-rw-r--r--pdf/pdf_font3.c46
1 files changed, 9 insertions, 37 deletions
diff --git a/pdf/pdf_font3.c b/pdf/pdf_font3.c
index 7ecd3bff..708e7658 100644
--- a/pdf/pdf_font3.c
+++ b/pdf/pdf_font3.c
@@ -74,7 +74,7 @@ pdfi_type3_build_char(gs_show_enum * penum, gs_gstate * pgs, gs_font * pfont,
}
if (code < 0)
goto build_char_error;
- if (CharProc->type != PDF_STREAM) {
+ if (pdfi_type_of(CharProc) != PDF_STREAM) {
code = gs_note_error(gs_error_typecheck);
goto build_char_error;
}
@@ -223,6 +223,8 @@ int pdfi_free_font_type3(pdf_obj *font)
pdfi_countdown(t3font->CharProcs);
pdfi_countdown(t3font->Encoding);
pdfi_countdown(t3font->ToUnicode);
+ pdfi_countdown(t3font->filename); /* Should never exist, but just in case */
+
gs_free_object(OBJ_MEMORY(font), font, "Free type 3 font");
return 0;
}
@@ -230,10 +232,9 @@ int pdfi_free_font_type3(pdf_obj *font)
int pdfi_read_type3_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *stream_dict, pdf_dict *page_dict, pdf_font **ppdffont)
{
- int code = 0, i, num_chars = 0;
+ int code = 0;
pdf_font_type3 *font = NULL;
pdf_obj *obj = NULL;
- double f;
pdf_obj *tounicode = NULL;
*ppdffont = NULL;
@@ -271,44 +272,15 @@ int pdfi_read_type3_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *stream
if (code < 0)
goto font3_error;
- code = pdfi_dict_get_number(ctx, font_dict, "FirstChar", &f);
- if (code < 0)
- goto font3_error;
- font->FirstChar = (int)f;
-
- code = pdfi_dict_get_number(ctx, font_dict, "LastChar", &f);
- if (code < 0)
- goto font3_error;
- font->LastChar = (int)f;
- num_chars = (font->LastChar - font->FirstChar) + 1;
code = pdfi_dict_knownget_type(ctx, font_dict, "FontDescriptor", PDF_DICT, (pdf_obj **)&font->FontDescriptor);
if (code < 0)
goto font3_error;
- code = pdfi_dict_knownget_type(ctx, font_dict, "Widths", PDF_ARRAY, (pdf_obj **)&obj);
- if (code < 0)
- goto font3_error;
- if (code > 0) {
- if (num_chars != pdfi_array_size((pdf_array *)obj)) {
- code = gs_note_error(gs_error_rangecheck);
- goto font3_error;
- }
+ pdfi_font_set_first_last_char(ctx, font_dict, (pdf_font *)font);
+ /* ignore errors with widths... for now */
+ (void)pdfi_font_create_widths(ctx, font_dict, (pdf_font*)font, 1.0);
- font->Widths = (double *)gs_alloc_bytes(ctx->memory, sizeof(double) * num_chars, "type 3 font Widths array");
- if (font->Widths == NULL) {
- code = gs_note_error(gs_error_VMerror);
- goto font3_error;
- }
- memset(font->Widths, 0x00, sizeof(double) * num_chars);
- for (i = 0; i < num_chars; i++) {
- code = pdfi_array_get_number(ctx, (pdf_array *)obj, (uint64_t)i, &font->Widths[i]);
- if (code < 0)
- goto font3_error;
- }
- }
- pdfi_countdown(obj);
- obj = NULL;
code = pdfi_dict_get(ctx, font_dict, "Encoding", &obj);
if (code < 0)
@@ -324,13 +296,13 @@ int pdfi_read_type3_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *stream
if (ctx->args.ignoretounicode != true) {
code = pdfi_dict_get(ctx, font_dict, "ToUnicode", (pdf_obj **)&tounicode);
- if (code >= 0 && tounicode->type == PDF_STREAM) {
+ if (code >= 0 && pdfi_type_of(tounicode) == PDF_STREAM) {
pdf_cmap *tu = NULL;
code = pdfi_read_cmap(ctx, tounicode, &tu);
pdfi_countdown(tounicode);
tounicode = (pdf_obj *)tu;
}
- if (code < 0 || (tounicode != NULL && tounicode->type != PDF_CMAP)) {
+ if (code < 0 || (tounicode != NULL && pdfi_type_of(tounicode) != PDF_CMAP)) {
pdfi_countdown(tounicode);
tounicode = NULL;
code = 0;