Example #1
0
        // Initialize fonts to use fonts installed in the fonts subdirectory for the Roboto
        // fonts. Done on startup.
        public static void InitializeFonts()
        {
            Uri    uri            = new Uri(typeof(FontDesc).Assembly.CodeBase);
            string executablePath = Path.GetDirectoryName(uri.LocalPath);
            string fontPath       = Path.Combine(executablePath, "fonts");

#if true
            GdiplusFontLoader.AddFontFile("Roboto", FontStyle.Regular, Path.Combine(fontPath, "Roboto-Regular.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto", FontStyle.Bold, Path.Combine(fontPath, "Roboto-Bold.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto", FontStyle.Italic, Path.Combine(fontPath, "Roboto-Italic.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto", FontStyle.Bold | FontStyle.Italic, Path.Combine(fontPath, "Roboto-BoldItalic.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto Condensed", FontStyle.Regular, Path.Combine(fontPath, "RobotoCondensed-Regular.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto Condensed", FontStyle.Bold, Path.Combine(fontPath, "RobotoCondensed-Bold.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto Condensed", FontStyle.Italic, Path.Combine(fontPath, "RobotoCondensed-Italic.ttf"));
            GdiplusFontLoader.AddFontFile("Roboto Condensed", FontStyle.Bold | FontStyle.Italic, Path.Combine(fontPath, "RobotoCondensed-BoldItalic.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-Black.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-BlackItalic.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-Medium.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-MediumItalic.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-Thin.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-ThinItalic.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-Light.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "Roboto-LightItalic.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "RobotoCondensed-Light.ttf"));
            // GdiplusFontLoader.AddFontFile(Path.Combine(fontPath, "RobotoCondensed-LightItalic.ttf"));
#endif
        }
Example #2
0
        private void pictureBoxPreview_Paint(object sender, PaintEventArgs e)
        {
            string expandedText = textExpander(this.UserText);
            float  emHeight     = pictureBoxPreview.Height * 0.7F;
            Color  textColor    = SwopColorConverter.CmykToRgbColor(colorChooser.CmykColor);

            if (!checkBoxAutoFontSize.Checked)
            {
                emHeight = GetEmHeight(e.Graphics, this.FontName, this.FontStyle, (float)upDownFontSize.Value);
            }

            StringFormat stringFormat = new StringFormat(StringFormat.GenericDefault);

            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.FormatFlags  |= StringFormatFlags.NoWrap;
            using (Font font = GdiplusFontLoader.CreateFont(this.FontName, emHeight, this.FontStyle))
                using (Brush brush = new SolidBrush(textColor)) {
                    e.Graphics.DrawString(expandedText, font, brush, pictureBoxPreview.ClientRectangle, stringFormat);
                }
        }
Example #3
0
        public override void LeftButtonClick(Pane pane, PointF location, float pixelSize, ref bool displayUpdateNeeded)
        {
            if (pane != Pane.Map)
            {
                return;
            }

            // If text is empty, use a non-empty text
            string measureText = string.IsNullOrEmpty(displayText) ? "000000" : displayText;

            // User just clicked. Create text of a default size.
            SizeF    size;
            Graphics g = Util.GetHiresGraphics();

            using (Font f = GdiplusFontLoader.CreateFont(NormalCourseAppearance.fontNameTextSpecial, NormalCourseAppearance.emHeightDefaultTextSpecial, NormalCourseAppearance.fontStyleTextSpecial))
                size = g.MeasureString(measureText, f, new PointF(0, 0), StringFormat.GenericTypographic);

            RectangleF boundingRect = new RectangleF(new PointF(location.X, location.Y - size.Height), size);

            boundingRect = currentObj.AdjustBoundingRect(boundingRect);
            CreateTextSpecial(boundingRect);
            displayUpdateNeeded = true;
        }
Example #4
0
 private static bool IsInstalled(string fontName)
 {
     return(GdiplusFontLoader.FontFamilyIsInstalled(fontName));
 }
Example #5
0
 public Font GetScaledFont(float scaleRatio)
 {
     return(GdiplusFontLoader.CreateFont(Name, EmHeight * scaleRatio, Style));
 }
Example #6
0
 public Font GetFont()
 {
     return(GdiplusFontLoader.CreateFont(Name, EmHeight, Style));
 }