textFamily property of span problem
Hello,
My problem is that I don't understand why the fontFamily property of the SPAN object doesn't accept a method that returns an array, but if the fontFamily property is passed an array directly, everything works. To make a long story short. Here are two cases:
objA = {
text: "Hello, World",
alignment: "left",
fontFamily: ["Helvetica", "sans-serif"]
};
getField("myTextFieldName").richValue = [objA] // WORKS!
objA = {
text: "Hello, World",
alignment: "left",
fontFamily: function(){return ["Helvetica", "sans-serif"]}
};
getField("myTextFieldName").richValue = [objA] // NOT WORKING!I need to randomly generate a font type in a form based on a button press. Therefore I need to pass the fontFamily property the result of the function, unfortunately the console doesn't tell me anything and I can't find why it doesn't work. The text appears, other properties like alignment and textSize.. too, but fontFamily does not.
var objSpan = {
text: "Hello, World",
alignment: "left",
textColor: ["RGB", 0/255, 0/255, 0/255],
textSize: 12,
linespacing: 20,
fontFamily: function(){
var randomFont = [
["Calibri", "sans-serif"], //1
["Helvetica", "sans-serif"], //2
["Myriad Pro", "sans-serif"], //3
["Adobe Caslon Pro", "serif"], //4
["Adobe Garamond Pro", "serif"], //5
["Arno Pro", "serif"], //6
["Arno Pro SmText", "serif"], //7
["Century", "serif"], //8
["Corbel", "sans-serif"], //9
["Georgia", "serif"], //10
["Gill Sans MT", "sans-serif"], //11
["Chaparral Pro", "serif"], //12
["Segoe UI", "sans-serif"], //13
["Times New Roman", "serif"] //14
];
var fo1 = Math.random()*(randomFont.length);//fo1 je náhodné reálné číslo v intervalu <0;14)
var fo2 = Math.floor(fo1);// fo2 is a natural number from the interval <0;13>
return randomFont[fo1]// returns the 0th to 13th element of the array randomFont
},
fontWeight: 400,
fontStyle: "normal",
fontStretch: "normal"
};
getField("myTextFieldName").richValue = [objSpan];Thanks to much!
