// Test the _write_font() function. CTEST(styles, write_font13) { char* got; char exp[] = "<font><b/><i/><strike/><outline/><shadow/><u/><vertAlign val=\"superscript\"/><sz val=\"12\"/><color rgb=\"FFFF0000\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_bold(format); format_set_italic(format); format_set_font_size(format, 12); format_set_font_color(format, LXW_COLOR_RED); format_set_font_strikeout(format); format_set_font_outline(format); format_set_font_shadow(format); format_set_font_script(format, LXW_FONT_SUPERSCRIPT); format_set_underline(format, LXW_UNDERLINE_SINGLE); styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
// Test the _write_font() function. CTEST(styles, write_font01) { char* got; char exp[] = "<font><sz val=\"11\"/><color theme=\"1\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
// Test the _write_font() function. CTEST(styles, write_font16) { char* got; char exp[] = "<font><u val=\"doubleAccounting\"/><sz val=\"11\"/><color theme=\"1\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_DOUBLE_ACCOUNTING); styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
// Test the _write_font() function. CTEST(styles, write_font17) { char* got; char exp[] = "<font><u/><sz val=\"11\"/><color theme=\"10\"/><name val=\"Calibri\"/><family val=\"2\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_SINGLE); format_set_theme(format, 10); format->hyperlink = 1; styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
/* * Create a new format object. */ lxw_format * lxw_format_new() { lxw_format *format = calloc(1, sizeof(lxw_format)); GOTO_LABEL_ON_MEM_ERROR(format, mem_error); format->xf_format_indices = NULL; format->xf_index = LXW_PROPERTY_UNSET; format->dxf_index = LXW_PROPERTY_UNSET; format->font_name[0] = '\0'; format->font_scheme[0] = '\0'; format->num_format[0] = '\0'; format->num_format_index = 0; format->font_index = 0; format->has_font = LXW_FALSE; format->has_dxf_font = LXW_FALSE; format->font_size = 11; format->bold = LXW_FALSE; format->italic = LXW_FALSE; format->font_color = LXW_COLOR_UNSET; format->underline = LXW_FALSE; format->font_strikeout = LXW_FALSE; format->font_outline = LXW_FALSE; format->font_shadow = LXW_FALSE; format->font_script = LXW_FALSE; format->font_family = LXW_DEFAULT_FONT_FAMILY; format->font_charset = LXW_FALSE; format->font_condense = LXW_FALSE; format->font_extend = LXW_FALSE; format->theme = LXW_FALSE; format->hyperlink = LXW_FALSE; format->hidden = LXW_FALSE; format->locked = LXW_TRUE; format->text_h_align = LXW_ALIGN_NONE; format->text_wrap = LXW_FALSE; format->text_v_align = LXW_ALIGN_NONE; format->text_justlast = LXW_FALSE; format->rotation = 0; format->fg_color = LXW_COLOR_UNSET; format->bg_color = LXW_COLOR_UNSET; format->pattern = LXW_PATTERN_NONE; format->has_fill = LXW_FALSE; format->has_dxf_fill = LXW_FALSE; format->fill_index = 0; format->fill_count = 0; format->border_index = 0; format->has_border = LXW_FALSE; format->has_dxf_border = LXW_FALSE; format->border_count = 0; format->bottom = LXW_BORDER_NONE; format->left = LXW_BORDER_NONE; format->right = LXW_BORDER_NONE; format->top = LXW_BORDER_NONE; format->diag_border = LXW_BORDER_NONE; format->diag_type = LXW_BORDER_NONE; format->bottom_color = LXW_COLOR_UNSET; format->left_color = LXW_COLOR_UNSET; format->right_color = LXW_COLOR_UNSET; format->top_color = LXW_COLOR_UNSET; format->diag_color = LXW_COLOR_UNSET; format->indent = 0; format->shrink = LXW_FALSE; format->merge_range = LXW_FALSE; format->reading_order = 0; format->just_distrib = LXW_FALSE; format->color_indexed = LXW_FALSE; format->font_only = LXW_FALSE; return format; mem_error: lxw_format_free(format); return NULL; }