コード例 #1
0
ファイル: CairoBackend.cs プロジェクト: kuggaa/longomatch
        public void MeasureText(string text, out int width, out int height,
                                string fontFamily, int fontSize, FontWeight fontWeight)
        {
            FontDescription desc = new FontDescription();

            desc.Family            = fontFamily;
            desc.Size              = Pango.Units.FromPixels(fontSize);
            desc.Weight            = WeightToPangoWeight(fontWeight);
            layout.FontDescription = desc;
            layout.SetMarkup(GLib.Markup.EscapeText(text));
            layout.GetPixelSize(out width, out height);
        }
コード例 #2
0
ファイル: CairoBackend.cs プロジェクト: kuggaa/longomatch
        Weight WeightToPangoWeight(FontWeight value)
        {
            Weight weight = Weight.Normal;

            switch (value)
            {
            case FontWeight.Light:
                weight = Weight.Light;
                break;

            case FontWeight.Bold:
                weight = Weight.Semibold;
                break;

            case FontWeight.Normal:
                weight = Weight.Normal;
                break;
            }
            return(weight);
        }