nessalc / MSWordToolbox

0 stars 0 forks source link

Dynamically generate character images with `Normal` font #1

Open nessalc opened 4 years ago

nessalc commented 4 years ago
  1. Use Settings.Default.SpecialCharacters for images to generate
  2. Key will either be label or character, Value will be the other.
  3. Some helpful code snippets:
    • System.Drawing.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
    • System.Drawing.Graphics.MeasureString(font.Name, font.Size, Drawing.PointF(0, 0), Drawing.StringFormat.GenericTypographic);
    • Drawing.Brush brush = new Drawing.SolidBrush(Drawing.ColorTranslator.FromOle((int)Globals.ThisAddIn.Application.ActiveDocument.Styles[WdBuiltinStyle.wdStyleNormal].Font.Color));
    • Drawing.Font font = new Drawing.Font(Globals.ThisAddIn.Application.ActiveDocument.Styles[WdBuiltinStyle.wdStyleNormal].Font.Name, Settings.Default.FontSize);
    • Drawing.Bitmap bitmap = new Drawing.Bitmap(Settings.Default.IconSize, Settings.Default.IconSize);
    • Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem()
  4. Cache images for future use.