private float GetStringWidth(string str, float curFontSize, float pSingleSpaceWidth, DocumentFont pFont)
    {
        char[] chars      = str.ToCharArray();
        float  totalWidth = 0;
        float  w          = 0;

        foreach (Char c in chars)
        {
            w           = pFont.GetWidth(c) / 1000;
            totalWidth += (w * curFontSize + this.UndercontentCharacterSpacing) * this.UndercontentHorizontalScaling / 100;
        }
        return(totalWidth);
    }
Пример #2
0
        private float GetStringWidth(string currentText, float curFontSize, float pSingleSpaceWidth, DocumentFont pFont)
        {
            char[] chArray = currentText.ToCharArray();
            float  left    = 0f;
            float  num3    = 0f;

            foreach (char theCharacter in chArray)
            {
                num3  = (float)(((double)pFont.GetWidth(Convert.ToString(theCharacter))) / 1000.0);
                left += Convert.ToSingle(num3 * curFontSize);
            }
            return(left);
        }
Пример #3
0
        /**
         * Gets the width of a String in text space units
         * @param string    the string that needs measuring
         * @return  the width of a String in text space units
         */
        private float GetStringWidth(String str)
        {
            DocumentFont font = gs.font;

            char[] chars      = str.ToCharArray();
            float  totalWidth = 0;

            for (int i = 0; i < chars.Length; i++)
            {
                float w           = font.GetWidth(chars[i]) / 1000.0f;
                float wordSpacing = chars[i] == 32 ? gs.wordSpacing : 0f;
                totalWidth += (w * gs.fontSize + gs.characterSpacing + wordSpacing) * gs.horizontalScaling;
            }

            return(totalWidth);
        }
        /**
         * Provides detail useful if a listener needs access to the position of each individual glyph in the text render operation
         * @return A list of {@link TextRenderInfo} objects that represent each glyph used in the draw operation. The next effect is if there was a separate Tj opertion for each character in the rendered string
         * @since 5.3.3
         */
        public List <TextRenderInfo> GetCharacterRenderInfos()
        {
            List <TextRenderInfo> rslt = new List <TextRenderInfo>(text.Length);

            DocumentFont font = gs.font;

            char[] chars      = text.ToCharArray();
            float  totalWidth = 0;

            for (int i = 0; i < chars.Length; i++)
            {
                float w           = font.GetWidth(chars[i]) / 1000.0f;
                float wordSpacing = chars[i] == 32 ? gs.wordSpacing : 0f;

                TextRenderInfo subInfo = new TextRenderInfo(this, i, totalWidth);
                rslt.Add(subInfo);

                totalWidth += (w * gs.fontSize + gs.characterSpacing + wordSpacing) * gs.horizontalScaling;
            }

            return(rslt);
        }