Why does changing text in Actionscript only preserve included letters? - string

I am working with Actionscript 3 in Flash, and I have a dynamic text field, instance called "textField" inside an instance of movie clip "mcpoo" and a keyframe with actionscript:
addEventListener(Event.ENTER_FRAME, myfunc);
function myfunc(e:Event):void{
mcpoo.textField.text = "this is a test string";
}
When I set the text field to a default value via text tool, e.g., "asdf" and test the movie, the text will change to include ONLY the chars in the default value, stripping out the rest. "this is a test string" is displayed as "ssass".
Why the good gawddam would it do something like this? As a corollary, how can I work around this or avoid it?

You need to embed more characters in the font you are using. By default, Flash will only embed the characters that you put in the field at author time. It does this to reduce file size.
Select the textfield and hit the Embed button in the Properties panel.
From there you can select the range of characters you want to include (under Character Ranges). You probably want to limit it to only the characters you will need, as it will add to the file size of the SWF.
Alternately, you could use a system font and forget about embedding anything.

Related

How can I change the font sizing within multiple lines of a string in Lua? (WoW Lua Question)

I am currently beginning to write functions for WoW WeakAura addons that use the WoW Lua in order to create the addon. I am trying to change the fonts within the printed string so that I have a Header essentially.
The code is essentially as follows:
return string.format("|cFFFFFFFFHeader Text|r\nRegular Text|r\nMore Regular Text|r\nEven More Regular Text")
The current printing returns all of the text the same size, but I just want to make the "Header Text" a size larger. I've found how to modify the colors, but I have yet to find anything similar for font size. Can someone assist?

Font name of a specific character in a string | Swift

is it possible to get the font name and its size of a specific character in string in Swift?
I want to make a textview in which you can type with different fonts. I did this, but the problem is for example if something, lets say "hello" is written in Helvetica 16pt, and my current font Helvetica 24 pt, and then I want to write something more in "hello", let say "helloworld". This is possible in swift using attributed strings, but the word "hello" will be 16pt, and the word "world", will be 24pt. So, how to detect the font of the "hello" word, and then change the font automatically, and continue typing with the same font?
You should have a look at the NSAttributedString documentation. The font size attribute you mentioned is actually contained within the NSFontAttributeName key, which stores an NSFont which has both font type and size. You can directly access that using fontAttributesInRange: if you know where you want to look in the string.

How to write a multiline text in a static text control in mfc?

I have a simple problem with my static text control. I want to write two sentences in two lines.
I searched everywhere, they answered that its style should not be simple and it should be big enough and then it can be done with \n or \r\n. Another guy wrote that it worked!
I did that, but it's not working! The caption is "Welcome to Genetic Algorithm Simulator Application.\nPlease Choose a Function:"
but it just ignores \n and shows this:
Welcome to Genetic Algorithm Simulator Application.Please Choose a Function:"
Also keep in mind that if the "Center Image" style (SS_CENTERIMAGE) is applied (giving you vertical centering of the text), then "\r\n" character sequences are ignored.
You should not set SS_SIMPLE style for static control. This is what is causing control to display only single line ignoring new line character. Get rid of this style and it will work.
I tried it with MFC in VS2008, in the static text control properties set the property "No Wrap" to False and the text should be automatically wrapped to the size of the control.
center image/no wrap/simple all these three options should set to be false!
Just apply the style SS_EDITCONTROL.

MailMerge: No fixed width font?

I am trying to send data to a specific MergeField. The data are sent correctly. Each line of the data has for specific characters. For example the data to the field may be:
12345 FIRST\nABCDE.F SECOND
(it cannot get the newline so i just so it through character \n)
Now in the printed document each character has its one width, '1' is smaller than 'E' for example. So the data are not alligned within the field. I tried the following fonts: Arial, Tahoma, Courier New. Nothing helped.
Any ideas? Thanks in advance.
Ps the data are sent through an executable built by Visual C++ 5.0!!
You should probably use a tab-stop based layout. Set your tab-stops every, say, centimetre or so (i.e. just big than the widest character in your font) and add a tab before each element that needs to be aligned.
With this you shouldn't need to find a fixed width font and can use something more attractive.
Edit: Out of interest, I wonder why you have no luck with Courier New which is fixed width.
Maybe you could post a screenshot somewhere so we can have a look at your problem in more detail.
Try Courier - it does not have kerning (kerning = variable character width)
Also in the Font window there is a check box that allows you to apply kerning to fonts of a certain size or above - setting this value to a large font size may remove kerning.

Centering fonts in VB6

How do you determine the length of a string of text in Arial Bold font, and then center it in VB6?
We are not using a "label" or "picture box" to print the text to the screen. We are sizing the text on the fly, and allowing the user to scale the size of our application to their liking. We write the text to screen using code.
One way is to have a hidden picture box and setup the font specs of that picture box the way you want.
Then use the TextHeight and TextWidth methods of the PictureBox to take your measurements. The Units will be in whatever scalemode the Picture Box is set to.
If you are printing directly to the printer or form then just set your font FIRST then take your measurements.
To center it
MyText = "Hello World"
<displayarea>.FontName = "Arial"
<displayarea>.FontSize = 14
<displayarea>.FontBold = True
TextWidth = <displayarea>.TextWidth(MyText)
TextLeftCoordinate = <displayarea>.ScaleLeft+<displayarea>.ScaleWidth/2-TextWidth/2
<displayarea>.CurrentX = TextLeftCoordinate
<displayarea>.Print MyText
Substitute displayarea with whatever object you are using.
Based on your updated answer note that the hidden picture box suggestion isn't used to print. It is only get text measurement. However you are printing directly to the form so you just need to use the code example above.
I can't remember the specifics (it's been about 3 years since I last used VB 6), but there's a method on Form called something like "MeasureString". It takes the string, and measures it according to the font settings of the form.
Also, here's a comment posted by Jason Lepack in case I've misunderstood and over-complicated your requirements:
"Labels usually have an alignment property. If you set it to align to center then, regardless of the font face it should center in the label".
There are Win32 GDI functions you can invoke: see for example GetTextExtentPoint32 at http://msdn.microsoft.com/en-us/library/ms534223(VS.85).aspx
Your best option may be Form.TextWidth, which appears to return the width of a string in twips. I've just taken this approach in order to dynamically size a button based on the length of the label that needs to appear inside it.
There is also a corresponding function called Form.TextHeight which would allow you to do the same thing in the vertical dimension.
Make sure that you set the Font property of the form to match the Font property of the control you're intending to measure the text for, otherwise you'll get incorrect results.
Read more at http://msdn.microsoft.com/en-us/library/aa267168(VS.60).aspx

Resources