2 * << Haru Free PDF Library >> -- hpdf_gstate.c
4 * URL: http://libharu.org
6 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7 * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
9 * Permission to use, copy, modify, distribute and sell this software
10 * and its documentation for any purpose is hereby granted without fee,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation.
14 * It is provided "as is" without express or implied warranty.
18 #include "hpdf_conf.h"
19 #include "hpdf_utils.h"
20 #include "hpdf_gstate.h"
23 HPDF_GState_New (HPDF_MMgr mmgr,
28 if (current && current->depth >= HPDF_LIMIT_MAX_GSTATE) {
29 HPDF_SetError (mmgr->error, HPDF_EXCEED_GSTATE_LIMIT, 0);
34 gstate = HPDF_GetMem (mmgr, sizeof(HPDF_GState_Rec));
39 gstate->trans_matrix = current->trans_matrix;
40 gstate->line_width = current->line_width;
41 gstate->line_cap = current->line_cap;
42 gstate->line_join = current->line_join;
43 gstate->miter_limit = current->miter_limit;
44 gstate->dash_mode = current->dash_mode;
45 gstate->flatness = current->flatness;
47 gstate->char_space = current->char_space;
48 gstate->word_space = current->word_space;
49 gstate->h_scalling = current->h_scalling;
50 gstate->text_leading = current->text_leading;
51 gstate->rendering_mode = current->rendering_mode;
52 gstate->text_rise = current->text_rise;
54 gstate->cs_stroke = current->cs_stroke;
55 gstate->cs_fill = current->cs_fill;
56 gstate->rgb_fill = current->rgb_fill;
57 gstate->rgb_stroke = current->rgb_stroke;
58 gstate->cmyk_fill = current->cmyk_fill;
59 gstate->cmyk_stroke = current->cmyk_stroke;
60 gstate->gray_fill = current->gray_fill;
61 gstate->gray_stroke = current->gray_stroke;
63 gstate->font = current->font;
64 gstate->font_size = current->font_size;
66 gstate->prev = current;
67 gstate->depth = current->depth + 1;
69 HPDF_TransMatrix DEF_MATRIX = {1, 0, 0, 1, 0, 0};
70 HPDF_RGBColor DEF_RGB_COLOR = {0, 0, 0};
71 HPDF_CMYKColor DEF_CMYK_COLOR = {0, 0, 0, 0};
72 HPDF_DashMode DEF_DASH_MODE = {{0, 0, 0, 0, 0, 0, 0, 0}, 0, 0};
74 gstate->trans_matrix = DEF_MATRIX;
75 gstate->line_width = HPDF_DEF_LINEWIDTH;
76 gstate->line_cap = HPDF_DEF_LINECAP;
77 gstate->line_join = HPDF_DEF_LINEJOIN;
78 gstate->miter_limit = HPDF_DEF_MITERLIMIT;
79 gstate->dash_mode = DEF_DASH_MODE;
80 gstate->flatness = HPDF_DEF_FLATNESS;
82 gstate->char_space = HPDF_DEF_CHARSPACE;
83 gstate->word_space = HPDF_DEF_WORDSPACE;
84 gstate->h_scalling = HPDF_DEF_HSCALING;
85 gstate->text_leading = HPDF_DEF_LEADING;
86 gstate->rendering_mode = HPDF_DEF_RENDERING_MODE;
87 gstate->text_rise = HPDF_DEF_RISE;
89 gstate->cs_stroke = HPDF_CS_DEVICE_GRAY;
90 gstate->cs_fill = HPDF_CS_DEVICE_GRAY;
91 gstate->rgb_fill = DEF_RGB_COLOR;
92 gstate->rgb_stroke = DEF_RGB_COLOR;
93 gstate->cmyk_fill = DEF_CMYK_COLOR;
94 gstate->cmyk_stroke = DEF_CMYK_COLOR;
95 gstate->gray_fill = 0;
96 gstate->gray_stroke = 0;
99 gstate->font_size = 0;
100 gstate->writing_mode = HPDF_WMODE_HORIZONTAL;
110 HPDF_GState_Free (HPDF_MMgr mmgr,
113 HPDF_GState current = NULL;
116 current = gstate->prev;
117 HPDF_FreeMem (mmgr, gstate);