summaryrefslogtreecommitdiff
path: root/libs/litehtml/src/el_font.cpp
blob: 3d5f6d9f73ea5556cc2eeaf5d6c8da15aaba0a40 (plain)
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
#include "html.h"
#include "el_font.h"


litehtml::el_font::el_font(const std::shared_ptr<document>& doc) : html_tag(doc)
{

}

void litehtml::el_font::parse_attributes()
{
	const char* str = get_attr("color");
	if(str)
	{
		m_style.add_property(_color_, str, "", false, get_document()->container());
	}

	str = get_attr("face");
	if(str)
	{
		m_style.add_property(_font_family_, str);
	}

	str = get_attr("size");
	if(str)
	{
		int sz = atoi(str);
		if(*str == '+' || *str == '-') sz = 3 + sz; // relative size

		if(sz <= 1)
		{
			m_style.add_property(_font_size_, "x-small");
		} else if(sz >= 6)
		{
			m_style.add_property(_font_size_, "xx-large");
		} else
		{
			switch(sz)
			{
			case 2:
				m_style.add_property(_font_size_, "small");
				break;
			case 3:
				m_style.add_property(_font_size_, "medium");
				break;
			case 4:
				m_style.add_property(_font_size_, "large");
				break;
			case 5:
				m_style.add_property(_font_size_, "x-large");
				break;
			}
		}
	}

	html_tag::parse_attributes();
}