Custom Page Layout Annotations in Display Conduit

There is fortunately a lot of overlap between C++/C#, so prior insight can be used regardless of the platform, even if sometimes the translation is not obvious.

At least for C#, there are a few 2d drawing commands that don’t necessarily draw in the 3d world space (e.g. Draw2dText Draw2dRectangle Draw2dLine) - these have options to draw in the screen viewport space (using the values returned from Viewport.GetScreenPort).

In this case, it turned out to be a combination of scales (similar to other examples where a combination of transforms is used), to draw text of a specific point size on a page:

UnitSystem pageunitsystem = e.RhinoDoc.PageUnitSystem;
e.Viewport.GetWorldToScreenScale(Point3d.Origin, out double scale); // View must be orthagonal, and 
                                                      //must be the paper space. Detail view may not return the same value since its world space is the model.
double pointToPixel = scale / RhinoMath.UnitScale(pageunitsystem, UnitSystem.PrinterPoints);
int TextSize = 12; // Text Size in Points
e.Display.Draw2dText(text, color, new Point2d(leftcnr, topcnr), false, (int)(TextSize * pointToPixel), fontName);

Quite fortunately, this also scales correctly when printing, rather than outputting screen dpi (96 for an older screen) it uses the anticipated printer dpi. (Additional math not shown here is required to make sure placement of the items remains as anticipated.)