コード例 #1
0
        /** Hyphenates a word and returns the first part of it. To get
         * the second part of the hyphenated word call <CODE>getHyphenatedWordPost()</CODE>.
         * @param word the word to hyphenate
         * @param font the font used by this word
         * @param fontSize the font size used by this word
         * @param remainingWidth the width available to fit this word in
         * @return the first part of the hyphenated word including
         * the hyphen symbol, if any
         */
        public string getHyphenatedWordPre(string word, BaseFont font, float fontSize, float remainingWidth)
        {
            post = word;
            string hyphen      = this.HyphenSymbol;
            float  hyphenWidth = font.getWidthPoint(hyphen, fontSize);

            if (hyphenWidth > remainingWidth)
            {
                return("");
            }
            Hyphenation hyphenation = hyphenator.hyphenate(word);

            if (hyphenation == null)
            {
                return("");
            }
            int len = hyphenation.Length;
            int k;

            for (k = 0; k < len; ++k)
            {
                if (font.getWidthPoint(hyphenation.getPreHyphenText(k), fontSize) + hyphenWidth > remainingWidth)
                {
                    break;
                }
            }
            --k;
            if (k < 0)
            {
                return("");
            }
            post = hyphenation.getPostHyphenText(k);
            return(hyphenation.getPreHyphenText(k) + hyphen);
        }
コード例 #2
0
ファイル: PdfFont.cs プロジェクト: aakkssqq/CreatePDFCSharp
        /**
         * Returns the width of a certain character of this font.
         *
         * @param		character	a certain character
         * @return		a width in Text Space
         */

        internal float width(char character)
        {
            if (image == null)
            {
                return(font.getWidthPoint(character, size));
            }
            else
            {
                return(image.ScaledWidth);
            }
        }