Esempio n. 1
0
        void IView.UpdateFontDependentData(string fontName, LogFontSize fontSize)
        {
            if (drawContext.Font != null)
            {
                drawContext.Font.Dispose();
            }

            var oldDpp = drawContext.LineHeight > 0 ? ((IView)this).DisplayLinesPerPage : 0;

            drawContext.Font = new LJD.Font(GetFontFamily(fontName).Name, ToFontEmSize(fontSize));

            using (var nativeGraphics = CreateGraphics())
                using (var tmp = new LJD.Graphics(nativeGraphics))
                {
                    int count = 8 * 1024;
                    drawContext.CharSize = tmp.MeasureString(new string('0', count), drawContext.Font);
                    drawContext.CharWidthDblPrecision = (double)drawContext.CharSize.Width / (double)count;
                    drawContext.CharSize.Width       /= (float)count;
                    drawContext.LineHeight            = (int)Math.Floor(drawContext.CharSize.Height);
                }

            UpdateTimeAreaSize();

            if (oldDpp != 0 && oldDpp != ((IView)this).DisplayLinesPerPage && viewEvents != null)
            {
                viewEvents.OnDisplayLinesPerPageChanged();
            }
        }
        private static int ToFontEmSize(LogFontSize fontSize)         // todo: review sizes
        {
            switch (fontSize)
            {
            case LogFontSize.SuperSmall: return(6);

            case LogFontSize.ExtraSmall: return(7);

            case LogFontSize.Small: return(8);

            case LogFontSize.Large1: return(10);

            case LogFontSize.Large2: return(11);

            case LogFontSize.Large3: return(14);

            case LogFontSize.Large4: return(16);

            case LogFontSize.Large5: return(18);

            default: return(14);
            }
        }
Esempio n. 3
0
 public FontData(string name = null, LogFontSize size = LogFontSize.Normal)
 {
     Name = name;
     Size = size;
 }