# Different font in same line of text

**URL:** <https://casparcgforum.org/t/different-font-in-same-line-of-text/4329>\
**Category:** General\
**Tags:** flash, template, howto\
**Created:** [July 23, 2021, 3:07pm UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329 "2021-07-23T15:07:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.basso](https://casparcgforum.org/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@andrea.basso](https://casparcgforum.org/u/andrea.basso)\
**Post date:** [July 23, 2021, 3:07pm UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329/1 "2021-07-23T15:07:15Z")

</div>

I may have to create templates that use different types of fonts (example: regular and bold) in the same line of dynamic text (example: first name in regular, last name in bold).

I have to stick with Flash (no time or sufficient experience and knowledge to move to HTML5 at short notice).

The only solution that I can think of, with the knowledge I have, is to split the name in different text objects, one for the first name, one for the last name, etc. Each text object uses the proper font required. I calculate the actual length of the text with AS3 and using this information I move the objects horizontally in order to center them on the graphics (or align them as required).

Any easier solution that you can think of?

---

<div class="post-metadata">

**Author:** ![hreinnbeck](https://casparcgforum.org/user_avatar/casparcgforum.org/hreinnbeck/32/154_2.png) [@hreinnbeck](https://casparcgforum.org/u/hreinnbeck)\
**Post date:** [July 23, 2021, 3:17pm UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329/2 "2021-07-23T15:17:53Z")

</div>

Stopped using flash and moved to html years ago, but didn’t textfield support some basic formatting tags including `<b>`?

---

<div class="post-metadata">

**Author:** ![tsipas](https://casparcgforum.org/user_avatar/casparcgforum.org/tsipas/32/80_2.png) [@tsipas](https://casparcgforum.org/u/tsipas)\
**Post date:** [July 23, 2021, 3:40pm UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329/3 "2021-07-23T15:40:32Z")

</div>

```auto
		public function wordcolor():void
		{
			
			switch(showcolor)
			{
				case "White" :
			    txtTestFormat2.color = 0xFFFFFF ;
                txtTestFormat1.font = boldfont.fontName;
				txtTestFormat1.size = 34;
			    mcstory.story.setTextFormat(txtTestFormat2 , color_start , color_end );
				break ;
				case "Green" :
			    txtTestFormat2.color = 0xFFFFFF ;
                txtTestFormat1.font = boldfont.fontName;
				txtTestFormat1.size = 34;
			    mcstory.story.setTextFormat(txtTestFormat2 , color_start , color_end );
				break ;
				case "Red" :
			    txtTestFormat2.color = 0x000099 ;
                txtTestFormat1.font = boldfont.fontName;
				txtTestFormat1.size = 34;
			    mcstory.story.setTextFormat(txtTestFormat2 , color_start , color_end );
				break ;
			}

		}

```

Something similar I do to colorized part of text I think it should also work with different font the same way color\_start and color\_end is integer that specify in which part of the text to change attributes.  
Of cource you must manipulate each text string, I do it form Visual Basic and send the values(color\_start , color\_end) to AS3 as element

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 23, 2021, 7:59pm UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329/5 "2021-07-23T19:59:07Z")

</div>

> [@andrea.basso](#):
>
> The only solution that I can think of, with the knowledge I have, is to split the name in different text objects, one for the first name, one for the last name, etc.

That is exactly how I do that also.

---

<div class="post-metadata">

**Author:** ![vimlesh1975](https://casparcgforum.org/user_avatar/casparcgforum.org/vimlesh1975/32/1608_2.png) [@vimlesh1975](https://casparcgforum.org/u/vimlesh1975)\
**Post date:** [July 23, 2021, 9:19pm UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329/6 "2021-07-23T21:19:46Z")

</div>

[https://drive.google.com/file/d/1D\_JhndAopzmhqOyZ3UyCkWDAS11kyD-O/view?usp=sharing](https://drive.google.com/file/d/1D_JhndAopzmhqOyZ3UyCkWDAS11kyD-O/view?usp=sharing)

This is a template in which text  
antil-alias property has been set to device font  
named as xf0  
while setting data it should be like `"<p>This is <b>some</b> content to <i>test</i>"`

as3 file contains following code.

```auto
package 
{
	import se.svt.caspar.template.CasparTemplate;
	public class mixweight extends CasparTemplate
	{
		override public function SetData(xmlData:XML):void
		{
			super.SetData(xmlData);
			for each (var element:XML in xmlData.elements())
			{
				
				if (element. @ id == "xf0")
				{
					xf0.htmlText=element.data. @ value;
				}
			}
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![Andrea](https://casparcgforum.org/user_avatar/casparcgforum.org/andrea/32/775_2.png) [@Andrea](https://casparcgforum.org/u/Andrea)\
**Post date:** [July 24, 2021, 7:35am UTC](https://casparcgforum.org/t/different-font-in-same-line-of-text/4329/7 "2021-07-24T07:35:04Z")

</div>

in actionscript you can have a text field in html thus change font, color, style, ecc ecc  
like this

```auto
var html_temp_storage:String;

html_temp_storage = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Sky Text" SIZE="30" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">Sky Text </FONT></P></TEXTFORMAT>';

Clock.xlaps.htmlText = html_temp_storage;

```

never really used because I switched to html, but I tested few times and worked for me
