Copy link to clipboard
Copied
I'm using the below code. I'm trying to replace a few fonts that are in Paragraph and Character styles.
function cb7CallBack(target) {
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
; var BOLD = doc.characterStyles;
for (var a = 0; a < BOLD.length; a++) {
if (BOLD.appliedFont=="Helvetica Neue LT Pro" && BOLD.fontStyle =="77 Bold Condensed") {
BOLD.appliedFont = "Suisse Int'l Condensed"
}
}
}
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
; var REG = doc.characterStyles;
for (var a = 0; a < REG.length; a++) {
if (REG.appliedFont=="Helvetica Neue LT Pro" && REG.fontStyle =="57 Condensed") {
REG.appliedFont = "Suisse Int'l Condensed"
}
}
}
Copy link to clipboard
Copied
Font styles such as bold italic reguler, etc are classified as part of the font name: so to set a font you would use "Arial\tBold" to get the Bold style of Arial. and for the size of the text you would use pointSize rather than fontStyle.. so to make a selection have a size of 32 you would use: app.activeDocument.selection[0].pointSize = "32pt"
Copy link to clipboard
Copied
I should clarify. The First part of the code works. "BOLD" I cannot get the second part to work.
Copy link to clipboard
Copied
Hope it works, also no need use document length twice..try this
function cb7CallBack() {
var docs = app.documents;
for (var d = docs.length-1; d >= 0; d--) {
var doc=docs
; var BOLD = doc.characterStyles;
for (var a = BOLD.length-1; a >= 0; a--) {
if (BOLD.appliedFont=="Helvetica Neue LT Pro" && BOLD.fontStyle =="77 Bold Condensed") {
BOLD.appliedFont = "Suisse Int'l Condensed"
}
if (BOLD.appliedFont=="Helvetica Neue LT Pro" && BOLD.fontStyle =="57 Condensed") {
BOLD.appliedFont = "Suisse Int'l Condensed"
}
}
}
}
cb7CallBack()
Copy link to clipboard
Copied
UnFortunately No. It will only changes the 77 Bold COND. and leaves 57 Cond alone. I'm guessing because the 57 is in a paragraphStyle. I've changed characterStyles to paragraphStyle just to see if it would work and it still doesnt.
Copy link to clipboard
Copied
The provided coding only for character style
Copy link to clipboard
Copied
Are you sure that Suisse Int'l Condensed has a Regular font? Somehow Condensed and Regular seem to contradict each other.
Copy link to clipboard
Copied
Yes. There is a Suisse int'l Reg and Suisse int'l Condensed Regular.