Skip to content

Commit ed89b16

Browse files
committed
More docs
1 parent 093608a commit ed89b16

File tree

6 files changed

+69
-1
lines changed

6 files changed

+69
-1
lines changed

docfx/docs/rich-text.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
All widgets except TextBox do support [FontStashSharp rich text syntax](https://fontstashsharp.github.io/FontStashSharp/docs/rich-text.html).
2+
3+
I.e. if we take following MML:
4+
```xml
5+
<Project>
6+
<Panel>
7+
<Label Text="/c[red]First /cd/tuline/n/c[blue]/tdSecond /cd/tsLine" HorizontalAlignment="Center" VerticalAlignment="Center" />
8+
</Panel>
9+
</Project>
10+
```
11+
It would be rendered:
12+
13+
![alt text](~/images/rich-text-1.png)
14+
15+
Or if we take MML:
16+
```xml
17+
<Project>
18+
<Panel>
19+
<TextButton Text="E=mc/v[-8]2/n/vdMass–energy equivalence." HorizontalAlignment="Center" VerticalAlignment="Center"/>
20+
</Panel>
21+
</Project>
22+
```
23+
24+
It would result in:
25+
26+
![alt text](~/images/rich-text-2.png)
27+
28+
If we want to use commands that require external resources('/f' and '/i'), then we would need to set RichTextDefaults.FontResolver and RichTextDefaults.ImageResolver.
29+
30+
However there are special rules for the rtf resource resolving when using MyraPad. It requires resources to be either available in the same folder as the edited xmmp file. Or the resource folder path must be specified in the attribute DesignerRtfAssetsPath of the root tag Project. The resource folder path could be either absolute or relative to the location of the edited xmmp.
31+
32+
I.e. if we load following MML in the MyraPad:
33+
```xml
34+
<Project DesignerRtfAssetsPath="../../../tiles/releases/Nov-2015/dngn/trees">
35+
<Project.ExportOptions />
36+
<Panel>
37+
<TabControl HorizontalAlignment="Center" VerticalAlignment="Center" Height="260" GridRow="1">
38+
<TabItem Text="/i[mangrove1.png] /v[8]First Tab" />
39+
<TabItem Text="/i[mangrove2.png] /v[8]/tsSecond Tab" />
40+
<TabItem Text="/i[mangrove3.png] /v[8]/tuThird Tab" />
41+
</TabControl>
42+
</Panel>
43+
</Project>
44+
```
45+
46+
It would render following(assuming we have corresponding images mangrove*.png in the corresponding folder):
47+
48+
![alt text](~/images/rich-text-3.png)
49+
50+
The '/f' command parameter must be passed in form 'fontFileName, size'.
51+
52+
I.e. if we load following MML:
53+
```xml
54+
<Project DesignerRtfAssetsPath="C:\Windows\Fonts">
55+
<Project.ExportOptions />
56+
<Panel>
57+
<Label Text="Text in default font./n/f[arialbd.ttf, 24]Bold and smaller font. /f[ariali.ttf, 48]Italic and larger font./n/fdBack to the default font." HorizontalAlignment="Center" VerticalAlignment="Center" />
58+
</Panel>
59+
</Project>
60+
```
61+
62+
It would render following:
63+
64+
![alt text](~/images/rich-text-4.png)
65+
66+
**Note**. Above resource resolving rules work only in the MyraPad. The property DesignerRtfAssetsPath is ignored in the run-time. Thus its developer responsibility to set RichTextDefaults.FontResolver and RichTextDefaults.ImageResolver, if they want to use external resources in the rich text during the run-time.

docfx/docs/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
- name: Images
1010
href: images.md
1111
- name: Fonts
12-
href: fonts.md
12+
href: fonts.md
13+
- name: Rich Text
14+
href: rich-text.md

docfx/images/rich-text-1.png

4.52 KB
Loading

docfx/images/rich-text-2.png

6.08 KB
Loading

docfx/images/rich-text-3.png

91.1 KB
Loading

docfx/images/rich-text-4.png

79.6 KB
Loading

0 commit comments

Comments
 (0)