root/gs3-extensions/html-to-expeditee/trunk/src/perllib/CssStyleToExpAttr.pm @ 24941

Revision 24941, 10.0 KB (checked in by davidb, 8 years ago)

Work on converting CSS style attributes to Expeditee attributes

Line 
1###########################################################################
2#
3# CssStyleToExpAttr.pm --
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 2009 New Zealand Digital Library Project
9#
10# This program is free software; you can redistr   te it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26package CssStyleToExpAttr;
27
28my $font_generic_family_lookup = {
29    'serif'      => "t", # (e.g., Times)
30    'sans-serif' => "s", # (e.g., Helvetica)
31    'cursive',   => "s", # (e.g., Zapf-Chancery)
32    'fantasy'    => "s", # (e.g., Western)
33    'monospace'  => "m"  # (e.g., Courier)
34};
35
36
37my $font_specific_family_lookup = {
38  "arial"           => "sans-serif",
39  "arial black"     => "sans-serif",
40  "gadget"          => "sans-serif",
41  "comic sans ms"       => "cursive",
42  "comic sans"      => "cursive",
43  "courier"         => "monospace",
44  "courier new"     => "monospace",
45  "georgia"         => "serif",
46  "impact"          => "sans-serif",
47  "charcoal"        => "sans-serif",
48  "lucida console"      => "monospace",
49  "monaco"          => "monospace",
50  "lucida sans unicode" => "sans-serif",
51  "lucida grande"       => "sans-serif",
52  "palatino linotype"   => "serif",
53  "book antiqua"        => "serif",
54  "palatino"        => "serif",
55  "tahoma"          => "sans-serif",
56  "geneva"          => "sans-serif",
57  "times"           => "serif",
58  "times new roman"     => "serif",
59  "trebuchet ms"        => "sans-serif",
60  "trebuchet"       => "sans-serif",
61  "verdana"         => "sans-serif",
62  "geneva"          => "sans-serif",
63  #symbol       => "symbol",
64  #webdings         => "symbol",
65  #wingdings        => "symbol",
66  #zapf dingbats    => "symbol",
67  "ms sans serif"       => "sans-serif",
68  "sans serif       => sans-serif,
69  geneva"           => "sans-serif",
70  "ms serif"        => "serif",
71  "new york"        => "serif"
72};
73
74my $UNUSED_font_specific_family_mapping = {
75    'serif'      => [
76             "Times New Roman",
77             "Bodoni",
78             "Garamond",
79             "Minion Web",
80             "ITC Stone Serif",
81             "MS Georgia",
82             "Bitstream Cyberbit",
83             "Adobe Minion Cyrillic",
84             "Excelsior Cyrillic Upright",
85             "Monotype Albion 70",
86             "ER Bukinist",
87             "New Peninim",
88             "Raanana",
89             "Ryumin Light-KL",
90             "Kyokasho ICA",
91             "Futo Min A101",
92             "Lo Cicero Cherokee"
93    ],
94
95    'sans-serif' => [
96             "MS Trebuchet",
97             "ITC Avant Garde Gothic",
98             "MS Arial",
99             "MS Verdana",
100             "Univers",
101             "Futura",
102             "ITC Stone Sans",
103             "Gill Sans",
104             "Akzidenz Grotesk",
105             "Helvetica",
106             "Attika",
107             "Typiko New Era",
108             "MS Tahoma",
109             "Monotype Gill Sans 571",
110             "Helvetica Greek",
111             "Helvetica Cyrillic",
112             "ER Univers",
113             "Lucida Sans Unicode",
114             "Bastion",
115             "Arial Hebrew",
116             "Shin Go",
117             "Heisei Kaku Gothic W5"
118    ],
119    'cursive'    => [
120             "Caflisch Script",
121             "Adobe Poetica",
122             "Sanvito",
123             "Ex Ponto",
124             "Snell Roundhand",
125             "Zapf-Chancery",
126             "ER Architekt",
127             "Corsiva",
128             "DecoType Naskh",
129             "Monotype Urdu 507"
130    ],
131 
132   'fantasy'    => [
133             "Alpha Geometrique",
134             "Critter",
135             "Cottonwood",
136             "FB Reactor",
137             "Studz"
138    ],
139
140    'monospace'  => [
141             "Courier",
142             "MS Courier New",
143             "Prestige",
144             "Everson Mono",
145             "ER Kurier",
146             "Osaka Monospaced",
147    ]
148};
149
150
151                 
152my $font_style_lookup = {
153    'normal'  => "n",
154    'italic'  => "i",
155    'oblique' => 'i'
156};
157
158# Nothing that can currently be done for small-caps
159my $font_varient_lookup = {
160    'normal' => "",
161    'small-caps' => ""
162};
163
164
165my $font_weight_lookup = {
166    'normal'  => "n",
167    'bold'    => "n",
168    'bolder'  => "b", # filler for now
169    'lighter' => "n", # filler for now
170    '100'     => "n",
171    '200'     => "n",
172    '300'     => "b",
173    '400'     => "b",
174    '500'     => "b",
175    '600'     => "b",
176    '700'     => "b",
177    '800'     => "b",
178    '900'     => "b"
179};
180
181
182my $font_size_absolute = {
183    'xx-small' => 8,
184    'x-small'  =>10,
185    'small'    =>12,
186    'medium'   =>14,
187    'large'    =>16,
188    'x-large'  =>18,
189    'xx-large' =>20
190};
191
192# px, em, percentage, and relative, such as larger
193
194## color, background-color
195
196my $color_name_lookup = {
197    "aliceblue" =>  [240,248,255],
198    "antiquewhite" =>   [250,235,215],
199    "aqua" =>       [0,255,255],
200    "aquamarine" =>     [127,255,212],
201    "azure" =>      [240,255,255],
202    "beige" =>      [245,245,220],
203    "bisque" =>     [255,228,196],
204    "black" =>      [0,0,0],
205    "blanchedalmond" => [255,235,205],
206    "blue" =>       [0,0,255],
207    "blueviolet" =>     [138,43,226],
208    "brown" =>      [165,42,42],
209    "burlywood" =>  [222,184,135],
210    "cadetblue" =>  [95,158,160],
211    "chartreuse" =>     [127,255,0],
212    "chocolate" =>  [210,105,30],
213    "coral" =>      [255,127,80],
214    "cornflowerblue" => [100,149,237],
215    "cornsilk" =>   [255,248,220],
216    "crimson" =>    [220,20,60],
217    "cyan" =>       [0,255,255],
218    "darkblue" =>   [0,0,139],
219    "darkcyan" =>   [0,139,139],
220    "darkgoldenrod" =>  [184,134,11],
221    "darkgray" =>   [169,169,169],
222    "darkgreen" =>  [0,100,0],
223    "darkgrey" =>   [169,169,169],
224    "darkkhaki" =>  [189,183,107],
225    "darkmagenta" =>    [139,0,139],
226    "darkolivegreen" => [85,107,47],
227    "darkorange" =>     [255,140,0],
228    "darkorchid" =>     [153,50,204],
229    "darkred" =>    [139,0,0],
230    "darksalmon" =>     [233,150,122],
231    "darkseagreen" =>   [143,188,143],
232    "darkslateblue" =>  [72,61,139],
233    "darkslategray" =>  [47,79,79],
234    "darkslategrey" =>  [47,79,79],
235    "darkturquoise" =>  [0,206,209],
236    "darkviolet" =>     [148,0,211],
237    "deeppink" =>   [255,20,147],
238    "deepskyblue" =>    [0,191,255],
239    "dimgray" =>    [105,105,105],
240    "dimgrey" =>    [105,105,105],
241    "dodgerblue" =>     [30,144,255],
242    "firebrick" =>  [178,34,34],
243    "floralwhite" =>    [255,250,240],
244    "forestgreen" =>    [34,139,34],
245    "fuchsia" =>    [255,0,255],
246    "gainsboro" =>  [220,220,220],
247    "ghostwhite" =>     [248,248,255],
248    "gold" =>       [255,215,0],
249    "goldenrod" =>  [218,165,32],
250    "gray" =>       [128,128,128],
251    "green" =>      [0,128,0],
252    "greenyellow" =>    [173,255,47],
253    "grey" =>       [128,128,128],
254    "honeydew" =>   [240,255,240],
255    "hotpink" =>    [255,105,180],
256    "indianred" =>  [205,92,92],
257    "indigo" =>     [75,0,130],
258    "ivory" =>      [255,255,240],
259    "khaki" =>      [240,230,140],
260    "lavender" =>   [230,230,250],
261    "lavenderblush" =>  [255,240,245],
262    "lawngreen" =>  [124,252,0],
263    "lemonchiffon" =>   [255,250,205],
264    "lightblue" =>  [173,216,230],
265    "lightcoral" =>     [240,128,128],
266    "lightcyan" =>  [224,255,255],
267    "lightgoldenrodyellow" =>   [250,250,210],
268    "lightgray" =>  [211,211,211],
269    "lightgreen" =>     [144,238,144],
270    "lightgrey" =>  [211,211,211],
271    "lightpink" =>  [255,182,193],
272    "lightsalmon" =>    [255,160,122],
273    "lightseagreen" =>  [32,178,170],
274    "lightskyblue" =>   [135,206,250],
275    "lightslategray" => [119,136,153],
276    "lightslategrey" => [119,136,153],
277    "lightsteelblue" => [176,196,222],
278    "lightyellow" =>    [255,255,224],
279    "lime" =>       [0,255,0],
280    "limegreen" =>  [50,205,50],
281    "linen" =>      [250,240,230],
282    "magenta" =>    [255,0,255],
283    "maroon" =>     [128,0,0],
284    "mediumaquamarine" =>   [102,205,170],
285    "mediumblue" =>     [0,0,205],
286    "mediumorchid" =>   [186,85,211],
287    "mediumpurple" =>   [147,112,219],
288    "mediumseagreen" =>     [60,179,113],
289    "mediumslateblue" =>    [123,104,238],
290    "mediumspringgreen" =>  [0,250,154],
291    "mediumturquoise" =>    [72,209,204],
292    "mediumvioletred" =>    [199,21,133],
293    "midnightblue" =>   [25,25,112],
294    "mintcream" =>  [245,255,250],
295    "mistyrose" =>  [255,228,225],
296    "moccasin" =>   [255,228,181],
297    "navajowhite" =>    [255,222,173],
298    "navy" =>       [0,0,128],
299    "oldlace" =>    [253,245,230],
300    "olive" =>      [128,128,0],
301    "olivedrab" =>  [107,142,35],
302    "orange" =>     [255,165,0],
303    "orangered" =>  [255,69,0],
304    "orchid" =>     [218,112,214],
305    "palegoldenrod" =>  [238,232,170],
306    "palegreen" =>  [152,251,152],
307    "paleturquoise" =>  [175,238,238],
308    "palevioletred" =>  [219,112,147],
309    "papayawhip" =>     [255,239,213],
310    "peachpuff" =>  [255,218,185],
311    "peru" =>       [205,133,63],
312    "pink" =>       [255,192,203],
313    "plum" =>       [221,160,221],
314    "powderblue" =>     [176,224,230],
315    "purple" =>     [128,0,128],
316    "red" =>        [255,0,0],
317    "rosybrown" =>  [188,143,143],
318    "royalblue" =>  [65,105,225],
319    "saddlebrown" =>    [139,69,19],
320    "salmon" =>     [250,128,114],
321    "sandybrown" =>     [244,164,96],
322    "seagreen" =>   [46,139,87],
323    "seashell" =>   [255,245,238],
324    "sienna" =>     [160,82,45],
325    "silver" =>     [192,192,192],
326    "skyblue" =>    [135,206,235],
327    "slateblue" =>  [106,90,205],
328    "slategray" =>  [112,128,144],
329    "slategrey" =>  [112,128,144],
330    "snow" =>       [255,250,250],
331    "springgreen" =>    [0,255,127],
332    "steelblue" =>  [70,130,180],
333    "tan" =>        [210,180,140],
334    "teal" =>       [0,128,128],
335    "thistle" =>    [216,191,216],
336    "tomato" =>     [255,99,71],
337    "turquoise" =>  [64,224,208],
338    "violet" =>     [238,130,238],
339    "wheat" =>      [245,222,179],
340    "white" =>      [255,255,255],
341    "whitesmoke" =>     [245,245,245],
342    "yellow" =>     [255,255,0],
343    "yellowgreen" =>    [154,205,50 ]
344};
345
346
347sub convert_font_size
348{
349    my ($css_font_size) = @_;
350
351    my $exp_font_size = undef;
352
353    if ($css_font_size =~ m/^(\d+(?:\.\d*))px$/) {
354    $exp_font_size = int($1);
355    }
356
357    return $exp_font_size;
358}
359   
3601;
361   
Note: See TracBrowser for help on using the browser.