I believe your goal as follows.
- You want to set the text with the bold type to the title of items on Google Form using Google Apps Script.
Issue and workaround:
Unfortunately, in the current stage, there are not methods for directly managing the rich texts to the title of each items on Google Form in Google Form service. But when the text with the bold type is directly copied and pasted to the title of item on Google Form, it can be done. So in this answer, using this, as a current workaround, I would like to propose to convert the text data to the text with the bold type with the unicode, and put the converted text to Google Form.
The flow of this workaround is as follows.
- Convert the text to the bold type with the unicode.
- In this conversion, each character in the text is converted to the bold type using the difference between the original character code and the bold character code.
- Put to the converted text to the title of item on Google Form.
When above flow is reflected to the script, it becomes as follows.
Sample script:
function myFunction() {
// 1. Convert the text to the bold type with the unicode.
const conv = {
c: function(text, obj) {return text.replace(new RegExp(`[${obj.reduce((s, {r}) => s += r, "")}]`, "g"), e => {
const t = e.codePointAt(0);
if ((t >= 48 && t <= 57) || (t >= 65 && t <= 90) || (t >= 97 && t <= 122)) {
return obj.reduce((s, {r, d}) => {
if (new RegExp(`[${r}]`).test(e)) s = String.fromCodePoint(e.codePointAt(0) + d);
return s;
}, "")
}
return e;
})},
bold: function(text) {return this.c(text, [{r: "0-9", d: 120734}, {r: "A-Z", d: 120211}, {r: "a-z", d: 120205}])},
italic: function(text) {return this.c(text, [{r: "A-Z", d: 120263}, {r: "a-z", d: 120257}])},
boldItalic: function(text) {return this.c(text, [{r: "A-Z", d: 120315}, {r: "a-z", d: 120309}])},
};
var newTitle = "New title for item 1";
var convertedNewTitle = conv.bold(newTitle); // Bold type
// var convertedNewTitle = conv.italic(newTitle); // Italic type
// var convertedNewTitle = conv.boldItalic(newTitle); // Bold-italic type
// 2. Put to the converted text to the title of item on Google Form.
var formID = "###"; // Please set the Form ID.
var form = FormApp.openById(formID);
var Items = form.getItems();
Items[0].setTitle(convertedNewTitle);
}
- In this sample script, the bold, italic and bold-italic types can be converted.
- In this case, the numbers and the specific characters have no bold, italic and bold-italic types. Please be careful this.
Result:
When above sample script is used, the following result is obtained.
From:

To:

Testing
https://jsfiddle.net/7bL5r3em/
References: