[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/Xsharp Font.cs,1.4,1.5
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/Xsharp Font.cs,1.4,1.5 |
Date: |
Sun, 30 Nov 2003 05:41:33 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv14568/Xsharp
Modified Files:
Font.cs
Log Message:
The default font is named "Microsoft Sans Serif", not "Arial"; remove the
dpi adjustments on "SizeInPoints" because they weren't supposed to be
there; normalize font sizes to the nearest supported X size to prevent
horrid looking stretched bitmap fonts.
Index: Font.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Font.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Font.cs 30 Nov 2003 05:00:21 -0000 1.4
--- Font.cs 30 Nov 2003 05:41:31 -0000 1.5
***************
*** 51,54 ****
--- 51,59 ----
/// <para>The family name for the default sans-serif font.</para>
/// </summary>
+ public static readonly String DefaultSansSerif = "defaultsans";
+
+ /// <summary>
+ /// <para>The family name for the usual X sans-serif font.</para>
+ /// </summary>
public static readonly String SansSerif = "helvetica";
***************
*** 63,84 ****
public static readonly String Fixed = "courier";
! /// <summary>
! /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>.
! /// </para>
! /// </summary>
! ///
! /// <param name="family">
! /// <para>The name of the font family, or <see langword="null"/> to
! /// use the default sans-serif font.</para>
! /// </param>
! ///
! /// <param name="pointSize">
! /// <para>The point size (120 is typically "normal height").</para>
! /// </param>
! ///
! /// <param name="style">
! /// <para>Additional styles to apply to the font.</para>
! /// </param>
! public Font(String family, int pointSize, FontStyle style)
{
if(family != null)
--- 68,73 ----
public static readonly String Fixed = "courier";
! // Constructors.
! private Font(String family, int pointSize, FontStyle style)
{
if(family != null)
***************
*** 94,133 ****
this.infoList = null;
}
-
- /// <summary>
- /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
- /// with a default point size and style.</para>
- /// </summary>
- ///
- /// <param name="family">
- /// <para>The name of the font family, or <see langword="null"/> to
- /// use the default sans-serif font.</para>
- /// </param>
- public Font(String family)
- : this(family, 120, FontStyle.Normal)
- {
- // Nothing to do here.
- }
-
- /// <summary>
- /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
- /// with a default style.</para>
- /// </summary>
- ///
- /// <param name="family">
- /// <para>The name of the font family, or <see langword="null"/> to
- /// use the default sans-serif font.</para>
- /// </param>
- ///
- /// <param name="pointSize">
- /// <para>The point size (120 is typically "normal height").</para>
- /// </param>
- public Font(String family, int pointSize)
- : this(family, pointSize, FontStyle.Normal)
- {
- // Nothing to do here.
- }
-
- // Internal constructor that is called from "CreateFromXLFD".
private Font(String name, bool unused)
{
--- 83,86 ----
***************
*** 251,254 ****
--- 204,289 ----
/// <summary>
+ /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>.
+ /// </para>
+ /// </summary>
+ ///
+ /// <param name="family">
+ /// <para>The name of the font family, or <see langword="null"/> to
+ /// use the default sans-serif font.</para>
+ /// </param>
+ ///
+ /// <param name="pointSize">
+ /// <para>The point size (120 is typically "normal height").</para>
+ /// </param>
+ ///
+ /// <param name="style">
+ /// <para>Additional styles to apply to the font.</para>
+ /// </param>
+ ///
+ /// <para>The font object that corresponds to the given
parameters.</para>
+ /// </returns>
+ public static Font CreateFont
+ (String family, int pointSize, FontStyle style)
+ {
+ if(family == DefaultSansSerif)
+ {
+ // TODO: we will need to map this
differently in future.
+ family = SansSerif;
+ }
+ return new Font(family, pointSize, style);
+ }
+
+ /// <summary>
+ /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
+ /// with a default point size and style.</para>
+ /// </summary>
+ ///
+ /// <param name="family">
+ /// <para>The name of the font family, or <see langword="null"/> to
+ /// use the default sans-serif font.</para>
+ /// </param>
+ public static Font CreateFont(String family)
+ {
+ return CreateFont(family, 120,
FontStyle.Normal);
+ }
+
+ /// <summary>
+ /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
+ /// with a default style.</para>
+ /// </summary>
+ ///
+ /// <param name="family">
+ /// <para>The name of the font family, or <see langword="null"/> to
+ /// use the default sans-serif font.</para>
+ /// </param>
+ ///
+ /// <param name="pointSize">
+ /// <para>The point size (120 is typically "normal height").</para>
+ /// </param>
+ public static Font CreateFont(String family, int pointSize)
+ {
+ return CreateFont(family, pointSize,
FontStyle.Normal);
+ }
+
+ /// <summary>
+ /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
+ /// with a default style.</para>
+ /// </summary>
+ ///
+ /// <param name="family">
+ /// <para>The name of the font family, or <see langword="null"/> to
+ /// use the default sans-serif font.</para>
+ /// </param>
+ ///
+ /// <param name="pointSize">
+ /// <para>The point size (120 is typically "normal height").</para>
+ /// </param>
+ public Font(String family, int pointSize)
+ : this(family, pointSize, FontStyle.Normal)
+ {
+ // Nothing to do here.
+ }
+
+ /// <summary>
/// <para>Construct a font from an XLFD name.</para>
/// </summary>
***************
*** 266,270 ****
if(name == null)
{
! return new Font(null);
}
else
--- 301,305 ----
if(name == null)
{
! return CreateFont(null);
}
else
***************
*** 486,489 ****
--- 521,558 ----
}
+ // Normalize a point size to make it match a nearby X font size so
+ // that we don't get unsightly stretching.
+ private static int NormalizePointSize(int pointSize)
+ {
+ if(pointSize < 90)
+ {
+ return 80;
+ }
+ else if(pointSize < 110)
+ {
+ return 100;
+ }
+ else if(pointSize < 130)
+ {
+ return 120;
+ }
+ else if(pointSize < 160)
+ {
+ return 140;
+ }
+ else if(pointSize < 210)
+ {
+ return 180;
+ }
+ else if(pointSize <= 240)
+ {
+ return 240;
+ }
+ else
+ {
+ return pointSize;
+ }
+ }
+
// Get the XFontSet structure for this font on a particular display.
internal IntPtr GetFontSet(Display dpy)
***************
*** 523,527 ****
IntPtr display = dpy.Lock();
fontSet = Xlib.XSharpCreateFont
! (display, family,
pointSize, (int)style);
if(fontSet == IntPtr.Zero)
{
--- 592,597 ----
IntPtr display = dpy.Lock();
fontSet = Xlib.XSharpCreateFont
! (display, family,
!
NormalizePointSize(pointSize), (int)style);
if(fontSet == IntPtr.Zero)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/Xsharp Font.cs,1.4,1.5,
Rhys Weatherley <address@hidden> <=