I need a way to reduce character spacing by 50% or just bi a number of points. I checked online and found that it might be doable with the NSAttributedString by seting its kerning to a negative number. Can anyone tell me how or give me a different way to do this?
Related
I have a set of pages that look like this:
I have the content in grids with * Heights and Widths so the grid correctly scales when the entire window resizes. I would like the text to resize with the grid. Basically I would like the user to resize from this:
To this:
(preserving white space)
One way to do this would be to wrap the TextBlock in a ViewBox with margins on the right and bottom (for Grid.Row="3") to account for white space. But because I have several pages with different lengths and line counts I would have to set the margin specifically for each page otherwise the text sizes would differ on each page. Is there a better way to do this??
I don't think there is a better way to do this. There are different ways. But, I think it isn't just a matter of opinion that they would not be better.
Ways I can think of.
Render your text offscreen, rendertargetbitmap that so you've got a picture. Change your textblocks on screen to images and stretch them.
Or
Work out the size your text wants to be. Then do some calculation comes up with a different fontsize which is "better". This is a lot easier to write a description of than do.
In my opinion.
A viewbox is easier to implement. Way less error prone than calculations. Will give at least as good results as rendering to a picture.
I just want to add one more solution to the ones suggested by Andy, which is more of a scientific approach and takes a bit of practice to master.
Suppose you have to find a function F, which maps one or more variables to a desired single value. In your case that would be a function F, which takes aspect ratio of the window as input and outputs an appropriate font size.
How can you find such a function?
Well... you don't need to do any math yourself!
First, you need some data to begin with:
1. Resize the window randomly
2. Calculate aspect ration (X)
3. Pick an appropriate font size that looks good enough (Y)
4. Repeat the measurement 7 to 10 times (sorry data scientists)
5. Enter the data in Excel - one column for X and another one for Y
6. Insert a scatter chart
7. Choose the best trendline for your data, but avoid the polynomial one
8. Display the trendline equation and use the expression in your code
Now I should mention the pros and cons of this regression technique.
Pros:
1. It can solve a wide range of tricky problems:
"I use this 3rd party control, but when the text is too long it overlaps the title bar. How to trim it so it doesn't go beyond the top border?. Deadline is coming!"
2. Even if it doesn't solve the problem perfectly, the results are often acceptable
3. It takes minutes to try out unlike spending a day refreshing your math skills
Cons:
1. The biggest problem is that to keep it simple, you often lower the number of
variables by assuming some of them to be constant. In this post I've assumed that
the font family won't change for example, neither the font weight.
2. If any of the assumptions does not hold the final result could be even worse
This technique is fragile, but powerful. Use it as your last weapon and never leave magic expression like
fontSize = (int)(0.76 + 1.2 * aspectRation) without documenting how it came to be.
OK so I don't even know how to research my problem because I don't know any terms to describe it. So here it is:
I am using an IMU to measure the lying angle and bed inclination for bedbound patients. Is there a way for me to show these results graphically? I mean, is it possible to have a dummy on the screen in a way that I can control his lying angle using C?
I would greatly appreciate it if you let me know if you have any knowledge about possible ways to do it.
I'm trying to create a sparkbar (very similar to a sparkline) that can have a range of data, and needs to be displayed next to other sparkbars with the same type of data for the same time frame. The majority of the values are within +/- 10 units. However, sometimes outliers are much greater. This means that if we keep each plot consistent by scaling to the max values, most of the charts are flat with just the odd ones being clear.
Our solution is to display the majority scaled to +/- 10 and the rest have their axis expanded to the full range of values, with some indicator that they are "special". For example:
Normal vs Special
However, you can see that the special one isn't that clear.
Does anyone have any suggestion on how to indicate better? One suggestion is to add a grep bar behind at +/- 10 similar to this:
Any thoughts?
I am using WPF, and need to print some short strings on an engraving printer... The problem is that they need to be printed in "high" and all the blank space must be dug away, so I need to fill all the blank space with concentric shapes depending on the string being sent, something like this image:
I really don't know where to begin, could someone please point me in the right direction? Is there an easy way to accomplish this?
Thanks in advance.
I don't know of a WPF specific way to accomplish it easily. I mean, short of pre-determining shapes for each character to draw and manually coding it...
However, can you use a custom font? If you can, why don't you make your own font with those shapes baked in, and reduce the character spacing to 0, no margins?
I'm using GeoDjango with PostGIS and trying to use a polygon to get records from a database which fall inside it.
If I define a polygon which is bigger than half the area of the earth it assumes the 'inside' of my polygon is the smaller area which I intended as the 'outside' and returns only results which are outside it.
I can just use this smaller, wrong area to exclude results. Polygon.area seems to know what I intend so I can use this to determine when to make my search inclusive or exclusive. I feel like this problem is probably common, is there a better way to solve it?
Update: If 180 degrees longitude is inside my polygon this doesn't work at all. It seems GEOS is to blame this time. This image shows what I believe is the reason. Green is the polygon I define, Red is how it seems to be interpreting it. Again this seems like a problem which would crop up often and one that libraries like GEOS are made to deal with. Is there a way?
Alright, no answers. Here's what I've done.
Because GEOS doesn't like things crossing the 180th meridian:
First check if the polygon crosses the 180th meridian - If so, break it into 2 polygons along that line.
Because PostGIS assumes a polygon is as small as possible you can't make one cover more than half the world, so:
Check if the polygon or each of the split polygons covers half the world or more - If so, break them in half.
Construct a MultiPolygon from the results.