Source/OxyPlot.Avalonia/CanvasRenderContext.cs
/// <summary>
/// Measures the size of the specified text.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="fontFamily">The font family.</param>
/// <param name="fontSize">Size of the font (in device independent units, 1/96 inch).</param>
/// <param name="fontWeight">The font weight.</param>
/// <returns>
/// The size of the text (in device independent units, 1/96 inch).
/// </returns>
Measures the size of the specified text.
Measures the size of the specified text .
public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
        {
            if (string.IsNullOrEmpty(text))
            {
                return OxySize.Empty;
            }
            var tb = new TextBlock { Text = text };
            if (fontFamily != null)
            {
                tb.FontFamily = fontFamily;
            }
            if (fontSize > 0)
            {
                tb.FontSize = fontSize;
            }
            if (fontWeight > 0)
            {
                tb.FontWeight = GetFontWeight(fontWeight);
            }
            tb.Measure(new Size(1000, 1000));
            return new OxySize(tb.DesiredSize.Width, tb.DesiredSize.Height);
        }
public OxySize MeasureText ( string text , string fontFamily , double fontSize , double fontWeight ) { if ( string . IsNullOrEmpty ( text ) ) { return OxySize . Empty ; } var tb = new TextBlock { Text = text } ; if ( fontFamily != null ) { tb . FontFamily = fontFamily ; } if ( fontSize > 0 ) { tb . FontSize = fontSize ; } if ( fontWeight > 0 ) { tb . FontWeight = GetFontWeight ( fontWeight ) ; } tb . Measure ( new Size ( 1000 , 1000 ) ) ; return new OxySize ( tb . DesiredSize . Width , tb . DesiredSize . Height ) ; }
Measures the size of the specified text.
Measures the size of the specified text .
The size of the text (in device independent units, 1/96 inch).
The size of the text ( in device independent units 1 / 96 inch ) .
text
string
None
fontFamily
string
The font family.
The font family .
fontSize
double
Size of the font (in device independent units, 1/96 inch).
Size of the font ( in device independent units 1 / 96 inch ) .
fontWeight
double
The font weight.
The font weight .