Skip to content

Commit 093608a

Browse files
committed
Added docs
1 parent 2837404 commit 093608a

File tree

4 files changed

+61
-5
lines changed

4 files changed

+61
-5
lines changed

docfx/docs/adding-reference-to-fna.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Clone following projects in one folder:
22

33
Link|Description
44
----|-----------
5-
https://github.com/FNA-XNA/FNA|FNA
6-
https://github.com/FontStashSharp/FontStashSharp|Text rendering library
7-
https://github.com/rds1983/XNAssets|Assets management library
8-
https://github.com/rds1983/Myra|Myra
5+
<https://github.com/FNA-XNA/FNA>|FNA
6+
<https://github.com/FontStashSharp/FontStashSharp>|Text rendering library
7+
<https://github.com/rds1983/XNAssets>|Assets management library
8+
<https://github.com/rds1983/Myra>|Myra
99

1010
Now add every required project .FNA.Core.csproj to your project

docfx/docs/fonts.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Myra uses [FontStashSharp](https://github.com/FontStashSharp/FontStashSharp) for the text rendering.
2+
3+
Sample code for setting font:
4+
```c#
5+
byte[] ttfData = File.ReadAllBytes("DroidSans.ttf");
6+
7+
// Ordinary DynamicSpriteFont
8+
FontSystem ordinaryFontSystem = new FontSystem();
9+
ordinaryFontSystem.AddFont(ttfData);
10+
_label1.Font = ordinaryFontSystem.GetFont(32);
11+
12+
// Stroked DynamicSpriteFont
13+
FontSystemSettings strokedSettings = new FontSystemSettings
14+
{
15+
Effect = FontSystemEffect.Stroked,
16+
EffectAmount = 1
17+
};
18+
FontSystem strokedFontSystem = new FontSystem(strokedSettings);
19+
strokedFontSystem.AddFont(ttfData);
20+
_label2.Font = strokedFontSystem.GetFont(24);
21+
22+
// Blurry DynamicSpriteFont
23+
FontSystemSettings blurrySettings = new FontSystemSettings
24+
{
25+
Effect = FontSystemEffect.Blurry,
26+
EffectAmount = 1
27+
};
28+
FontSystem blurryFontSystem = new FontSystem(blurrySettings);
29+
blurryFontSystem.AddFont(ttfData);
30+
_label3.Font = blurryFontSystem.GetFont(48);
31+
32+
// StaticSpriteFont in AngelCode BMFont Format(https://www.angelcode.com/products/bmfont/)
33+
string fntData = File.ReadAllText("comicSans48.fnt");
34+
_label4.Font = StaticSpriteFont.FromBMFont(fntData, atlasFileName => File.OpenRead(atlasFileName), GraphicsDevice);
35+
```
36+
37+
It is equivalent to the following MML:
38+
```xml
39+
<Project>
40+
<Project.ExportOptions />
41+
<Panel Background="#4BD961FF">
42+
<VerticalStackPanel HorizontalAlignment="Center" VerticalAlignment="Center" >
43+
<Label Text="Hello, World!" Font="DroidSans.ttf:32" />
44+
<Label Text="Hello, World!" Font="DroidSans.ttf:Stroked:1:24" />
45+
<Label Text="Hello, World!" Font="DroidSans.ttf:Blurry:2:48" />
46+
<Label Text="Hello, World!" Font="comicSans48.fnt" />
47+
</VerticalStackPanel>
48+
</Panel>
49+
</Project>
50+
```
51+
52+
Which would result to the following:
53+
54+
![alt text](~/images/fonts.png)

docfx/docs/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
- name: MyraPad
88
href: MyraPad.md
99
- name: Images
10-
href: Images.md
10+
href: images.md
11+
- name: Fonts
12+
href: fonts.md

docfx/images/fonts.png

173 KB
Loading

0 commit comments

Comments
 (0)