diff options
Diffstat (limited to 'source/pdf/pdf-appearance.c')
-rw-r--r-- | source/pdf/pdf-appearance.c | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index a6445d0d..fbd50434 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -12,10 +12,10 @@ #define STRIKE_HEIGHT (0.375f) #define UNDERLINE_HEIGHT (0.075f) #define LINE_THICKNESS (0.07f) -#define SMALL_FLOAT (0.00001) -#define LIST_SEL_COLOR_R (0.6) -#define LIST_SEL_COLOR_G (0.75) -#define LIST_SEL_COLOR_B (0.85) +#define SMALL_FLOAT (0.00001f) +#define LIST_SEL_COLOR_R (0.6f) +#define LIST_SEL_COLOR_G (0.75f) +#define LIST_SEL_COLOR_B (0.85f) enum { @@ -172,9 +172,9 @@ static void get_font_info(fz_context *ctx, pdf_document *doc, pdf_obj *dr, char fz_throw(ctx, FZ_ERROR_GENERIC, "No font name in default appearance"); font_rec->font = font = pdf_load_font(ctx, doc, dr, pdf_dict_gets(ctx, pdf_dict_get(ctx, dr, PDF_NAME_Font), font_rec->da_rec.font_name), 0); - font_rec->lineheight = 1.0; + font_rec->lineheight = 1.0f; if (font && font->ascent != 0.0f && font->descent != 0.0f) - font_rec->lineheight = (font->ascent - font->descent) / 1000.0; + font_rec->lineheight = (font->ascent - font->descent) / 1000.0f; } static void font_info_fin(fz_context *ctx, font_info *font_rec) @@ -306,7 +306,7 @@ static void fzbuf_print_text(fz_context *ctx, fz_buffer *fzbuf, const fz_rect *c fz_append_printf(ctx, fzbuf, fmt_W); if (col) { - fzbuf_print_color(ctx, fzbuf, col, 0, 0.0); + fzbuf_print_color(ctx, fzbuf, col, 0, 0.0f); fz_append_printf(ctx, fzbuf, fmt_f); } else @@ -424,7 +424,7 @@ static void text_splitter_init(text_splitter *splitter, font_info *info, const c splitter->unscaled_width = width; splitter->height = height; splitter->fontsize = fontsize; - splitter->scale = 1.0; + splitter->scale = 1.0f; splitter->lineheight = fontsize * info->lineheight ; /* RJW: The cast in the following line is important, as otherwise * under MSVC in the variable = 0 case, splitter->max_lines becomes @@ -482,7 +482,7 @@ static int text_splitter_layout(fz_context *ctx, text_splitter *splitter) stride = pdf_text_stride(ctx, splitter->info->font, fontsize, (unsigned char *)text, len, room, &count); /* If not a single char fits although the line is empty, then force one char */ - if (count == 0 && splitter->x == 0.0) + if (count == 0 && splitter->x == 0.0f) stride = pdf_text_stride(ctx, splitter->info->font, fontsize, (unsigned char *)text, 1, FLT_MAX, &count); if (count < len && splitter->retry) @@ -500,8 +500,8 @@ static int text_splitter_layout(fz_context *ctx, text_splitter *splitter) fitwidth *= 1.001f; /* Stretching by 10% is worth trying only if processing the first word on the line */ - hstretchwidth = splitter->x == 0.0 - ? splitter->width * 1.1 / splitter->scale + hstretchwidth = splitter->x == 0.0f + ? splitter->width * 1.1f / splitter->scale : FLT_MAX; vstretchwidth = splitter->width * (splitter->max_lines + 1) * splitter->lineheight @@ -524,7 +524,7 @@ static int text_splitter_layout(fz_context *ctx, text_splitter *splitter) /* This is not the first word on the line. Best to give up on this line and push * the word onto the next */ - if (count < len && splitter->x > 0.0) + if (count < len && splitter->x > 0.0f) return 0; splitter->text_end = splitter->text_start + count; @@ -571,7 +571,7 @@ static void fzbuf_print_text_start1(fz_context *ctx, fz_buffer *fzbuf, const fz_ fz_append_printf(ctx, fzbuf, fmt_W); if (col) { - fzbuf_print_color(ctx, fzbuf, col, 0, 0.0); + fzbuf_print_color(ctx, fzbuf, col, 0, 0.0f); fz_append_printf(ctx, fzbuf, fmt_f); } else @@ -622,12 +622,12 @@ static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, con fz_rect tbox; rect = *bbox; - if (rect.x1 - rect.x0 > 3.0 && rect.y1 - rect.y0 > 3.0) + if (rect.x1 - rect.x0 > 3.0f && rect.y1 - rect.y0 > 3.0f) { - rect.x0 += 1.0; - rect.x1 -= 1.0; - rect.y0 += 1.0; - rect.y1 -= 1.0; + rect.x0 += 1.0f; + rect.x1 -= 1.0f; + rect.y0 += 1.0f; + rect.y1 -= 1.0f; } height = rect.y1 - rect.y0; @@ -643,7 +643,7 @@ static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, con variable = (info->font_rec.da_rec.font_size == 0); fontsize = variable - ? (info->multiline ? 14.0 : height / info->font_rec.lineheight) + ? (info->multiline ? 14.0f : height / info->font_rec.lineheight) : info->font_rec.da_rec.font_size; info->font_rec.da_rec.font_size = fontsize; @@ -698,11 +698,11 @@ static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, con fzbuf = fz_new_buffer(ctx, 0); tm.a = splitter.scale; - tm.b = 0.0; - tm.c = 0.0; + tm.b = 0.0f; + tm.c = 0.0f; tm.d = splitter.scale; tm.e = rect.x0; - tm.f = rect.y1 - (1.0+ascent-descent)*fontsize*splitter.scale/2.0; + tm.f = rect.y1 - (1.0f+ascent-descent)*fontsize*splitter.scale/2.0f; fzbuf_print_text_start1(ctx, fzbuf, &rect, info->col); fzbuf_print_text_start2(ctx, fzbuf, &info->font_rec, &tm); @@ -716,9 +716,9 @@ static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, con int i, n = fz_mini((int)strlen(text), info->max_len); float comb_width = full_width/info->max_len; float char_width = pdf_text_stride(ctx, info->font_rec.font, fontsize, (unsigned char *)"M", 1, FLT_MAX, NULL); - float init_skip = (comb_width - char_width)/2.0; + float init_skip = (comb_width - char_width)/2.0f; - fz_translate(&tm, rect.x0, rect.y1 - (height+(ascent-descent)*fontsize)/2.0); + fz_translate(&tm, rect.x0, rect.y1 - (height+(ascent-descent)*fontsize)/2.0f); fzbuf = fz_new_buffer(ctx, 0); @@ -726,7 +726,7 @@ static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, con fzbuf_print_text_start2(ctx, fzbuf, &info->font_rec, &tm); for (i = 0; i < n; i++) - fzbuf_print_text_word(ctx, fzbuf, i == 0 ? init_skip : comb_width, 0.0, text+i, 1); + fzbuf_print_text_word(ctx, fzbuf, i == 0 ? init_skip : comb_width, 0.0f, text+i, 1); fzbuf_print_text_end(ctx, fzbuf); } @@ -738,7 +738,7 @@ static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, con } else { - fz_translate(&tm, rect.x0, rect.y1 - (height+(ascent-descent)*fontsize)/2.0); + fz_translate(&tm, rect.x0, rect.y1 - (height+(ascent-descent)*fontsize)/2.0f); switch (info->q) { @@ -1130,7 +1130,7 @@ static int get_border_style(fz_context *ctx, pdf_obj *obj) static float get_border_width(fz_context *ctx, pdf_obj *obj) { float w = pdf_to_real(ctx, pdf_dict_getl(ctx, obj, PDF_NAME_BS, PDF_NAME_W, NULL)); - return w == 0.0 ? 1.0 : w; + return w == 0.0f ? 1.0f : w; } void pdf_update_text_appearance(fz_context *ctx, pdf_document *doc, pdf_obj *obj, char *eventValue) @@ -1297,18 +1297,18 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj * } } - if (clip_rect.x1 - clip_rect.x0 > 3.0 && clip_rect.y1 - clip_rect.y0 > 3.0) + if (clip_rect.x1 - clip_rect.x0 > 3.0f && clip_rect.y1 - clip_rect.y0 > 3.0f) { - clip_rect.x0 += 1.0; - clip_rect.x1 -= 1.0; - clip_rect.y0 += 1.0; - clip_rect.y1 -= 1.0; + clip_rect.x0 += 1.0f; + clip_rect.x1 -= 1.0f; + clip_rect.y0 += 1.0f; + clip_rect.y1 -= 1.0f; } height = clip_rect.y1 - clip_rect.y0; width = clip_rect.x1 - clip_rect.x0; variable = (info.font_rec.da_rec.font_size == 0); fontsize = variable - ? (info.multiline ? 14.0 : height / info.font_rec.lineheight) + ? (info.multiline ? 14.0f : height / info.font_rec.lineheight) : info.font_rec.da_rec.font_size; /* Get the ascent, descent across the items list. */ @@ -1337,10 +1337,10 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj * /* Add the selection rects */ if (num_sel > 0) { - color[0] = (float)LIST_SEL_COLOR_R; - color[1] = (float)LIST_SEL_COLOR_G; - color[2] = (float)LIST_SEL_COLOR_B; - fill_rect.x0 = 0.0; + color[0] = LIST_SEL_COLOR_R; + color[1] = LIST_SEL_COLOR_G; + color[2] = LIST_SEL_COLOR_B; + fill_rect.x0 = 0.0f; fill_rect.x1 = width; for (i = 0; i < num_sel; i++) { @@ -1354,7 +1354,7 @@ void pdf_update_listbox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj * /* And now finish with the text content */ for (i = 0; i < n; i++) { - fzbuf_print_text_word(ctx, fzbuf, 0.0, i == 0 ? 0 : -fontsize * + fzbuf_print_text_word(ctx, fzbuf, 0.0f, i == 0 ? 0 : -fontsize * lineheight, opts[i], (int)strlen(opts[i])); } fzbuf_print_text_end(ctx, fzbuf); @@ -1448,7 +1448,7 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_BG, NULL); if (pdf_is_array(ctx, tobj)) { - fzbuf_print_color(ctx, fzbuf, tobj, 0, 0.0); + fzbuf_print_color(ctx, fzbuf, tobj, 0, 0.0f); fz_append_printf(ctx, fzbuf, fmt_re, rect.x0, rect.y0, rect.x1, rect.y1); fz_append_printf(ctx, fzbuf, fmt_f); @@ -1461,9 +1461,9 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob btotal += bwidth; if (bstyle == BS_Beveled) - fz_append_printf(ctx, fzbuf, fmt_g, 1.0); + fz_append_printf(ctx, fzbuf, fmt_g, 1.0f); else - fz_append_printf(ctx, fzbuf, fmt_g, 0.33); + fz_append_printf(ctx, fzbuf, fmt_g, 0.33f); fz_append_printf(ctx, fzbuf, fmt_m, bwidth, bwidth); fz_append_printf(ctx, fzbuf, fmt_l, bwidth, rect.y1 - bwidth); fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - bwidth, rect.y1 - bwidth); @@ -1472,9 +1472,9 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob fz_append_printf(ctx, fzbuf, fmt_l, 2 * bwidth, 2 * bwidth); fz_append_printf(ctx, fzbuf, fmt_f); if (bstyle == BS_Beveled) - fzbuf_print_color(ctx, fzbuf, tobj, 0, -0.25); + fzbuf_print_color(ctx, fzbuf, tobj, 0, -0.25f); else - fz_append_printf(ctx, fzbuf, fmt_g, 0.66); + fz_append_printf(ctx, fzbuf, fmt_g, 0.66f); fz_append_printf(ctx, fzbuf, fmt_m, rect.x1 - bwidth, rect.y1 - bwidth); fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - bwidth, bwidth); fz_append_printf(ctx, fzbuf, fmt_l, bwidth, bwidth); @@ -1487,7 +1487,7 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_BC, NULL); if (tobj) { - fzbuf_print_color(ctx, fzbuf, tobj, 1, 0.0); + fzbuf_print_color(ctx, fzbuf, tobj, 1, 0.0f); fz_append_printf(ctx, fzbuf, fmt_w, bwidth); fz_append_printf(ctx, fzbuf, fmt_re, bwidth/2, bwidth/2, @@ -1539,26 +1539,26 @@ void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_a switch (type) { case PDF_ANNOT_HIGHLIGHT: - color[0] = 1.0; - color[1] = 1.0; - color[2] = 0.0; - alpha = 0.5; - line_thickness = 1.0; - line_height = 0.5; + color[0] = 1.0f; + color[1] = 1.0f; + color[2] = 0.0f; + alpha = 0.5f; + line_thickness = 1.0f; + line_height = 0.5f; break; case PDF_ANNOT_UNDERLINE: - color[0] = 0.0; - color[1] = 0.0; - color[2] = 1.0; - alpha = 1.0; + color[0] = 0.0f; + color[1] = 0.0f; + color[2] = 1.0f; + alpha = 1.0f; line_thickness = LINE_THICKNESS; line_height = UNDERLINE_HEIGHT; break; case PDF_ANNOT_STRIKE_OUT: - color[0] = 1.0; - color[1] = 0.0; - color[2] = 0.0; - alpha = 1.0; + color[0] = 1.0f; + color[1] = 0.0f; + color[2] = 0.0f; + alpha = 1.0f; line_thickness = LINE_THICKNESS; line_height = STRIKE_HEIGHT; break; @@ -2054,14 +2054,14 @@ static const float outline_thickness = 15.0f; static void draw_rounded_rect(fz_context *ctx, fz_path *path) { - fz_moveto(ctx, path, 20.0, 60.0); - fz_curveto(ctx, path, 20.0, 30.0, 30.0, 20.0, 60.0, 20.0); - fz_lineto(ctx, path, 340.0, 20.0); - fz_curveto(ctx, path, 370.0, 20.0, 380.0, 30.0, 380.0, 60.0); - fz_lineto(ctx, path, 380.0, 340.0); - fz_curveto(ctx, path, 380.0, 370.0, 370.0, 380.0, 340.0, 380.0); - fz_lineto(ctx, path, 60.0, 380.0); - fz_curveto(ctx, path, 30.0, 380.0, 20.0, 370.0, 20.0, 340.0); + fz_moveto(ctx, path, 20.0f, 60.0f); + fz_curveto(ctx, path, 20.0f, 30.0f, 30.0f, 20.0f, 60.0f, 20.0f); + fz_lineto(ctx, path, 340.0f, 20.0f); + fz_curveto(ctx, path, 370.0f, 20.0f, 380.0f, 30.0f, 380.0f, 60.0f); + fz_lineto(ctx, path, 380.0f, 340.0f); + fz_curveto(ctx, path, 380.0f, 370.0f, 370.0f, 380.0f, 340.0f, 380.0f); + fz_lineto(ctx, path, 60.0f, 380.0f); + fz_curveto(ctx, path, 30.0f, 380.0f, 20.0f, 370.0f, 20.0f, 340.0f); fz_closepath(ctx, path); } @@ -2077,9 +2077,9 @@ static void draw_speech_bubble(fz_context *ctx, fz_path *path) void pdf_update_text_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot) { - static float white[3] = {1.0, 1.0, 1.0}; - static float yellow[3] = {1.0, 1.0, 0.0}; - static float black[3] = {0.0, 0.0, 0.0}; + static float white[3] = {1.0f, 1.0f, 1.0f}; + static float yellow[3] = {1.0f, 1.0f, 0.0f}; + static float black[3] = {0.0f, 0.0f, 0.0f}; fz_display_list *dlist = NULL; fz_device *dev = NULL; |