vb.net DrawString X-Position - vb.net

I have problems with positioning within the DrawString method. However, only on the X axis.
No matter what value I recommend for the distance from above - it fits. Therefore, I assume that I have made everything right.
For example, An X in Arial with font size 10, the letter is slightly more than 0.5 mm too far right. If I try it with font size 600, it is more than 35 mm too far right. I suspect that something has to be adjusted depending on the font size and it has nothing to do with the dimensions of the Graphics object.
Does anyone have ideas / experiences / a formula?
If code examples are needed, I can supply them.

Related

VBA Userform: Text of same font size changes size based on Top property

I have a userform. In multiple cases across several different controls, I have observed the objects with the same Width, Height, Font, and Font Size display different font sizes depending on where they are placed on my userform.
. . . .
Above is an example of this. The two textbox's are both 26H and 48W, with a Left of 90. Both have font Tahoma Regular size 18. The only difference between them is their Top property. And yet visually, the upper one has much wider text than the lower one. The picture on the right has added dots to prove this is not an optical illusion. The upper one can only fit one dot between the letter and the edge. The lower one can fit at least two dots between the letter and the edge.
Can anyone explain why this is happening? What is happening? Or how I could stop it from happening?
Why its happening?
A normal windows graphical application renders in 96dpi/ppi.
However, excel’s rendering system is in 72dpi/ppi,so, when you specify 26 as the height, excel will first convert 72 to 96 dpi.
26 x 96 / 72 = 34.6667
Which means your control height is 34.667 pixels.
This will create artefacts in the rendering of your control.
How can you stop it?
Make sure that the final position of your control and its height has a final pixel position in the form to be a whole number.
You can do this by multiplying by your screen dpi and divide by excel dpi(72)
In your case you can apply a height of 25.5 which will render it correctly.
I hope I solved your answer!!
As Krishna Soni says in this thread, you should use a height of 25.5 for all the reasons he present.
This is equivalent to using controls with a height that is a multiple of 3. Since the rounding of 25.5 is 30, we can take 3 as a multiple of the Top, Height, and Width properties and avoid the text resizing issues.
Seen on Weird change of font size when changing Top proprierty by 1

Set the height and width of a mpld3 plot

I want to set the width and height of a mpld3 plot to a specific value (in pixels, so it fits the div it is in). The way I tried it looks like this (javascript):
commands["width"]=plotWidth;
commands["height"]=plotHeight;
mpld3.draw_figure("plotname",commands);
plotWidth and plotHeight the values I want the height and width to be set to.
Now, this actually sets the size of the mpld3-figure object to the values I want, but the plot inside still keeps its old size, so it looks like nothing happened.
So, how do I change the size of the plot itself? So far it looks like whatever I do, the plot does not change.
You can change the shape of an mpld3 plot when creating a figure with the python code plt.figure(figsize=(width,height)) (where width and height are in inches). Here is a notebook demonstrating this.
There has been some interest in making mpld3 figures "responsive", which would be a cooler and more precise way to accomplish your goal, but so far no one has tried making the necessary code changes. Patches welcome!

Is there any way to convert/compare JasperReports's report 'band height' to/with inches?

I am making labels using iReport and need to make sure they fit with the labels the client uses. I am using label format Avery 5163 which has a height of 2 inches. The labels I'm making need to match up with the labels they will be using to print.
I can only find a 'band height' property in iReport which is definitely not in inches. I could fiddle with the band height until they lined up with the Avery 5163 label heights, but I don't like wasting paper and I have more of these labels with different sizes I'd love to know a way to handle this. Has anyone experienced this or know of any solutions?
As I recall, the dimensions of Jasper Reports labels are defined in "dots", with 72 dots per inch.
So your 2 inch label would require a height of 144 units.

VBA gives wrong plotarea width?

I want to get the PlotArea width and height in order to calculate the proportion.
I used ActiveChart.PlotArea.Width to get the width, and then tested the width using Photoshop.
I discovered that the width returned by ActiveChart.PlotArea.Width is wrong.
Image shows what I am talking about:
I have no Idea why...
Please help me to understand why it happens and how to fix it...
Thanks!
PlotArea.Width is returning the width in points not pixels.
http://msdn.microsoft.com/en-us/library/ff198324.aspx
Points are a unit of length. Pixels are variable on a number of factors like monitor, fonts, truefont settings, ect. Here is a SO post about converting pixels to points: Convert Pixels to Points

How To remove ugly font smoothing on ipad apps

I'm working on an iPad app with xcode 4.0.2 and im having trouble getting my fonts to look sharp and clear when i set the font size below 15px. It appears that there is some level of font smoothing being applied to the font and it doesn't look good at all. I've tried several different fonts and i get the same effect. Is there a way i can turn this off?
Make sure you are actually drawing on non fractioned coordinates. If for example you start drawing on X = 0.5 and Y = 0.0, your text will look lousy. Same goes for vertical coordinates. In case your coordinates are resulting from a calculation, simply add a cast towards an integer like this:
CGPoint startDrawingAt = CGPointMake((int)x, (int)y);
Or use proper rounding:
CGPoint startDrawingAt = CGPointMake(roundf(x), roundf(y));