FPhoenix Posted November 3, 2015 Share Posted November 3, 2015 I can see ClearType GUI font rendering at site screenshots, but it won't work for my Paint.NET. I use Windows 7 x64 and Paint.NET 4.0.6. ClearType is turned on in my system settings, and its works fine for most of software, including my personal .NET programs. Is it possible to activate it for this editor somehow? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted November 3, 2015 Share Posted November 3, 2015 Here is a CodeLab script to do it: // Title: BoltBait's Render Text Sample // Author: BoltBait // Submenu: Render // Name: Text // URL: http://www.BoltBait.com/pdn #region UICode MultiLineTextboxControl Amount1 = ""; // [1,32767] Text FontFamily Amount2 = new FontFamily("Arial"); // Font IntSliderControl Amount3 = 12; // [10,72] Size RadioButtonControl Amount4 = 0; // [1] Smoothing|None|Anti-Alias|ClearType ColorWheelControl Amount5 = ColorBgra.FromBgr(0,0,0); // Color PanSliderControl Amount6 = Pair.Create( 0.0 , 0.0 ); // Location #endregion void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); // Reset the destination canvas dst.CopySurface(src,rect.Location,rect); // Determine where the text will be written int column = (int)Math.Round(((Amount6.First + 1) / 2) * (selection.Right - selection.Left)); int row = (int)Math.Round(((Amount6.Second + 1) / 2) * (selection.Bottom - selection.Top)); // Create a brush and graphics surface to write on SolidBrush Brush1 = new SolidBrush(Amount5.ToColor()); Graphics g = new RenderArgs(dst).Graphics; // specify smoothing mode switch (Amount4) { case 0: // none g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; break; case 1: // anti-alias g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; break; case 2: // cleartype g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; break; } // Be sure to clip to our ROI g.Clip = new Region(rect); // Create a font from user selection Font SelectedFont; try { SelectedFont = new Font(Amount2.Name, Amount3); } catch { // If font creation fails, use Arial font SelectedFont = new Font("Arial", Amount3); } // Write our text to the canvas g.DrawString(Amount1, SelectedFont, Brush1, column, row); } 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Rick Brewster Posted November 3, 2015 Share Posted November 3, 2015 The Text Tool doesn't use ClearType, and you can't enable it to do so. ClearType can only render on top of opaque content, and layers in Paint.NET have an alpha channel. It would be really confusing if the Text Tool didn't work when used on a layer that isn't completely opaque, or if it reverted to non-ClearType without telling you. It is also very useful to have text on its own layer, and requiring text to be on a layer that's opaque kinda defeats the purpose. I've always wanted to have this workable, but the obstacles just don't justify the engineering cost. Also, FWIW, GDI+'s text rendering is pretty bad (referring to BoltBait's code sample). Also, the following code: Graphics g = new RenderArgs(dst).Graphics; is incorrect. You need to hold on to the RenderArgs for the duration of your method, otherwise it will destroy the Graphics. So, this code has a race condition with the garbage collector. I recommend this instead, using (RenderArgs ra = new RenderArgs(dst)) { Graphics g = ra.Graphics; ... } I also recommend wrapping your other disposable resources (e.g. brushes, and any other GDI+ object) with a "using" block. Otherwise it can become a significant performance issue. 4 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
DavidP Posted December 13, 2020 Share Posted December 13, 2020 In the documentation it says that ClearType is available as one of three options for text antialiasing. However I can’t get it to work. Text is always rendered using grayscale antialiasing, not with ClearType. Am I doing something wrong? Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 13, 2020 Share Posted December 13, 2020 5 hours ago, DavidP said: In the documentation it says that ClearType is available as one of three options for text antialiasing. That's not what is says... Quote There are three text rendering modes: Smooth, Sharp (Modern) & Sharp (Classic). These correspond to DirectWrite rendering modes of Outline, ClearType Natural Symmetric, and GDI Classic, respectively. The key word here is correspond Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.