View Full Version : Font Size Macro
peterich8
03-11-2009, 04:48 PM
I am trying to write a macro that will resize text in a template field. My intention is to use it as a multi-line “size to fit”, if there is only a little text it will make it bigger, if there is a lot the font size will get smaller.
I have been able to get the text to resize using the following code after manually changing the size on the font tab:
ActiveCanvas.Scene.Template(“0”)
ActiveCanvas.Selection.Execute (“Apply Color/Font”)
But then when I update the template field (Alt+T and enter) to redo the line breaks the template goes back to its old size. Also I can’t seem to be able to assign the font size within the macro so I can use a variable.
Any help would be greatly appreciated. Thanks
CherylHardy
03-11-2009, 06:12 PM
What's happening is that you need to "set" a font inside a template (in Template Properties) for it to "stick", otherwise it reverts to whatever properties you set when you made the original template. How about this- have you considered saving to your browser a selection of font sizes in the same font so that you can change between them? Assign hotkeys to the fonts in your browser by right clicking on them, choosing edit, then assigning a hotkey to them from the drop down menu. You will use that hotkey in this macro (replace the parts in {} with your font shortcut):
Lyric.FontKey "{FONT SHORTCUT HERE, LIKE ALT + 1}"
set t = ActiveCanvas.Scene.SelectedTemplate(-1)
t.Text.Font = ActiveCanvas.GetFont
You can then run the macros to set the templates with the saved font sizes.
Hope that helps.
CherylHardy
03-11-2009, 11:15 PM
Here's another option. If you record setting the template properties into a macro, you get this:
With ActiveCanvas.Scene.SelectedTemplate(-1).LyricProperties
.Justification 0
.TemplateID 0
.SizeToFit 0
.AllCaps 0
.AutoErase 0
.Priority 1
.EndUpdate
End With
These properties would change depending on your template properties- so if a box is ticked it's 1, if not it's 0, and the template id is obviously the number of the template. The justification numbers are 0 for none, 1 for center, 2 for left, 3 for page center, and 4 for right.
If you're always updating the same template (so the template number won't change), perhaps this macro will help you do what you were trying to do originally. All you would have to do is change the font size from the dropdown on the toolbar and then run that macro (with the correct template properties settings of course.)
peterich8
03-12-2009, 12:05 PM
I like the look of the hot key idea. I will give that a try. Thanks.
Is there a way to do it without a hotkey to call a browser font so the macro does it all? I would like to dummy proof it so someone can't accidentally erase the fonts.
CherylHardy
03-12-2009, 09:09 PM
The hotkey that you assign to the browser font doesn't have to actually be pressed, it's just a way to identify the font for the macro to work. So really, that macro DOES do it all.
CherylHardy
03-17-2009, 08:59 PM
Check it out! This macro should do what you want. Put it on a hotkey, and it will set in the selected template whatever font or font color you have selected in the dropdown toolbar at the top of the screen:
ActiveCanvas.Selection.Execute ("Apply Color/Font")
That's it! Enjoy.