Changed text controls to re-apply style after system font size change
[platform/core/uifw/dali-toolkit.git] / docs / content / shared-javascript-and-cpp-documentation / markup-style.md
1 <!--
2 /**-->
3
4 # Mark-up Style {#markup-style}
5
6 Mark-up tags can be used within the text to set styles.
7
8 By default the text controls don't process the mark-up string. To enable the mark-up string processing the property *ENABLE_MARKUP* must be set to *true*.
9
10 ~~~{.cpp}
11 // C++
12
13 TextField field = TextField::New();
14 field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
15
16 Stage::GetCurrent().Add( field );
17 ~~~
18
19 ~~~{.js}
20 // JavaScript
21
22 var field = new dali.TextField();
23 field.enableMarkup = true;
24
25 dali.stage.add( field );
26 ~~~
27
28 Note the mark-up processor doesn't check the correctness of the mark-up string. This may
29 cause the text to be badly rendered.
30
31 The table below describes the priorities when styles are applied while rendering text.
32 |  |  |  |  |
33 |--|--|--|--|
34 | Priority 1 | Style set by markup string. | Will override the style set through the control properties. | i.e The \<color\> tag will override the *TEXT_COLOR* property. |
35 | Priority 2 | Style set through the control properties. | Will override the default platform style. |  |
36 | Priority 3 | Default platform style. |  |  |
37
38 Font size has slightly different priorities - the size provided by the platform is a logical
39 size, and can be mapped to physical point sizes using style sheets. There is a default set of
40 sizes defined for DALi, and these can be overridden by application specific stylesheets. Thus
41 the priorities are:
42
43 |  |  |  |
44 |--|--|--|
45 | Priority 1 | Size set by markup string. | Will override the style set through the stylesheets. |
46 | Priority 2 | Physical Size set by application style sheet | |
47 | Priority 2 | Logical Size set by application style sheet | Mapping from platform logical to physical |
48 | Priority 3 | Logical Size set by DALi style sheet | Mapping from platform logical to physical |
49
50 See [Font Selection](@ref font-selection) for more details.
51
52 Current supported tags are:
53
54 ## \<color\>
55
56 Sets the color of the characters inside the tag. The *color* tag has a *value* attribute used to set the color. Possible values are: 'red', 'green', 'blue', 'yellow', 'magenta',
57  'cyan', 'white', 'black' and 'transparent'. Web color and 32 bits hexadecimal 0xAARRGGBB formats are also supported.
58
59 Examples below are equivalent, render the text in red. Second example codes the color in 0xAARRGGBB, third and fourth in web color with 3 and 6 characters.
60
61 ~~~{.cpp}
62 // C++
63 field.SetProperty( TextLabel::Property::TEXT, "<color value='red'>Red Text</color>" ); // Color coded with a text constant.
64 ~~~
65
66 ~~~{.js}
67 // JavaScript
68
69 field.text = "<color value='red'>Red Text</color>"; // Color coded with a text constant.
70 ~~~
71
72 ~~~{.cpp}
73 // C++
74 field.SetProperty( TextLabel::Property::TEXT, "<color value='0xFFFF0000'>Red Text</color>" ); // Color packed inside an ARGB hexadecimal value.
75 ~~~
76
77 ~~~{.js}
78 // JavaScript
79
80 field.text = "<color value='0xFFFF0000'>Red Text</color>"; // Color packed inside an ARGB hexadecimal value.
81 ~~~
82
83 ~~~{.cpp}
84 // C++
85 field.SetProperty( TextLabel::Property::TEXT, "<color value='#F00'>Red Text</color>" ); // Color packed with the web color format (3 characters).
86 ~~~
87
88 ~~~{.js}
89 // JavaScript
90
91 field.text = "<color value='#F00'>Red Text</color>"; // Color packed with the web color format (3 characters).
92 ~~~
93
94 ~~~{.cpp}
95 // C++
96 field.SetProperty( TextLabel::Property::TEXT, "<color value='#FF0000'>Red Text</color>" ); // Color packed with the web color format (6 characters).
97 ~~~
98
99 ~~~{.js}
100 // JavaScript
101
102 field.text = "<color value='#FF0000'>Red Text</color>"; // Color packed with the web color format (6 characters).
103 ~~~
104
105 ## \<font\>
106
107 Sets the font values of the characters inside the tag.
108
109 Supported attributes are:
110 - *family* The name of the font.
111 - *size* The size of the font in points.
112 - *weight* The weight of the font.
113 - *width* The width of the font
114 - *slant* The slant of the font.
115
116 See the [Font Selection](@ref font-selection) to have a view of the possible values for the *weight*, *width* and *slant* attributes.
117
118 ~~~{.cpp}
119 // C++
120 field.SetProperty( TextLabel::Property::TEXT, "<font family='SamsungSans' weight='bold'>Hello world</font>" );
121 ~~~
122
123 ~~~{.js}
124 // JavaScript
125
126 field.text = "<font family='SamsungSans' weight='bold'>Hello world</font>";
127 ~~~
128
129 */