예제 #1
0
        /// <summary>
        /// Computes how the font should be moved from baseline left to obey a specified alignment
        /// </summary>
        private void GetTextAlignDXDY(GFNFont fnt, string txt, double size, TextAlign align, out double dx, out double dy)
        {
            dx = 0.0;
            dy = 0.0;

            double w, h;

            //y align:
            if ((align & TextAlignAtom.TEXT_BOTTOM) != 0)
            {
                dy = fnt.GetDescent(size);
            }
            else if ((align & TextAlignAtom.TEXT_CENTER_Y) != 0)
            {
                dy = -size * 0.5;
            }
            else if ((align & TextAlignAtom.TEXT_TOP) != 0)
            {
                dy = -fnt.GetAscent(size);
            }
            //else align is baseline, dy=0.0

            //x align:
            if ((align & TextAlignAtom.TEXT_RIGHT) != 0)
            {
                InternalGetTextSize(fnt, txt, size, out w, out h);
                dx = -w;
            }
            else if ((align & TextAlignAtom.TEXT_CENTER_X) != 0)
            {
                InternalGetTextSize(fnt, txt, size, out w, out h);
                dx = -w * 0.5;
            }
            //else align is left, dx=0.0 and we're done
        }
예제 #2
0
        public virtual void GetFontDim(double size, out double linespace_pixels, out double ascent_pixels, out double descent_pixels, out bool filled)
        {
            GFNFont fnt = FindFont(Font);

            linespace_pixels = fnt.GetLineSpacing(size);
            ascent_pixels    = fnt.GetAscent(size);
            descent_pixels   = fnt.GetDescent(size);
            filled           = fnt.Filled;
        }