首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是scaledSize (Legend.FontSpec)

什么是scaledSize (Legend.FontSpec)
EN

Stack Overflow用户
提问于 2015-10-09 20:40:39
回答 2查看 135关注 0票数 0

我正在尝试在ZedGraph上设置图例的字体大小。但是,大小从来没有出现在我设置的位置。

这个值从何而来?我已经检查了我的代码(我从其他人手中接管了项目,这是一个大项目,所以很难找到它),并在ZedGraph对象的其他地方查找某种缩放项,但找不到如何设置此值。它是以某种方式自动计算的吗?

我也在网上找过答案,但一无所获。

EN

回答 2

Stack Overflow用户

发布于 2015-10-09 20:56:47

这是Size的设置器:

代码语言:javascript
复制
set
{
    if ( value != _size )
    {
        Remake( _scaledSize / _size * value, _size, ref _scaledSize,
                    ref _font );
        _size = value;
    }
}
//...

/// <summary>
/// Recreate the font based on a new scaled size.  The font
/// will only be recreated if the scaled size has changed by
/// at least 0.1 points.
/// </summary>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects.  This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <param name="size">The unscaled size of the font, in points</param>
/// <param name="scaledSize">The scaled size of the font, in points</param>
/// <param name="font">A reference to the <see cref="Font"/> object</param>
private void Remake( float scaleFactor, float size, ref float scaledSize, ref Font font )
{
    float newSize = size * scaleFactor;

    float oldSize = ( font == null ) ? 0.0f : font.Size;

    // Regenerate the font only if the size has changed significantly
    if ( font == null ||
            Math.Abs( newSize - oldSize ) > 0.1 ||
            font.Name != this.Family ||
            font.Bold != _isBold ||
            font.Italic != _isItalic ||
            font.Underline != _isUnderline )
    {
        FontStyle style = FontStyle.Regular;
        style = ( _isBold ? FontStyle.Bold : style ) |
                    ( _isItalic ? FontStyle.Italic : style ) |
                     ( _isUnderline ? FontStyle.Underline : style );

        scaledSize = size * (float)scaleFactor;
        font = new Font( _family, scaledSize, style, GraphicsUnit.World );
    }
}

有趣的代码行是:

代码语言:javascript
复制
scaledSize = size * (float)scaleFactor;
font = new Font( _family, scaledSize, style, GraphicsUnit.World );

这意味着您的大小是使用PaneBase.CalcScaleFactor缩放的。你应该看看这最后一个

票数 0
EN

Stack Overflow用户

发布于 2015-10-09 21:46:46

ZedGraph会根据窗格的大小自动缩放所有字体。

这是通过GraphPane.IsFontScaled属性控制的。将其设置为false,您的字体应保持您设置的大小。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33038582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档