How to re-size a text area depending of the text size? - text

I wanna know an ideal way to re-size a text area depending of the text size like various programs do.
In my case we will asume the width, font and font size are constant, and I'm not using line breaks, so it would be something like doing this:
I know I should consider the words, their length, every " " character, and how many are per line, I wanna know a not messy way to achieve this

Related

Wrap Text in openPD

Is there a way to wrap text around an image in openPDF? or around other text? I'm trying to mesh two texts onto one page (texts which may contain pictures), but one text may be larger or smaller then the other. They could look like one of these two pictures:
I was going to make a column text, and test the length of text 2 against the length of the text of text 1 that remains after the first few lines (see the picture), but I couldn't return the remaining text with columnText.go(true).
Is there an easy way to wrap text around a picture or other variable object (aka text)?

How to set individual font color using extendscript

I have created a paragraph text in after effects using Extendscript
For example i have a text "HI". I need to give color for "H" as red [1,0,0] and "I" as green [0,1,0].
I have checked everywhere ,. where i can find out that i can change the text color in whole rather than individually ! is there anything that can be done?
I need to change color of each and individual characters using script
It looks like it's not possible. The text in a text layer is a TextDocument object, and when you look at the AE scripting guide it says
TextDocument fillColor attribute
textDocument.fillColor
Description
The text layer’s fill color, as an array of [r, g, b] floating-point values. For example, in an 8-bpc project, a red
value of 255 would be 1.0, and in a 32-bpc project, an overbright blue value can be something like 3.2.
NOTE: If the text layer has different fill color settings for each character, this attribute returns the setting for the first character. Also, if you change the value, it resets all characters in the text layer to the specified setting.
Type
Array [r, g, b] of floating-point values; read/write.
The important bit is the Note. The same thing applies for all the text attributes like fontSize, fill, stroke &c., &c..
So for some reason you can't access the style attributes for anything but the first character in a line of text. Are you annoyed? I am. Perhaps log a bug with Adobe—it will be completely futile, but you might feel better.

Create Overstrike Effect In A Cell

I have been asked if there is any way to get Excel to produce an overstrike effect in a cell. My first attempt was the use the BACKSPACE character:
="A" & CHAR(8) & "B"
But the display does not seem to honor the BACKSPACE:
Is this a font problem? Is there a unicode approach ?
I hate to tell the client to search for a custom font.
EDIT#1:
For example. This code:
Sub XBar()
ActiveCell.Font.Name = "Arial MS Unicode"
ActiveCell.Value = "X" & ChrW(773)
End Sub
Visually produces:
but this is not a general solution.
You can extend the character set by putting one character on top of another BUT you can only do this with a limited set of symbols. These are known at the "Combining Diacritical Marks" and usually live towards the end of the font set.
For a spreadsheet document, I wanted to put in 9 recurring (ie 9 with a dot above it). This does not exist as one character but can be made by combining two.
First of all put in the 9, then from the Combining Diacritical Marks, choose the . and one will go above the other. I actually had to do this in Word and then copy and paste the new characters back to Excel to make them work.
Once in Excel, I used a look up to convert the digit 9 into the dotted digit 9 wherever I needed it.
Different fonts have different ranges of these characters. Arial Unicode MS has some unusual ones. You need to look at the fonts and choose the most appropriate for your needs.
However, on the whole, I don't think you can put a B on top of an A!
Are you trying to do this?
If so, then select the character(s) you'd like to strikethrough, click the arrow icon in the font section (circled below) and tick the box next to strikethrough.
See here for more information.

svg concatenate text of different styles

I am using d3 to create an axis label inside an svg element. Part of the label is constant (string literal) and part of it varies as the user clicks around. To emphasize that it changes, I want it to be bold, while the rest of the text is normal weight. Aligning these two text elements, to each other and the rest of the drawing, has turned out to be quite difficult.
Also, it seems trailing spaces in text elements are ignored, making it harder to do the concatenation. And if there's a way to change styles within a text element, that would work too.
Here is a very hacky way of doing it, in that it won't work with three pieces of text (because text-anchor), and the result is hard to center (do I really need to go use getBBox()?).
function renderLabel(dynamicText){
svg.select(".label").remove();
var label = svg.append("g")
.attr("class", "label")
label.append("text")
.attr("text-anchor", "end")
.text("The Axis is Based On ");
label.append("text")
.attr("text-anchor", "start")
.style("font-weight", "bold")
.attr("transform", "translate(6,0)") //space
.text(dynamicText);
}
In general, I would like to be able to append/concatenate any number of string variables, each with distinct styles, in a way that "looks good" as a sentence, and can be centered. Please tell me there's a better way to do it.
Instead of using separate text elements, use one text element with two tspan elements nested inside. If you do not set separate positioning attributes on the tspan, they will naturally line up as one row of text.
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/tspan

How to tell if ultragrid text has been truncated

We are using infragistics ultragrid to present data to the user. if the user modifies the width of a column, I need to be able to tell if the data is truncated so that I can adjust the output properly when exporting the data into pdf. We want to truncate the data when exporting to other formats to match what the user sees after the column width adjustment.
Thanks,
Currie
Whether the text is cut off or not is done automatically when drawing the string so you would need to get the available space and the string and then determine how much of it fits into the space when drawn.
Within the CellExporting event of the UltraDocumentExporter, you can get the text and the size with the following:
Size size = e.GridRow.GetCellSizeResolved(e.GridColumn);
string text = e.GridRow.GetCellText(e.GridColumn);
You can also change the value that is being exported by setting e.ExportValue to the string that you want to put in the PDF document.
What remains to be done is to determine the amount of characters that fit into the rectangle and the following should help you with that:
How to determine maximum number of characters given a fixed width font and a maximum width in pixels

Resources