iPlug2 Forum

How to draw text without antialiasing?

In the old version of IPlug, where the text was rendered by means of Windows GDI, there were clearly readable inscriptions, however, in the new version of IPlug2, the text rendering was performed with antialiasing, which makes the inscriptions blurry at a small font size.

Using the DrawBitmapedText function does not solve the problem, since it requires the same width for all characters.

Does anyone have any ideas on how to make an inscription in a simple way without antialiasing?

Which graphics backend are you trying to use?

Thanks, but I’ve already figured out this problem. Made changes in the file ISkiaGraphics.cpp,
set font.setEdging(SkFont::Edging::kAlias);

It looks like we should be setting SkFont::Edging::kSubpixelAntiAlias, as the default, which improves skia text appearance a lot on low-DPI screens on windows. Did you achieve what you want without antialiasing? Maybe we will have an option for IText

Yes. I added an extra field mAliasing to the IText structure.
For implementation i made this:

void IGraphicsSkia::DoDrawText(const IText& text, const char* str, const IRECT& bounds, const IBlend* pBlend)
{
  IRECT measured = bounds;
  
  SkFont font;
  double x, y;
  
  PrepareAndMeasureText(text, str, measured, x, y, font);
  // added this
  if (text.mAliasing)
    font.setEdging(SkFont::Edging::kAlias);
  PathTransformSave();
  DoTextRotation(text, bounds, measured);
  SkPaint paint;
  paint.setColor(SkiaColor(text.mFGColor, pBlend));
  mCanvas->drawSimpleText(str, strlen(str), SkTextEncoding::kUTF8, x, y, font, paint);
  PathTransformRestore();
}