本文整理汇总了C++中pdf_is_name函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_is_name函数的具体用法?C++ pdf_is_name怎么用?C++ pdf_is_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_is_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pdf_load_type0_font
static pdf_font_desc *
pdf_load_type0_font(pdf_document *xref, pdf_obj *dict)
{
pdf_obj *dfonts;
pdf_obj *dfont;
pdf_obj *subtype;
pdf_obj *encoding;
pdf_obj *to_unicode;
dfonts = pdf_dict_gets(dict, "DescendantFonts");
if (!dfonts)
fz_throw(xref->ctx, "cid font is missing descendant fonts");
dfont = pdf_array_get(dfonts, 0);
subtype = pdf_dict_gets(dfont, "Subtype");
encoding = pdf_dict_gets(dict, "Encoding");
to_unicode = pdf_dict_gets(dict, "ToUnicode");
if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType0"))
return load_cid_font(xref, dfont, encoding, to_unicode);
else if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType2"))
return load_cid_font(xref, dfont, encoding, to_unicode);
else
fz_throw(xref->ctx, "syntaxerror: unknown cid font type");
return NULL; /* Stupid MSVC */
}
开发者ID:JosephLi141242,项目名称:android-pdf-viewer,代码行数:28,代码来源:pdf_font.c
示例2: resolve_dest_rec
static pdf_obj *
resolve_dest_rec(fz_context *ctx, pdf_document *doc, pdf_obj *dest, int depth)
{
if (depth > 10) /* Arbitrary to avoid infinite recursion */
return NULL;
if (pdf_is_name(ctx, dest) || pdf_is_string(ctx, dest))
{
dest = pdf_lookup_dest(ctx, doc, dest);
dest = resolve_dest_rec(ctx, doc, dest, depth+1);
return dest;
}
else if (pdf_is_array(ctx, dest))
{
return dest;
}
else if (pdf_is_dict(ctx, dest))
{
dest = pdf_dict_get(ctx, dest, PDF_NAME_D);
return resolve_dest_rec(ctx, doc, dest, depth+1);
}
else if (pdf_is_indirect(ctx, dest))
return dest;
return NULL;
}
开发者ID:arbitrary-dev,项目名称:mupdf,代码行数:29,代码来源:pdf-annot.c
示例3: pdf_load_name_tree_imp
static void
pdf_load_name_tree_imp(pdf_obj *dict, pdf_document *xref, pdf_obj *node)
{
fz_context *ctx = xref->ctx;
pdf_obj *kids = pdf_dict_gets(node, "Kids");
pdf_obj *names = pdf_dict_gets(node, "Names");
int i;
if (kids && !pdf_dict_mark(node))
{
for (i = 0; i < pdf_array_len(kids); i++)
pdf_load_name_tree_imp(dict, xref, pdf_array_get(kids, i));
pdf_dict_unmark(node);
}
if (names)
{
for (i = 0; i + 1 < pdf_array_len(names); i += 2)
{
pdf_obj *key = pdf_array_get(names, i);
pdf_obj *val = pdf_array_get(names, i + 1);
if (pdf_is_string(key))
{
key = pdf_to_utf8_name(ctx, key);
pdf_dict_put(dict, key, val);
pdf_drop_obj(key);
}
else if (pdf_is_name(key))
{
pdf_dict_put(dict, key, val);
}
}
}
}
开发者ID:JMQCode,项目名称:iBooks,代码行数:34,代码来源:pdf_nametree.c
示例4: resolve_dest_rec
static pdf_obj *
resolve_dest_rec(pdf_document *xref, pdf_obj *dest, int depth)
{
if (depth > 10) /* Arbitrary to avoid infinite recursion */
return NULL;
if (pdf_is_name(dest) || pdf_is_string(dest))
{
dest = pdf_lookup_dest(xref, dest);
return resolve_dest_rec(xref, dest, depth+1);
}
else if (pdf_is_array(dest))
{
return dest;
}
else if (pdf_is_dict(dest))
{
dest = pdf_dict_gets(dest, "D");
return resolve_dest_rec(xref, dest, depth+1);
}
else if (pdf_is_indirect(dest))
return dest;
return NULL;
}
开发者ID:CentMeng,项目名称:PDFViewer,代码行数:28,代码来源:pdf_annot.c
示例5: pdf_lookup_dest
pdf_obj *
pdf_lookup_dest(pdf_document *xref, pdf_obj *needle)
{
fz_context *ctx = xref->ctx;
pdf_obj *root = pdf_dict_gets(xref->trailer, "Root");
pdf_obj *dests = pdf_dict_gets(root, "Dests");
pdf_obj *names = pdf_dict_gets(root, "Names");
pdf_obj *dest = NULL;
/* PDF 1.1 has destinations in a dictionary */
if (dests)
{
if (pdf_is_name(needle))
return pdf_dict_get(dests, needle);
else
return pdf_dict_gets(dests, pdf_to_str_buf(needle));
}
/* PDF 1.2 has destinations in a name tree */
if (names && !dest)
{
pdf_obj *tree = pdf_dict_gets(names, "Dests");
return pdf_lookup_name_imp(ctx, tree, needle);
}
return NULL;
}
开发者ID:AvinashKiran,项目名称:mupdf,代码行数:28,代码来源:pdf_nametree.c
示例6: build_filter
/*
* Create a filter given a name and param dictionary.
*/
static fz_stream *
build_filter(fz_context *ctx, fz_stream *chain, pdf_document *doc, pdf_obj *f, pdf_obj *p, int num, int gen, fz_compression_params *params)
{
fz_compression_params local_params;
if (params == NULL)
params = &local_params;
build_compression_params(ctx, f, p, params);
/* If we were using params we were passed in, and we successfully
* recognised the image type, we can use the existing filter and
* shortstop here. */
if (params != &local_params && params->type != FZ_IMAGE_RAW)
return chain;
if (params->type != FZ_IMAGE_RAW)
return fz_open_image_decomp_stream(ctx, chain, params, NULL);
if (pdf_name_eq(ctx, f, PDF_NAME_ASCIIHexDecode) || pdf_name_eq(ctx, f, PDF_NAME_AHx))
return fz_open_ahxd(ctx, chain);
else if (pdf_name_eq(ctx, f, PDF_NAME_ASCII85Decode) || pdf_name_eq(ctx, f, PDF_NAME_A85))
return fz_open_a85d(ctx, chain);
else if (pdf_name_eq(ctx, f, PDF_NAME_JBIG2Decode))
{
fz_jbig2_globals *globals = NULL;
pdf_obj *obj = pdf_dict_get(ctx, p, PDF_NAME_JBIG2Globals);
if (pdf_is_indirect(ctx, obj))
globals = pdf_load_jbig2_globals(ctx, doc, obj);
/* fz_open_jbig2d takes possession of globals */
return fz_open_jbig2d(ctx, chain, globals);
}
else if (pdf_name_eq(ctx, f, PDF_NAME_JPXDecode))
return chain; /* JPX decoding is special cased in the image loading code */
else if (pdf_name_eq(ctx, f, PDF_NAME_Crypt))
{
pdf_obj *name;
if (!doc->crypt)
{
fz_warn(ctx, "crypt filter in unencrypted document");
return chain;
}
name = pdf_dict_get(ctx, p, PDF_NAME_Name);
if (pdf_is_name(ctx, name))
return pdf_open_crypt_with_filter(ctx, chain, doc->crypt, name, num, gen);
return chain;
}
fz_warn(ctx, "unknown filter name (%s)", pdf_to_name(ctx, f));
return chain;
}
开发者ID:PuzzleFlow,项目名称:mupdf,代码行数:61,代码来源:pdf-stream.c
示例7: parse_dict
static void
parse_dict (fz_context *ctx, pdf_obj *dict, pdfout_data *hash)
{
/* Check Style key. */
pdf_obj *style = pdf_dict_get (ctx, dict, PDF_NAME_S);
if (style)
{
const char *value;
if (pdf_is_name (ctx, style) == false)
pdfout_throw (ctx, "style key 'S' not a name object");
/* pdf_to_name returns the empty string, not NULL, on all errors,
so the strcmps are allowed. */
if (pdf_name_eq (ctx, style, PDF_NAME_D))
value = "arabic";
else if (pdf_name_eq (ctx, style, PDF_NAME_R))
value = "Roman";
else if (pdf_name_eq (ctx, style, PDF_NAME_A))
value = "Letters";
else
{
/* FIXME once PDF_NAMES for "r" and "a" available. */
const char *string = pdf_to_name (ctx, style);
if (streq(string, "r"))
value = "roman";
else if (streq (string, "a"))
value = "letters";
else
pdfout_throw (ctx, "unknown numbering style '%s'", string);
}
int len = strlen (value);
pdfout_data_hash_push_key_value (ctx, hash, "style", value, len);
}
pdf_obj *first = pdf_dict_gets (ctx, dict, "St");
if (first)
{
int value = pdf_to_int (ctx, first);
if (value < 1)
pdfout_throw (ctx, "value %d of 'St' is < 1 or not an int", value);
push_int_key (ctx, hash, "first", value);
}
pdf_obj *prefix = pdf_dict_get (ctx, dict, PDF_NAME_P);
if (prefix)
{
if (pdf_is_string (ctx, prefix) == false)
pdfout_throw (ctx, "value of 'P' not a string");
int utf8_len;
char *utf8 = pdfout_str_obj_to_utf8 (ctx, prefix, &utf8_len);
pdfout_data_hash_push_key_value (ctx, hash, "prefix", utf8, utf8_len);
free (utf8);
}
}
开发者ID:amba,项目名称:pdfout,代码行数:57,代码来源:page-labels.c
示例8: pdf_load_font_descriptor
static void
pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *doc, pdf_obj *dict, char *collection, char *basefont, int iscidfont, int has_encoding)
{
pdf_obj *obj1, *obj2, *obj3, *obj;
char *fontname, *origname;
FT_Face face;
fz_context *ctx = doc->ctx;
/* Prefer BaseFont; don't bother with FontName */
origname = basefont;
/* SumatraPDF: handle /BaseFont /Arial,Bold+000041 /FontName /Arial,Bold */
if (strchr(basefont, '+') && pdf_is_name(pdf_dict_gets(dict, "FontName")))
origname = pdf_to_name(pdf_dict_gets(dict, "FontName"));
/* cf. http://code.google.com/p/sumatrapdf/issues/detail?id=1616 */
if (strlen(origname) > 7 && origname[6] == '+')
origname += 7;
/* Look through list of alternate names for built in fonts */
fontname = clean_font_name(origname);
fontdesc->flags = pdf_to_int(pdf_dict_gets(dict, "Flags"));
fontdesc->italic_angle = pdf_to_real(pdf_dict_gets(dict, "ItalicAngle"));
fontdesc->ascent = pdf_to_real(pdf_dict_gets(dict, "Ascent"));
fontdesc->descent = pdf_to_real(pdf_dict_gets(dict, "Descent"));
fontdesc->cap_height = pdf_to_real(pdf_dict_gets(dict, "CapHeight"));
fontdesc->x_height = pdf_to_real(pdf_dict_gets(dict, "XHeight"));
fontdesc->missing_width = pdf_to_real(pdf_dict_gets(dict, "MissingWidth"));
obj1 = pdf_dict_gets(dict, "FontFile");
obj2 = pdf_dict_gets(dict, "FontFile2");
obj3 = pdf_dict_gets(dict, "FontFile3");
obj = obj1 ? obj1 : obj2 ? obj2 : obj3;
if (pdf_is_indirect(obj))
{
fz_try(ctx)
{
pdf_load_embedded_font(doc, fontdesc, fontname, obj);
}
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
fz_warn(ctx, "ignored error when loading embedded font; attempting to load system font");
if (origname != fontname && !iscidfont)
pdf_load_builtin_font(ctx, fontdesc, fontname);
else
pdf_load_system_font(ctx, fontdesc, fontname, collection, has_encoding);
}
}
else
{
if (origname != fontname && !iscidfont)
开发者ID:superbatonchik,项目名称:mupdf-converter,代码行数:54,代码来源:pdf-font.c
示例9: pdf_parse_file_spec
char *
pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_obj *dest)
{
pdf_obj *filename = NULL;
const char *path;
char *uri;
char frag[256];
if (pdf_is_string(ctx, file_spec))
filename = file_spec;
if (pdf_is_dict(ctx, file_spec)) {
#ifdef _WIN32
filename = pdf_dict_get(ctx, file_spec, PDF_NAME(DOS));
#else
filename = pdf_dict_get(ctx, file_spec, PDF_NAME(Unix));
#endif
if (!filename)
filename = pdf_dict_geta(ctx, file_spec, PDF_NAME(UF), PDF_NAME(F));
}
if (!pdf_is_string(ctx, filename))
{
fz_warn(ctx, "cannot parse file specification");
return NULL;
}
if (pdf_is_array(ctx, dest))
fz_snprintf(frag, sizeof frag, "#page=%d", pdf_array_get_int(ctx, dest, 0) + 1);
else if (pdf_is_name(ctx, dest))
fz_snprintf(frag, sizeof frag, "#%s", pdf_to_name(ctx, dest));
else if (pdf_is_string(ctx, dest))
fz_snprintf(frag, sizeof frag, "#%s", pdf_to_str_buf(ctx, dest));
else
frag[0] = 0;
path = pdf_to_text_string(ctx, filename);
uri = NULL;
#ifdef _WIN32
if (!pdf_name_eq(ctx, pdf_dict_get(ctx, file_spec, PDF_NAME(FS)), PDF_NAME(URL)))
{
/* Fix up the drive letter (change "/C/Documents/Foo" to "C:/Documents/Foo") */
if (path[0] == '/' && (('A' <= path[1] && path[1] <= 'Z') || ('a' <= path[1] && path[1] <= 'z')) && path[2] == '/')
uri = fz_asprintf(ctx, "file://%c:%s%s", path[1], path+2, frag);
}
#endif
if (!uri)
uri = fz_asprintf(ctx, "file://%s%s", path, frag);
return uri;
}
开发者ID:TamirEvan,项目名称:mupdf,代码行数:51,代码来源:pdf-link.c
示例10: pdf_extgstate_uses_blending
static int
pdf_extgstate_uses_blending(pdf_document *doc, pdf_obj *dict)
{
pdf_obj *obj = pdf_dict_gets(dict, "BM");
/* SumatraPDF: properly support /BM arrays */
if (pdf_is_array(obj))
{
int k;
for (k = 0; k < pdf_array_len(obj); k++)
{
char *bm = pdf_to_name(pdf_array_get(obj, k));
if (!strcmp(bm, "Normal") || fz_lookup_blendmode(bm) > 0)
break;
}
obj = pdf_array_get(obj, k);
}
if (pdf_is_name(obj) && strcmp(pdf_to_name(obj), "Normal"))
return 1;
/* SumatraPDF: support transfer functions */
obj = pdf_dict_getsa(dict, "TR", "TR2");
if (obj && !pdf_is_name(obj))
return 1;
return 0;
}
开发者ID:codepongo,项目名称:sumatrapdf,代码行数:24,代码来源:pdf-page.c
示例11: can_reuse_buffer
/* Check if an entry has a cached stream and return whether it is directly
* reusable. A buffer is directly reusable only if the stream is
* uncompressed, or if it is compressed purely a compression method we can
* return details of in fz_compression_params.
*
* If the stream is reusable return 1, and set params as required, otherwise
* return 0. */
static int
can_reuse_buffer(fz_context *ctx, pdf_xref_entry *entry, fz_compression_params *params)
{
pdf_obj *f;
pdf_obj *p;
if (!entry || !entry->obj || !entry->stm_buf)
return 0;
if (params)
params->type = FZ_IMAGE_RAW;
f = pdf_dict_geta(ctx, entry->obj, PDF_NAME_Filter, PDF_NAME_F);
/* If there are no filters, it's uncompressed, and we can use it */
if (!f)
return 1;
p = pdf_dict_geta(ctx, entry->obj, PDF_NAME_DecodeParms, PDF_NAME_DP);
if (pdf_is_array(ctx, f))
{
int len = pdf_array_len(ctx, f);
/* Empty array of filters. It's uncompressed. We can cope. */
if (len == 0)
return 1;
/* 1 filter is the most we can hope to cope with - if more,*/
if (len != 1)
return 0;
p = pdf_array_get(ctx, p, 0);
}
if (pdf_is_null(ctx, f))
return 1; /* Null filter is uncompressed */
if (!pdf_is_name(ctx, f))
return 0;
/* There are filters, so unless we have the option of shortstopping,
* we can't use the existing buffer. */
if (!params)
return 0;
build_compression_params(ctx, f, p, params);
return (params->type == FZ_IMAGE_RAW) ? 0 : 1;
}
开发者ID:PuzzleFlow,项目名称:mupdf,代码行数:52,代码来源:pdf-stream.c
示例12: pdfout_data_scalar_from_pdf
pdfout_data *
pdfout_data_scalar_from_pdf (fz_context *ctx, pdf_obj *obj)
{
const char *s;
if (pdf_is_null (ctx, obj))
return pdfout_data_scalar_new (ctx, "null", strlen ("null"));
else if (pdf_is_bool (ctx, obj))
{
if (pdf_to_bool (ctx, obj))
s = "true";
else
s = "false";
return pdfout_data_scalar_new (ctx, s, strlen (s));
}
else if (pdf_is_name (ctx, obj))
{
s = pdf_to_name (ctx, obj);
return pdfout_data_scalar_new (ctx, s, strlen (s));
}
else if (pdf_is_string (ctx, obj))
{
int len;
char *str = pdfout_str_obj_to_utf8 (ctx, obj, &len);
pdfout_data *result = pdfout_data_scalar_new (ctx, str, len);
free (str);
return result;
}
else if (pdf_is_int (ctx, obj))
{
int n = pdf_to_int (ctx, obj);
char buf[200];
int len = pdfout_snprintf (ctx, buf, "%d", n);
return pdfout_data_scalar_new (ctx, buf, len);
}
else if (pdf_is_real (ctx, obj))
{
float f = pdf_to_real (ctx, obj);
char buf[200];
int len = pdfout_snprintf (ctx, buf, "%g", f);
return pdfout_data_scalar_new (ctx, buf, len);
}
else
abort();
}
开发者ID:amba,项目名称:pdfout,代码行数:45,代码来源:data.c
示例13: pdf_open_filter
/*
* Construct a filter to decode a stream, constraining
* to stream length and decrypting.
*/
static fz_stream *
pdf_open_filter(fz_stream *chain, pdf_document *xref, pdf_obj *stmobj, int num, int gen, int offset, pdf_image_params *imparams)
{
pdf_obj *filters;
pdf_obj *params;
filters = pdf_dict_getsa(stmobj, "Filter", "F");
params = pdf_dict_getsa(stmobj, "DecodeParms", "DP");
chain = pdf_open_raw_filter(chain, xref, stmobj, num, gen, offset);
if (pdf_is_name(filters))
chain = build_filter(chain, xref, filters, params, num, gen, imparams);
else if (pdf_array_len(filters) > 0)
chain = build_filter_chain(chain, xref, filters, params, num, gen, imparams);
return chain;
}
开发者ID:JMQCode,项目名称:iBooks,代码行数:22,代码来源:pdf_stream.c
示例14: pdf_open_inline_stream
/*
* Construct a filter to decode a stream, without
* constraining to stream length, and without decryption.
*/
fz_stream *
pdf_open_inline_stream(pdf_document *xref, pdf_obj *stmobj, int length, fz_stream *chain, pdf_image_params *imparams)
{
pdf_obj *filters;
pdf_obj *params;
filters = pdf_dict_getsa(stmobj, "Filter", "F");
params = pdf_dict_getsa(stmobj, "DecodeParms", "DP");
/* don't close chain when we close this filter */
fz_keep_stream(chain);
if (pdf_is_name(filters))
return build_filter(chain, xref, filters, params, 0, 0, imparams);
if (pdf_array_len(filters) > 0)
return build_filter_chain(chain, xref, filters, params, 0, 0, imparams);
return fz_open_null(chain, length);
}
开发者ID:Ernest0x,项目名称:mupdf,代码行数:23,代码来源:pdf_stream.c
示例15: pdf_open_inline_stream
/*
* Construct a filter to decode a stream, without
* constraining to stream length, and without decryption.
*/
fz_stream *
pdf_open_inline_stream(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *chain, fz_compression_params *imparams)
{
pdf_obj *filters;
pdf_obj *params;
filters = pdf_dict_geta(ctx, stmobj, PDF_NAME_Filter, PDF_NAME_F);
params = pdf_dict_geta(ctx, stmobj, PDF_NAME_DecodeParms, PDF_NAME_DP);
/* don't close chain when we close this filter */
fz_keep_stream(ctx, chain);
if (pdf_is_name(ctx, filters))
return build_filter(ctx, chain, doc, filters, params, 0, 0, imparams);
if (pdf_array_len(ctx, filters) > 0)
return build_filter_chain(ctx, chain, doc, filters, params, 0, 0, imparams);
if (imparams)
imparams->type = FZ_IMAGE_RAW;
return fz_open_null(ctx, chain, length, fz_tell(ctx, chain));
}
开发者ID:PuzzleFlow,项目名称:mupdf,代码行数:25,代码来源:pdf-stream.c
示例16: pdf_open_filter
/*
* Construct a filter to decode a stream, constraining
* to stream length and decrypting.
*/
static fz_stream *
pdf_open_filter(fz_context *ctx, pdf_document *doc, fz_stream *chain, pdf_obj *stmobj, int num, fz_off_t offset, fz_compression_params *imparams)
{
pdf_obj *filters;
pdf_obj *params;
int orig_num, orig_gen;
filters = pdf_dict_geta(ctx, stmobj, PDF_NAME_Filter, PDF_NAME_F);
params = pdf_dict_geta(ctx, stmobj, PDF_NAME_DecodeParms, PDF_NAME_DP);
chain = pdf_open_raw_filter(ctx, chain, doc, stmobj, num, &orig_num, &orig_gen, offset);
fz_var(chain);
fz_try(ctx)
{
if (pdf_is_name(ctx, filters))
{
fz_stream *chain2 = chain;
chain = NULL;
chain = build_filter(ctx, chain2, doc, filters, params, orig_num, orig_gen, imparams);
}
else if (pdf_array_len(ctx, filters) > 0)
{
fz_stream *chain2 = chain;
chain = NULL;
chain = build_filter_chain(ctx, chain2, doc, filters, params, orig_num, orig_gen, imparams);
}
}
fz_catch(ctx)
{
fz_drop_stream(ctx, chain);
fz_rethrow(ctx);
}
return chain;
}
开发者ID:iezbli,项目名称:zbli,代码行数:41,代码来源:pdf-stream.c
示例17: pdf_load_type3_font
pdf_font_desc *
pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *dict)
{
char buf[256];
char *estrings[256];
pdf_font_desc *fontdesc = NULL;
pdf_obj *encoding;
pdf_obj *widths;
pdf_obj *charprocs;
pdf_obj *obj;
int first, last;
int i, k, n;
fz_rect bbox;
fz_matrix matrix;
fz_font *font;
fz_var(fontdesc);
/* Make a new type3 font entry in the document */
if (doc->num_type3_fonts == doc->max_type3_fonts)
{
int new_max = doc->max_type3_fonts * 2;
if (new_max == 0)
new_max = 4;
doc->type3_fonts = fz_resize_array(ctx, doc->type3_fonts, new_max, sizeof(*doc->type3_fonts));
doc->max_type3_fonts = new_max;
}
fz_try(ctx)
{
obj = pdf_dict_get(ctx, dict, PDF_NAME_Name);
if (pdf_is_name(ctx, obj))
fz_strlcpy(buf, pdf_to_name(ctx, obj), sizeof buf);
else
fz_strlcpy(buf, "Unnamed-T3", sizeof buf);
fontdesc = pdf_new_font_desc(ctx);
obj = pdf_dict_get(ctx, dict, PDF_NAME_FontMatrix);
pdf_to_matrix(ctx, obj, &matrix);
obj = pdf_dict_get(ctx, dict, PDF_NAME_FontBBox);
fz_transform_rect(pdf_to_rect(ctx, obj, &bbox), &matrix);
font = fz_new_type3_font(ctx, buf, &matrix);
fontdesc->font = font;
fontdesc->size += sizeof(fz_font) + 256 * (sizeof(fz_buffer*) + sizeof(float));
fz_set_font_bbox(ctx, font, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
/* Encoding */
for (i = 0; i < 256; i++)
estrings[i] = NULL;
encoding = pdf_dict_get(ctx, dict, PDF_NAME_Encoding);
if (!encoding)
{
fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: Type3 font missing Encoding");
}
if (pdf_is_name(ctx, encoding))
pdf_load_encoding(estrings, pdf_to_name(ctx, encoding));
if (pdf_is_dict(ctx, encoding))
{
pdf_obj *base, *diff, *item;
base = pdf_dict_get(ctx, encoding, PDF_NAME_BaseEncoding);
if (pdf_is_name(ctx, base))
pdf_load_encoding(estrings, pdf_to_name(ctx, base));
diff = pdf_dict_get(ctx, encoding, PDF_NAME_Differences);
if (pdf_is_array(ctx, diff))
{
n = pdf_array_len(ctx, diff);
k = 0;
for (i = 0; i < n; i++)
{
item = pdf_array_get(ctx, diff, i);
if (pdf_is_int(ctx, item))
k = pdf_to_int(ctx, item);
if (pdf_is_name(ctx, item) && k >= 0 && k < nelem(estrings))
estrings[k++] = pdf_to_name(ctx, item);
}
}
}
fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 1);
fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding);
pdf_load_to_unicode(ctx, doc, fontdesc, estrings, NULL, pdf_dict_get(ctx, dict, PDF_NAME_ToUnicode));
/* Widths */
pdf_set_default_hmtx(ctx, fontdesc, 0);
first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_FirstChar));
last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_LastChar));
//.........这里部分代码省略.........
开发者ID:FauxFaux,项目名称:k2pdfopt,代码行数:101,代码来源:pdf-type3.c
示例18: pdf_load_embedded_cmap
/*
* Load CMap stream in PDF file
*/
pdf_cmap *
pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *stmobj)
{
fz_stream *file = NULL;
pdf_cmap *cmap = NULL;
pdf_cmap *usecmap;
pdf_obj *wmode;
pdf_obj *obj = NULL;
fz_context *ctx = doc->ctx;
int phase = 0;
fz_var(phase);
fz_var(obj);
fz_var(file);
fz_var(cmap);
if (pdf_obj_marked(stmobj))
fz_throw(ctx, FZ_ERROR_GENERIC, "Recursion in embedded cmap");
if ((cmap = pdf_find_item(ctx, pdf_free_cmap_imp, stmobj)) != NULL)
{
return cmap;
}
fz_try(ctx)
{
file = pdf_open_stream(doc, pdf_to_num(stmobj), pdf_to_gen(stmobj));
phase = 1;
cmap = pdf_load_cmap(ctx, file);
phase = 2;
fz_close(file);
file = NULL;
wmode = pdf_dict_gets(stmobj, "WMode");
if (pdf_is_int(wmode))
pdf_set_cmap_wmode(ctx, cmap, pdf_to_int(wmode));
obj = pdf_dict_gets(stmobj, "UseCMap");
if (pdf_is_name(obj))
{
usecmap = pdf_load_system_cmap(ctx, pdf_to_name(obj));
pdf_set_usecmap(ctx, cmap, usecmap);
pdf_drop_cmap(ctx, usecmap);
}
else if (pdf_is_indirect(obj))
{
phase = 3;
pdf_mark_obj(obj);
usecmap = pdf_load_embedded_cmap(doc, obj);
pdf_unmark_obj(obj);
phase = 4;
pdf_set_usecmap(ctx, cmap, usecmap);
pdf_drop_cmap(ctx, usecmap);
}
pdf_store_item(ctx, stmobj, cmap, pdf_cmap_size(ctx, cmap));
}
fz_catch(ctx)
{
if (file)
fz_close(file);
if (cmap)
pdf_drop_cmap(ctx, cmap);
if (phase < 1)
fz_rethrow_message(ctx, "cannot open cmap stream (%d %d R)", pdf_to_num(stmobj), pdf_to_gen(stmobj));
else if (phase < 2)
fz_rethrow_message(ctx, "cannot parse cmap stream (%d %d R)", pdf_to_num(stmobj), pdf_to_gen(stmobj));
else if (phase < 3)
fz_rethrow_message(ctx, "cannot load system usecmap '%s'", pdf_to_name(obj));
else
{
if (phase == 3)
pdf_unmark_obj(obj);
fz_rethrow_message(ctx, "cannot load embedded usecmap (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
}
return cmap;
}
开发者ID:adan91,项目名称:gd-pdfview,代码行数:81,代码来源:pdf-cmap-load.c
示例19: pdf_process_extgstate
static void
pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_obj *dict)
{
pdf_obj *obj;
obj = pdf_dict_get(ctx, dict, PDF_NAME_LW);
if (pdf_is_number(ctx, obj) && proc->op_w)
proc->op_w(ctx, proc, pdf_to_real(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_LC);
if (pdf_is_int(ctx, obj) && proc->op_J)
proc->op_J(ctx, proc, fz_clampi(pdf_to_int(ctx, obj), 0, 2));
obj = pdf_dict_get(ctx, dict, PDF_NAME_LJ);
if (pdf_is_int(ctx, obj) && proc->op_j)
proc->op_j(ctx, proc, fz_clampi(pdf_to_int(ctx, obj), 0, 2));
obj = pdf_dict_get(ctx, dict, PDF_NAME_ML);
if (pdf_is_number(ctx, obj) && proc->op_M)
proc->op_M(ctx, proc, pdf_to_real(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_D);
if (pdf_is_array(ctx, obj) && proc->op_d)
{
pdf_obj *dash_array = pdf_array_get(ctx, obj, 0);
pdf_obj *dash_phase = pdf_array_get(ctx, obj, 1);
proc->op_d(ctx, proc, dash_array, pdf_to_real(ctx, dash_phase));
}
obj = pdf_dict_get(ctx, dict, PDF_NAME_RI);
if (pdf_is_name(ctx, obj) && proc->op_ri)
proc->op_ri(ctx, proc, pdf_to_name(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_FL);
if (pdf_is_number(ctx, obj) && proc->op_i)
proc->op_i(ctx, proc, pdf_to_real(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_Font);
if (pdf_is_array(ctx, obj) && proc->op_Tf)
{
pdf_obj *font_ref = pdf_array_get(ctx, obj, 0);
pdf_obj *font_size = pdf_array_get(ctx, obj, 1);
pdf_font_desc *font = load_font_or_hail_mary(ctx, csi->doc, csi->rdb, font_ref, 0, csi->cookie);
fz_try(ctx)
proc->op_Tf(ctx, proc, "ExtGState", font, pdf_to_real(ctx, font_size));
fz_always(ctx)
pdf_drop_font(ctx, font);
fz_catch(ctx)
fz_rethrow(ctx);
}
/* transfer functions */
obj = pdf_dict_get(ctx, dict, PDF_NAME_TR2);
if (pdf_is_name(ctx, obj))
if (!pdf_name_eq(ctx, obj, PDF_NAME_Identity) && !pdf_name_eq(ctx, obj, PDF_NAME_Default))
fz_warn(ctx, "ignoring transfer function");
if (!obj) /* TR is ignored in the presence of TR2 */
{
pdf_obj *tr = pdf_dict_get(ctx, dict, PDF_NAME_TR);
if (pdf_is_name(ctx, tr))
if (!pdf_name_eq(ctx, tr, PDF_NAME_Identity))
fz_warn(ctx, "ignoring transfer function");
}
/* transparency state */
obj = pdf_dict_get(ctx, dict, PDF_NAME_CA);
if (pdf_is_number(ctx, obj) && proc->op_gs_CA)
proc->op_gs_CA(ctx, proc, pdf_to_real(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_ca);
if (pdf_is_number(ctx, obj) && proc->op_gs_ca)
proc->op_gs_ca(ctx, proc, pdf_to_real(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_BM);
if (pdf_is_array(ctx, obj))
obj = pdf_array_get(ctx, obj, 0);
if (pdf_is_name(ctx, obj) && proc->op_gs_BM)
proc->op_gs_BM(ctx, proc, pdf_to_name(ctx, obj));
obj = pdf_dict_get(ctx, dict, PDF_NAME_SMask);
if (proc->op_gs_SMask)
{
if (pdf_is_dict(ctx, obj))
{
pdf_xobject *xobj;
pdf_obj *group, *s, *bc, *tr;
float softmask_bc[FZ_MAX_COLORS];
fz_colorspace *colorspace;
int colorspace_n = 1;
int k, luminosity;
fz_var(xobj);
group = pdf_dict_get(ctx, obj, PDF_NAME_G);
if (!group)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot load softmask xobject (%d 0 R)", pdf_to_num(ctx, obj));
xobj = pdf_load_xobject(ctx, csi->doc, group);
//.........这里部分代码省略.........
开发者ID:ArtifexSoftware,项目名称:mupdf,代码行数:101,代码来源:pdf-interpret.c
示例20: load_cid_font
static pdf_font_desc *
load_cid_font(pdf_document *xref, pdf_obj *dict, pdf_obj *encoding, pdf_obj *to_unicode)
{
pdf_obj *widths;
pdf_obj *descriptor;
pdf_font_desc *fontdesc = NULL;
FT_Face face;
int kind;
char collection[256];
char *basefont;
int i, k, fterr;
pdf_obj *obj;
int dw;
fz_context *ctx = xref->ctx;
fz_var(fontdesc);
fz_try(ctx)
{
/* Get font name and CID collection */
basefont = pdf_to_name(pdf_dict_gets(dict, "BaseFont"));
{
pdf_obj *cidinfo;
char tmpstr[64];
int tmplen;
cidinfo = pdf_dict_gets(dict, "CIDSystemInfo");
if (!cidinfo)
fz_throw(ctx, "cid font is missing info");
obj = pdf_dict_gets(cidinfo, "Registry");
tmplen = fz_mini(sizeof tmpstr - 1, pdf_to_str_len(obj));
memcpy(tmpstr, pdf_to_str_buf(obj), tmplen);
tmpstr[tmplen] = '\0';
fz_strlcpy(collection, tmpstr, sizeof collection);
fz_strlcat(collection, "-", sizeof collection);
obj = pdf_dict_gets(cidinfo, "Ordering");
tmplen = fz_mini(sizeof tmpstr - 1, pdf_to_str_len(obj));
memcpy(tmpstr, pdf_to_str_buf(obj), tmplen);
tmpstr[tmplen] = '\0';
fz_strlcat(collection, tmpstr, sizeof collection);
}
/* Load font file */
fontdesc = pdf_new_font_desc(ctx);
descriptor = pdf_dict_gets(dict, "FontDescriptor");
if (!descriptor)
fz_throw(ctx, "syntaxerror: missing font descriptor");
pdf_load_font_descriptor(fontdesc, xref, descriptor, collection, basefont);
face = fontdesc->font->ft_face;
kind = ft_kind(face);
/* Encoding */
if (pdf_is_name(encoding))
{
if (!strcmp(pdf_to_name(encoding), "Identity-H"))
fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 2);
else if (!strcmp(pdf_to_name(encoding), "Identity-V"))
fontdesc->encoding = pdf_new_identity_cmap(ctx, 1, 2);
else
fontdesc->encoding = pdf_load_system_cmap(ctx, pdf_to_name(encoding));
}
else if (pdf_is_indirect(encoding))
{
fontdesc->encoding = pdf_load_embedded_cmap(xref, encoding);
}
else
{
fz_throw(ctx, "syntaxerror: font missing encoding");
}
fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding);
pdf_set_font_wmode(ctx, fontdesc, pdf_cmap_wmode(ctx, fontdesc->encoding));
if (kind == TRUETYPE)
{
pdf_obj *cidtogidmap;
cidtogidmap = pdf_dict_gets(dict, "CIDToGIDMap");
if (pdf_is_indirect(cidtogidmap))
{
fz_buffer *buf;
buf = pdf_load_stream(xref, pdf_to_num(cidtogidmap), pdf_to_gen(cidtogidmap));
fontdesc->cid_to_gid_len = (buf->len) / 2;
fontdesc->cid_to_gid = fz_malloc_array(ctx, fontdesc->cid_to_gid_len, sizeof(unsigned short));
fontdesc->size += fontdesc->cid_to_gid_len * sizeof(unsigned short);
for (i = 0; i < fontdesc->cid_to_gid_len; i++)
fontdesc->cid_to_gid[i] = (buf->data[i * 2] << 8) + buf->data[i * 2 + 1];
fz_drop_buffer(ctx, buf);
//.........这里部分代码省略.........
开发者ID:JosephLi141242,项目名称:android-pdf-viewer,代码行数:101,代码来源:pdf_font.c
注:本文中的pdf_is_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论