forked from adapt-it/cordova-fonts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace WPCordovaClassLib.Cordova.Commands | ||
{ | ||
/// <summary> | ||
/// Provides information about system locale, culture settings, number formats, ect. | ||
/// </summary> | ||
public class Fonts : BaseCommand | ||
{ | ||
/// <summary> | ||
/// Gets the string identifier for the client's current language. | ||
/// </summary> | ||
/// <param name="options"></param> | ||
public void getPreferredLanguage(string options) | ||
{ | ||
try | ||
{ | ||
var language = CultureInfo.CurrentUICulture.Name; | ||
PluginResult result = new PluginResult(PluginResult.Status.OK, this.WrapIntoJSON(language)); | ||
this.DispatchCommandResult(result); | ||
} | ||
catch (Exception) | ||
{ | ||
this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new GlobalizationError())); | ||
} | ||
} | ||
|
||
|
||
FontFamily fontFamily = new FontFamily("Arial"); | ||
Font font = new Font( | ||
fontFamily, | ||
8, | ||
FontStyle.Regular, | ||
GraphicsUnit.Point); | ||
RectangleF rectF = new RectangleF(10, 10, 500, 500); | ||
SolidBrush solidBrush = new SolidBrush(Color.Black); | ||
|
||
string familyName; | ||
string familyList = ""; | ||
FontFamily[] fontFamilies; | ||
|
||
InstalledFontCollection installedFontCollection = new InstalledFontCollection(); | ||
|
||
// Get the array of FontFamily objects. | ||
fontFamilies = installedFontCollection.Families; | ||
|
||
// The loop below creates a large string that is a comma-separated | ||
// list of all font family names. | ||
|
||
int count = fontFamilies.Length; | ||
for (int j = 0; j < count; ++j) | ||
{ | ||
familyName = fontFamilies[j].Name; | ||
familyList = familyList + familyName; | ||
familyList = familyList + ", "; | ||
} | ||
|
||
// Draw the large string (list of all families) in a rectangle. | ||
e.Graphics.DrawString(familyList, font, solidBrush, rectF); | ||
} | ||
} |