Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
FontHelper.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 namespace SiliconStudio.Paradox.Graphics.Font
5 {
6  public static class FontHelper
7  {
8  /// <summary>
9  /// Converts a font size from points to pixels. Can't just let GDI+ do this for us, because we want identical results on every machine regardless of system DPI settings.
10  /// </summary>
11  /// <param name="points">The size in number of points</param>
12  /// <returns>The size in number of pixels</returns>
13  public static float PointsToPixels(float points)
14  {
15  return points * 96 / 72;
16  }
17 
18  /// <summary>
19  /// Build the path of a font in the database given the name of the font family and the font style.
20  /// </summary>
21  /// <param name="fontName">Family name of the font</param>
22  /// <param name="style">The style of the font</param>
23  /// <remarks>This function does not indicate it the font exists or not in the database.</remarks>
24  /// <returns>The absolute path of the font in the database</returns>
25  public static string GetFontPath(string fontName, FontStyle style)
26  {
27  var styleName = "";
28  if ((style & FontStyle.Bold) == FontStyle.Bold)
29  styleName += " Bold";
30  if ((style & FontStyle.Italic) == FontStyle.Italic)
31  styleName += " Italic";
32 
33  return "fonts/" + fontName + styleName + ".ttf";
34  }
35  }
36 }
static string GetFontPath(string fontName, FontStyle style)
Build the path of a font in the database given the name of the font family and the font style...
Definition: FontHelper.cs:25
SharpDX.DirectWrite.Font Font
static float PointsToPixels(float points)
Converts a font size from points to pixels. Can't just let GDI+ do this for us, because we want ident...
Definition: FontHelper.cs:13