IsMonospacingActive() public method

public IsMonospacingActive ( QFontRenderOptions options ) : bool
options QFontRenderOptions
return bool
示例#1
0
        private float MeasureTextNodeLength(TextNode node, QFontData fontData, QFontRenderOptions options)
        {
            bool  monospaced     = fontData.IsMonospacingActive(options);
            float monospaceWidth = fontData.GetMonoSpaceWidth(options);

            if (node.Type == TextNodeType.Space)
            {
                if (monospaced)
                {
                    return(monospaceWidth);
                }

                return((float)Math.Ceiling(fontData.meanGlyphWidth * options.WordSpacing));
            }

            float length = 0f;
            float height = 0f;

            if (node.Type == TextNodeType.Word)
            {
                for (int i = 0; i < node.Text.Length; i++)
                {
                    char c = node.Text[i];
                    if (fontData.CharSetMapping.ContainsKey(c))
                    {
                        var glyph = fontData.CharSetMapping[c];
                        if (monospaced)
                        {
                            length += monospaceWidth;
                        }
                        else
                        {
                            length += (float)Math.Ceiling(fontData.CharSetMapping[c].rect.Width + fontData.meanGlyphWidth * options.CharacterSpacing + fontData.GetKerningPairCorrection(i, node.Text, node));
                        }
                        height = Math.Max(height, glyph.yOffset + glyph.rect.Height);
                    }
                }
            }
            node.Height = height;
            return(length);
        }
示例#2
0
        private float MeasureTextNodeLength(TextNode node, QFontData fontData, QFontRenderOptions options)
        {
            bool  monospaced     = fontData.IsMonospacingActive(options);
            float monospaceWidth = fontData.GetMonoSpaceWidth(options);

            if (node.Type == TextNodeType.Space)
            {
                if (monospaced)
                {
                    return(monospaceWidth);
                }

                return((float)Math.Ceiling(fontData.meanGlyphWidth * options.WordSpacing));
            }

            float length = 0f;

            if (node.Type == TextNodeType.Word)
            {
                for (int i = 0; i < node.Text.Length; i++)
                {
                    char       c = node.Text[i];
                    QFontGlyph glyph;
                    if (fontData.CharSetMapping.TryGetValue(c, out glyph))
                    {
                        if (monospaced)
                        {
                            length += monospaceWidth;
                        }
                        else
                        {
                            length += (float)Math.Ceiling(glyph.rect.Width + fontData.meanGlyphWidth * options.CharacterSpacing + fontData.GetKerningPairCorrection(i, node.Text, node));
                        }
                    }
                }
            }
            return(length);
        }
示例#3
0
        private float MeasureTextNodeLength(TextNode node, QFontData fontData, QFontRenderOptions options)
        {
            bool monospaced = fontData.IsMonospacingActive(options);
            float monospaceWidth = fontData.GetMonoSpaceWidth(options);

            if (node.Type == TextNodeType.Space)
            {
                if (monospaced)
                    return monospaceWidth;

                return (float)Math.Ceiling(fontData.meanGlyphWidth * options.WordSpacing);
            }

            float length = 0f;
            if (node.Type == TextNodeType.Word)
            {

                for (int i = 0; i < node.Text.Length; i++)
                {
                    char c = node.Text[i];
                    if (fontData.CharSetMapping.ContainsKey(c))
                    {
                        if (monospaced)
                            length += monospaceWidth;
                        else
                            length += (float)Math.Ceiling(fontData.CharSetMapping[c].rect.Width + fontData.meanGlyphWidth * options.CharacterSpacing + fontData.GetKerningPairCorrection(i, node.Text, node));
                    }
                }
            }
            return length;
        }
 private bool IsMonospacingActive()
 {
     return(Font.IsMonospacingActive(Options));
 }