Skip to content

Commit 0fa56f8

Browse files
committed
Adds nicer/bigger font
Renames Primitives3D to 2D Changes colors to something more appropriate Resized textbox Adds Arsenal.spritefont Updates README.md
1 parent a281ac4 commit 0fa56f8

File tree

9 files changed

+126
-14
lines changed

9 files changed

+126
-14
lines changed

MonoGame-Textbox/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.1")]
36-
[assembly: AssemblyFileVersion("1.0.0.1")]
35+
[assembly: AssemblyVersion("1.0.0.2")]
36+
[assembly: AssemblyFileVersion("1.0.0.2")]

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,33 @@ This repository located on our [homepage][homepage] is private since this is th
1212
If you want to contribute to our repository (push, open pull requests), please use the copy on github located here: [the public github repository][github]
1313

1414
# Monogame-Textbox
15-
An editable, multi-language, event-driven textbox for MonoGame that supports selection and cut/copy/paste.
15+
An editable, multi-language, event-driven textbox for MonoGame that supports selection, special characters, SHIFT-CTRL combinations with cursor-keys and cut/copy/paste.
1616

1717
## Getting Started
1818
Clone the repository and run the project `Textbox-Test` as startup project.
1919
Nuget should take care about the rest...
2020

21-
Write, select, delete, cut, copy, paste, press **home**, press **pos1**...
21+
Write, select, delete, cut (ctrl-x), copy (ctrl-c), paste (ctrl-v), press **home**, press **pos1**, keep **shift** pressed while pressing a cursor key to select, try pressing **ctrl** while doing so in order to jump words ahead or back...
2222

2323
![Screenshot](https://github.com/UnterrainerInformatik/MonoGame-Textbox/blob/master/Textbox-Test.png)
2424

25-
### Used Tools
25+
### General Information
26+
27+
I generate the SpriteFont used in the test-projects using a `.spritefont` description-file read by the content-pipeline tool because of the insane amount of supported glyphs.
28+
29+
The reason why I don't use the automated build-pipeline for this is that it would require everyone to install the True-Type Font referenced further down this file. You are free to do so, in which case you may as well add the file `Arsenal.spritefont` to your automated build-pipeline of your project.
30+
31+
#### Used Tools
2632

2733
* [Resharper][https://www.jetbrains.com/resharper/]
34+
2835
* [MonoGame](http://www.monogame.net/)
29-
* You can easily get rid of the `Primitives2D.cs` class. It's only there to draw the outline of the textbox in the demo.
36+
37+
* You can easily get rid of the `Primitives2D.cs` class when you incorporate it in your own project. It's only there to draw the outline of the textbox in the demo.
38+
39+
* The font is called Arsenal and you can find it here [Fontsquirrel - Arsenal](https://www.fontsquirrel.com/fonts/arsenal?q%5Bterm%5D=arsenal&q%5Bsearch_check%5D=Y)
40+
41+
It has an insane amount of supported languages (and therefore glyphs) and is under the SIL Open Font License v1.10. So it's safe to use in your games.
3042

3143

3244

Textbox-Test.png

3.38 KB
Loading
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file contains an xml description of a font, and will be read by the XNA
4+
Framework Content Pipeline. Follow the comments to customize the appearance
5+
of the font in your game, and to change the characters which are available to draw
6+
with.
7+
-->
8+
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
9+
<Asset Type="Graphics:FontDescription">
10+
11+
<!--
12+
Modify this string to change the font that will be imported.
13+
-->
14+
<FontName>Arsenal</FontName>
15+
16+
<!--
17+
Size is a float value, measured in points. Modify this value to change
18+
the size of the font.
19+
-->
20+
<Size>18</Size>
21+
22+
<!--
23+
Spacing is a float value, measured in pixels. Modify this value to change
24+
the amount of spacing in between characters.
25+
-->
26+
<Spacing>0</Spacing>
27+
28+
<!--
29+
UseKerning controls the layout of the font. If this value is true, kerning information
30+
will be used when placing characters.
31+
-->
32+
<UseKerning>true</UseKerning>
33+
34+
<!--
35+
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
36+
and "Bold, Italic", and are case sensitive.
37+
-->
38+
<Style>Regular</Style>
39+
40+
<!--
41+
If you uncomment this line, the default character will be substituted if you draw
42+
or measure text that contains characters which were not included in the font.
43+
-->
44+
<!-- <DefaultCharacter>*</DefaultCharacter> -->
45+
46+
<!--
47+
CharacterRegions control what letters are available in the font. Every
48+
character from Start to End will be built and made available for drawing. The
49+
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
50+
character set. The characters are ordered according to the Unicode standard.
51+
See the documentation for more information.
52+
-->
53+
<CharacterRegions>
54+
<!-- Basic Latin -->
55+
<CharacterRegion>
56+
<Start>&#x20;</Start>
57+
<End>&#x7F;</End>
58+
</CharacterRegion>
59+
<!-- Latin-1 Supplement -->
60+
<CharacterRegion>
61+
<Start>&#x80;</Start>
62+
<End>&#xFF;</End>
63+
</CharacterRegion>
64+
<!-- Latin Extended-A -->
65+
<CharacterRegion>
66+
<Start>&#x100;</Start>
67+
<End>&#x17F;</End>
68+
</CharacterRegion>
69+
<!-- Cyrillic -->
70+
<CharacterRegion>
71+
<Start>&#x400;</Start>
72+
<End>&#x4FF;</End>
73+
</CharacterRegion>
74+
<!-- General Punctuation -->
75+
<CharacterRegion>
76+
<Start>&#x2000;</Start>
77+
<End>&#x206F;</End>
78+
</CharacterRegion>
79+
<!-- Spacing Modifier Letters -->
80+
<CharacterRegion>
81+
<Start>&#x2B0;</Start>
82+
<End>&#x2FF;</End>
83+
</CharacterRegion>
84+
85+
<!-- Single Characters -->
86+
<CharacterRegion>
87+
<Start>&#x20AC;</Start>
88+
<End>&#x20AC;</End>
89+
</CharacterRegion>
90+
<CharacterRegion>
91+
<Start>&#x20B4;</Start>
92+
<End>&#x20B4;</End>
93+
</CharacterRegion>
94+
95+
</CharacterRegions>
96+
</Asset>
97+
</XnaContent>
600 KB
Binary file not shown.

Textbox-Test/Game1.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ protected override void LoadContent()
7777

7878
font = Content.Load<SpriteFont>("Arsenal");
7979

80-
viewport = new Rectangle(50, 50, 400, 100);
80+
viewport = new Rectangle(50, 50, 400, 200);
8181
textBox = new TextBox(viewport, 200, "This is a test. Move the cursor, select, delete, write...",
82-
GraphicsDevice, font,
83-
Color.LightGray, Color.LightBlue, 30);
82+
GraphicsDevice, font, Color.LightGray, Color.DarkGreen, 30);
8483
}
8584

8685
/// <summary>
@@ -111,8 +110,11 @@ protected override void Update(GameTime gameTime)
111110
textBox.Area = new Rectangle((int) (viewport.X + margin), viewport.Y, (int) (viewport.Width - margin),
112111
viewport.Height);
113112
textBox.Renderer.Color = Color.White;
114-
textBox.Cursor.Color = Color.LightGray;
115-
textBox.Cursor.Selection = Color.LightBlue;
113+
textBox.Cursor.Selection = new Color(Color.Purple, .4f);
114+
115+
float lerpAmount = (float) (gameTime.TotalGameTime.TotalMilliseconds % 500f/500f);
116+
textBox.Cursor.Color = Color.Lerp(Color.DarkGray, Color.LightGray, lerpAmount);
117+
116118
textBox.Active = true;
117119
textBox.Update();
118120

File renamed without changes.

Textbox-Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.1")]
36-
[assembly: AssemblyFileVersion("1.0.0.1")]
35+
[assembly: AssemblyVersion("1.0.0.2")]
36+
[assembly: AssemblyFileVersion("1.0.0.2")]

Textbox-Test/Textbox-Test.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</PropertyGroup>
4747
<ItemGroup>
4848
<Compile Include="Game1.cs" />
49-
<Compile Include="Primitives3D.cs" />
49+
<Compile Include="Primitives2D.cs" />
5050
<Compile Include="Program.cs" />
5151
<Compile Include="Properties\AssemblyInfo.cs" />
5252
</ItemGroup>
@@ -65,6 +65,7 @@
6565
<MonoGameContentReference Include="Content\Content.mgcb" />
6666
<None Include="app.config" />
6767
<None Include="app.manifest" />
68+
<None Include="Content\Arsenal.spritefont" />
6869
<None Include="packages.config" />
6970
</ItemGroup>
7071
<ItemGroup>

0 commit comments

Comments
 (0)