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); } }
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; }
public Font GetScaledFont(float scaleRatio) { return(GdiplusFontLoader.CreateFont(Name, EmHeight * scaleRatio, Style)); }
public Font GetFont() { return(GdiplusFontLoader.CreateFont(Name, EmHeight, Style)); }