예제 #1
0
        //----------------------------------------------------------------------------------------------------x
        //----------------------------------------------------------------------------------------------------x
        /// <summary>
        ///
        /// </summary>
        /// <param name="sText"></param>
        /// <returns></returns>
        public Double rWidth(String sText)
        {
            if (sText.Length == 0)
            {
                return(0);
            }

            Double rWidth       = 0;
            Double rCharSpacing = 0;
            Double rWordSpacing = 0;

            foreach (Char c in sText)
            {
                Int16 iChar = (Int16)c;
                Type1FontData.CharMetrics acm = afmCharMetrics(iChar);
                if (acm == null)
                {
                    Console.WriteLine("Unknown character [" + c + "/" + iChar + "] in string [" + sText + "].");
                }
                else
                {
                    Debug.Assert(!Single.IsNaN(acm.fWidthX));
                    rWidth += acm.fWidthX;
                }
                if (c == ' ')
                {
                    rWidth += rWordSpacing;
                }
            }
            rWidth += (sText.Length - 1) * rCharSpacing;
            return(rWidth);
        }
예제 #2
0
 //----------------------------------------------------------------------------------------------------x
 /// <summary>Gets the size factor of the font.</summary>
 /// <param name="fontProp">Font properties</param>
 /// <returns>Size factor</returns>
 internal Double rSizeFactor(FontProp fontProp)
 {
     if (fontProp.fontDef.sFontName == "Symbol" || fontProp.fontDef.sFontName == "ZapfDingbats")
     {
         Type1FontData.CharMetrics afmCharMetrics = afm.afmCharMetrics(74);
         Debug.Assert(!(Single.IsNaN(afmCharMetrics.fBBox_ury)));
         Debug.Assert(!(Single.IsNaN(afmCharMetrics.fBBox_lly)));
         return(fontProp.rSize * 1000.0 / (afmCharMetrics.fBBox_ury - afmCharMetrics.fBBox_lly));
     }
     Debug.Assert(!(Single.IsNaN(afm.fCapHeight)));
     return(fontProp.rSize * 1000.0 / afm.fCapHeight);
 }