public override void ViewportDraw(AcGi.ViewportDraw vd) { int glyphPixels = CustomObjectSnapMode.GlyphSize; var glyphSize = vd.Viewport.GetNumPixelsInUnitSquare(_pt); // Calculate the size of the glyph in WCS // (use for text height factor) // We'll add 10% to the size, as otherwise // it looks a little too small double glyphHeight = (glyphPixels / glyphSize.Y) * 1.1; string text = "¼"; // Translate the X-axis of the DCS to WCS // (for the text direction) and the snap // point itself (for the text location) var dist = -glyphHeight / 2.0; var offset = new Vector3d(dist, dist, 0); var e2w = vd.Viewport.EyeToWorldTransform; var dir = Vector3d.XAxis.TransformBy(e2w); var pt = (_pt + offset).TransformBy(e2w); // Draw the centered text representing the glyph var style = new AcGi.TextStyle(); var fd = new AcGi.FontDescriptor("txt.shx", false, false, 0, 0); style.Font = fd; style.TextSize = glyphHeight; vd.Geometry.Text( pt, vd.Viewport.ViewDirection, dir, text, false, style ); }
protected override void SubViewportDraw(AcGi.ViewportDraw vd) { int glyphSize = CustomObjectSnapMode.GlyphSize; var glyphPixels = vd.Viewport.GetNumPixelsInUnitSquare(_pt); double glyphHeight = (glyphSize / glyphPixels.Y) * 1.1; string text = "¼"; var dist = -glyphHeight / 2.0; var offset = new Vector3d(dist, dist, 0); var e2w = vd.Viewport.EyeToWorldTransform; var dir = Vector3d.XAxis.TransformBy(e2w); var pt = (_pt + offset).TransformBy(e2w); var style = new AcGi.TextStyle(); var fd = new AcGi.FontDescriptor("txt.shx", false, false, 0, 0); style.Font = fd; style.TextSize = glyphHeight; vd.Geometry.Text(pt, vd.Viewport.ViewDirection, dir, text, false, style); }