PointText

Report VG.net problems here.

Moderators: Frank Hileman, Anne Szyjan

Post Reply
euanw
Posts: 19
Joined: Thu Oct 07, 2004 9:41 am

PointText

Post by euanw » Mon May 15, 2017 5:40 am

Hi,
I'm trying to draw some text in my picture, I normally use a Rectangle and set the Text property, but this time I don't want a background to the text. What should I use? I also don't want a border, so setting the DrawStyle of the Rectangle to Edge isn't any good. I tried a PointText, but the font is all horrible, couldn't work out why.
I've attached the file showing the result using PointText. When I use a Rectangle with Text it looks nice

var label = new PointText();
label.Location = picture.PointDeviceToElement(new Vector(distanceFromLeftToRuler - tickLineLength - 10, heightInPixels));
label.Text = HTMLtoRTF.ConvertToUnicode(value);
label.TextAppearance = new Prodige.Drawing.Styles.TextAppearance() { SizeUnit = System.Drawing.GraphicsUnit.Millimeter, Size = 3f / picture.Scaling.X };
label.TextAppearance.HorizontalAlignment = System.Drawing.StringAlignment.Far;
label.TextAppearance.VerticalAlignment = System.Drawing.StringAlignment.Center;

What am I doing wrong?

Thanks,

Euan
Attachments
PointText problem.PNG
PointText problem.PNG (4.26 KiB) Viewed 87055 times

User avatar
Frank Hileman
Site Admin
Posts: 1400
Joined: Sun Jul 25, 2004 8:16 pm
Location: California
Contact:

Re: PointText

Post by Frank Hileman » Tue May 16, 2017 9:07 am

Hello Euan,

Usually when there is a problem like this, I try drawing an Element in the designer, where I can control all properties via the property grid. This is much faster than changing code and re-running the program.

In this case, I can think of only these potential problems:
  • The text created via your ConvertToUnicode method.
  • Some unequal scaling or a strange shearing transformation applied to the text. This scaling may be on the Element itself, or it may be at a higher level.
  • The font may be wacky.
  • The Elements are doubled? There is a strange effect as if things are drawn twice.
  • You are drawing into a transparent bitmap and then drawing that bitmap on another surface. There is a known flaw with the ClearText algorithm in GDI+ whereby the algorithm cuts "holes" in transparent bitmaps (sets pixel areas to have no opacity). This is most evident when using the TranslucentForm, but it can occur in other circumstances. In this case, the work around is to reduce the opacity of the TextAppearance color slightly (.99 or so). Such a small change in opacity fixes the bug.
I will try to recreate the text in the designer but I don't think I have enough information to see the problem. If you have a static Picture, that would be useful. Or a simple program.

User avatar
Frank Hileman
Site Admin
Posts: 1400
Joined: Sun Jul 25, 2004 8:16 pm
Location: California
Contact:

Re: PointText

Post by Frank Hileman » Tue May 16, 2017 9:37 am

Hello Euan,

I could not reproduce the problem. I did note you are using Millimeters as a size unit. This is rare. I don't know if there is any bug with this unit, but world coordinates are generally the best unit, as they are independent of DPI.

Regards,

euanw
Posts: 19
Joined: Thu Oct 07, 2004 9:41 am

Re: PointText

Post by euanw » Thu May 18, 2017 4:01 am

Hi Frank,

yes, it seemed to be related to the Millimeters size unit. All ok now

thanks,

Euan

Post Reply