コード例 #1
0
        public static int GetWpfValue(XFontFamily family, XFontStyle style, GWV value)
        {
            FontDescriptor descriptor = FontDescriptorStock.Global.CreateDescriptor(family, style);
            XFontMetrics   metrics    = descriptor.FontMetrics;

            switch (value)
            {
            case GWV.GetCellAscent:
                return(metrics.Ascent);

            case GWV.GetCellDescent:
                return(Math.Abs(metrics.Descent));

            case GWV.GetEmHeight:
                //return (int)metrics.CapHeight;
                return(metrics.UnitsPerEm);

            case GWV.GetLineSpacing:
                return(metrics.Ascent + Math.Abs(metrics.Descent) + metrics.Leading);

            default:
                throw new InvalidOperationException("Unknown GWV value.");
                // DELETE
                //case GWV.IsStyleAvailable:
                //  style &= XFontStyle.Regular | XFontStyle.Bold | XFontStyle.Italic | XFontStyle.BoldItalic; // same as XFontStyle.BoldItalic
                //  List<Typeface> s_typefaces = new List<Typeface>(family.wpfFamily.GetTypefaces());
                //  foreach (Typeface typeface in s_typefaces)
                //  {
                //  }
                //  Debugger.Break();
                ////typeface.Style = FontStyles.
            }
        }
コード例 #2
0
ファイル: FontHelper.cs プロジェクト: AnthonyNystrom/Pikling
    public static int GetWpfValue(XFontFamily family, XFontStyle style, GWV value)
    {
      FontDescriptor descriptor = FontDescriptorStock.Global.CreateDescriptor(family, style);
      XFontMetrics metrics = descriptor.FontMetrics;

      switch (value)
      {
        case GWV.GetCellAscent:
          return (int)metrics.Ascent;

        case GWV.GetCellDescent:
          return (int)Math.Abs(metrics.Descent);

        case GWV.GetEmHeight:
          return (int)metrics.CapHeight;

        case GWV.GetLineSpacing:
          return (int)(metrics.Ascent + Math.Abs(metrics.Descent) + metrics.Leading);

        case GWV.IsStyleAvailable:
          // TODOWPF: 
          System.Collections.Generic.List<Typeface> typefaces = new System.Collections.Generic.List<Typeface>(family.wpfFamily.GetTypefaces());
          foreach (Typeface typeface in typefaces)
          {
            Debugger.Break();
            //typeface.Style = FontStyles.
          }
          // TODOWPF
          return 1;
      }
      return 0;
    }
コード例 #3
0
    public static int GetWpfValue(XFontFamily family, XFontStyle style, GWV value)
    {
      FontDescriptor descriptor = FontDescriptorStock.Global.CreateDescriptor(family, style);
      XFontMetrics metrics = descriptor.FontMetrics;

      switch (value)
      {
        case GWV.GetCellAscent:
          return metrics.Ascent;

        case GWV.GetCellDescent:
          return Math.Abs(metrics.Descent);

        case GWV.GetEmHeight:
          //return (int)metrics.CapHeight;
          return metrics.UnitsPerEm;

        case GWV.GetLineSpacing:
          return metrics.Ascent + Math.Abs(metrics.Descent) + metrics.Leading;

        default:
          throw new InvalidOperationException("Unknown GWV value.");
        // DELETE
        //case GWV.IsStyleAvailable:
        //  style &= XFontStyle.Regular | XFontStyle.Bold | XFontStyle.Italic | XFontStyle.BoldItalic; // same as XFontStyle.BoldItalic
        //  List<Typeface> s_typefaces = new List<Typeface>(family.wpfFamily.GetTypefaces());
        //  foreach (Typeface typeface in s_typefaces)
        //  {
        //  }
        //  Debugger.Break();
        ////typeface.Style = FontStyles.
      }
    }