AI is not giving actual text height - svg

I want to calculate actual height of the text, but the AI is giving the text height using the bounding box dimensions.
Please help me to calculate actual height of text!!
Thanks

This is not possible with SVG. You might have to use a (hidden) <canvas> element, draw the text there and check what pixels were colored. Have e.g. a look at the simple contextBoundingBox() function by Phrogz.

Related

I am trying to put some border to my cross text in excel

I am trying to give some border to my cross text which around 45 degree in excel but issue is that whenever i apply border to cross text the border also get apply at 45 degree.
I am looking for a straight rectangle border which contains cross text in it in excel.
Please help me to do that
I dont think you can find a way around that, but you could improvise;
try removing all the borders on that particular cell then sort of draw a rectangle (Or similar shape) and set its fill to nothing so it can give this impression of a "straight border" and this will look good, if you format it well that is, on printed paper.
Or you can draw a textbox on top of the cell (with the same size) and remove any color fill
If there's an option of locking its position, it would be useful too

Text in Ellipses JavaFX

I created a custom venn chart for two sets an their intersection in JavaFX.
Now I want to show the number of elements in this sets like in the following picture:
The sets are ellipses and I used masks to give the intersection a different color.
Now I want to show the number with size and position related to the available space so that the numbers are always inside the according area.
The width for the text element is easy to calculate, but I don't know how to get available height for the text elements.
Maybe it could be helpful to have the pixels of the ellipses as path, but I have no idea to how I can get this.
Does anyone know how to implement that?
Edit:
I developed an algorithm to find the size of a rectangle, which fits in the required areas of the ellipses. The text are scaled to the size of the rectangle and it works, but now I have another problem.
I need to center the scaled text in the rectangle an I used a StackPane for that. But I can't position the StackPane in the chart parent. If I set the layoutX and layoutY the bounds in parent are different.
For example: stackPane with text = sp;
sp.setLayoutY(122.1662320906945);
The Result for getBoundsInParent().getMinY() is 97.16622924804688;
How can I set the StackPane position, if I use it in a chart class as chart children?

itext multiline text on diagonal

How i can add a multi-line text with itext on diagonal. meaning that if the text is to large for the first diagonal(the largest diagonal) it should move on the next or above diagonal and so one, to see all the text.
I already calculated the text angle for the diagonal and uses pdfcontentbyte to stamp but if my text is longer than the diagonal the rest of the words that don't fit on the diagonal it is not showed. I think i have to make something mathematical or i saw something with setsimplecolumn and chunks but this will show my text aligned horizontal.
If anyone has some ideas? Thanks, and of course need some code examples.
Don't shoot me if I'm wrong, but based on your description I think you're talking about 'irregular columns'. See http://itextpdf.com/examples/iia.php?id=67
This type of column isn't a rectangle. Basically, you define coordinates for the left border (can be a diagonal line) and coordinates for the right border. Then you pour text between these two lines.
If that's not what you meant, maybe you want to write text diagonally. In that case, you can still use ColumnText, but you need to change the coordinate system, so that the text isn't written in horizontal lines from left to right, but in diagonal lines from top to bottom (or bottom to top). Changing the coordinate system is done with the concatCTM method.

SVG - resize tspan to fill all available space

I have tspan element with some text in it. I specified some font-size for it as well. In addition I have parent's box size, i.e. width and height. So now I'd like my text to fit the box with the specified width and height.
One of the options I have is manually calculate string width and height (but it became more complicated in case of different fonts and browsers).
So is there any other way in SVG to resize tspan to necessary sizes? Please note that I want text font size to be changed properly, i.e. so text will be displayed in max font size and any single char from it will be visible.
Well, I've came up with the following solution - have absolutely positioned div element outside of visible area. Apply all fonts and other-related styles (except font size) from tspan to that div, put text into the div. Next try different sizes (you can use binary search for better performance) and measure div size. Once max font size found - apply it along with the text to tspan.

Finding a point clicked in a grid

Given this grid ( http://i.stack.imgur.com/Nz39I.jpg is a trapezium/trapezoid, not a square), how do you find the point clicked by the user? I.e. When the user clicks a point in the grid, it should return the coordinates like A1 or D5.
I am trying to write pseudo code for this and I am stuck. Can anyone help me? Thanks!
EDIT: I am still stuck... Does anyone know of any way to find the height of the grid?
If it is a true perspective projection, you can run the click-point through the inverse projection to find it's X,Z coordinates in the 3D world. That grid has regular spacing and you can use simple math to get the A1,D5,etc.
If it's just something you drew, then you'll have to compare the Y coordinates to the positions of the horizontal lines to figure out which row. Then you'll need to check its position (left/right) relative to the angled lines to get the column - for that, you'll need either coordinates of the end-points, or equations for the lines.
Yet another option is to store an identical image where each "square" is flood-filled with a different color. You then check the color of the pixel where the user clicked but in this alternate image. This method assumes that it's a fixed image and is the least flexible.
If you have the coordinates of end points of the grid lines then
Try using the inside-outside test for each grid line and find the position
Since this grid is just a 3D view of a 2D grid plane, there is a projective transform that transforms the coordinates on the grid into coordinates on the 2D plane. To find this transform, it is sufficient to mark 4 different points on the plane (say, the edges), assign them coordinates on the 2D plane and solve the resulting linear equation system.

Resources