~centralelyon2010/inkscape/imagelinks2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "font-style-to-pos.h"
#include <style.h>

/* 'lighter' and 'darker' have to be resolved earlier */
/**
Given a style struct (CSS representation), sets the corresponding fields in a NRTypePosDef.
 */
NRTypePosDef
font_style_to_pos (SPStyle const &style)
{
	NRTypePosDef ret;

	switch (style.font_weight.computed) {
	case SP_CSS_FONT_WEIGHT_100:
		ret.weight = NR_POS_WEIGHT_CSS100;
		break;

	case SP_CSS_FONT_WEIGHT_200:
		ret.weight = NR_POS_WEIGHT_CSS200;
		break;

	case SP_CSS_FONT_WEIGHT_300:
		ret.weight = NR_POS_WEIGHT_CSS300;
		break;

	case SP_CSS_FONT_WEIGHT_400:
	case SP_CSS_FONT_WEIGHT_NORMAL:
		ret.weight = NR_POS_WEIGHT_CSS400;
		break;

	case SP_CSS_FONT_WEIGHT_500:
		ret.weight = NR_POS_WEIGHT_CSS500;
		break;

	case SP_CSS_FONT_WEIGHT_600:
		ret.weight = NR_POS_WEIGHT_CSS600;
		break;

	case SP_CSS_FONT_WEIGHT_700:
	case SP_CSS_FONT_WEIGHT_BOLD:
		ret.weight = NR_POS_WEIGHT_CSS700;
		break;

	case SP_CSS_FONT_WEIGHT_800:
		ret.weight = NR_POS_WEIGHT_CSS800;
		break;

	case SP_CSS_FONT_WEIGHT_900:
		ret.weight = NR_POS_WEIGHT_CSS900;
		break;

	case SP_CSS_FONT_WEIGHT_LIGHTER:
	case SP_CSS_FONT_WEIGHT_BOLDER:
	default:
		g_warning("Unrecognized font_weight.computed value");
		ret.weight = NR_POS_WEIGHT_NORMAL;
		break;
	}

	switch (style.font_style.computed) {
	case SP_CSS_FONT_STYLE_ITALIC:
		ret.italic = 1;
		break;

	case SP_CSS_FONT_STYLE_OBLIQUE:
		ret.oblique = 1;
		break;

	case SP_CSS_FONT_STYLE_NORMAL:
	default:
		ret.italic = 0;
		ret.oblique = 0;
		break;
	}

	switch (style.font_stretch.computed) {
	case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED:
	case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED:
		ret.stretch = NR_POS_STRETCH_EXTRA_CONDENSED;
		break;

	case SP_CSS_FONT_STRETCH_CONDENSED:
	case SP_CSS_FONT_STRETCH_NARROWER:
		ret.stretch = NR_POS_STRETCH_CONDENSED;
		break;

	case SP_CSS_FONT_STRETCH_SEMI_CONDENSED:
		ret.stretch = NR_POS_STRETCH_SEMI_CONDENSED;
		break;

	case SP_CSS_FONT_STRETCH_SEMI_EXPANDED:
		ret.stretch = NR_POS_STRETCH_SEMI_EXPANDED;
		break;

	case SP_CSS_FONT_STRETCH_EXPANDED:
	case SP_CSS_FONT_STRETCH_WIDER:
		ret.stretch = NR_POS_STRETCH_EXPANDED;
		break;

	case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED:
	case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED:
		ret.stretch = NR_POS_STRETCH_EXTRA_EXPANDED;
		break;

	default:
		ret.stretch = NR_POS_STRETCH_NORMAL;
		break;
	}

	switch (style.font_variant.computed) {
	case SP_CSS_FONT_VARIANT_SMALL_CAPS:
		ret.variant = NR_POS_VARIANT_SMALLCAPS;
		break;
	default:
		ret.variant = NR_POS_VARIANT_NORMAL;
		break;
	}

	return ret;
}