Copy link to clipboard
Copied
Hello, I have a simple script in which the font of a text layer is changed. Certain fonts, however, I have noticed change only the texts first character. So, for example: Test becomes Test, instead of Test
Any idea why this might happen, and a way around it? Thanks!
doc.activeLayer.textItem.font = "[Text Postscript Name Here]";
Now problem is that capitalization = TextCase.ALLCAPS does not really change the case of letters - it changes only the style of their display (essentially it an effect that draws over the text, like any other function from the characters palette ). TextItem.contents string does not change.
To really change case of letters, you need to change the case in textItem.contents using .toUpperCase
activeDocument.activeLayer.textItem.contents = activeDocument.activeLayer.textItem.contents.toUpperCase()
ac
...
Copy link to clipboard
Copied
Are you sure? try this one. Was the "Test" in the text layer all the same font to begin with?
if (activeDocument.activeLayer.kind==LayerKind.TEXT) { activeDocument.activeLayer.textItem.font = "Tahoma"; }
Even when font are mixed all fonts seem to change I'm on a Windows 10 PC
Copy link to clipboard
Copied
JJMack,
Font is the same for the entire layer. The same script works correctly with "Tahoma" font (and most others) and changes the entire text.
The issue seems to be with a few fonts downloaded online.
Copy link to clipboard
Copied
You should then identify which fonts and where you got them from and which which OS version and Photoshop version you are using..
Supply pertinent information for more timely and effective answers. The more information you supply about your issue, the better equipped other community members will be to answer. Consider including the following in your question:
Copy link to clipboard
Copied
One such font that fails is "GoodMorning" from DaFont.com (https://www.dafont.com/good-morning-2.font)
I am on Windows 10, 64bit and Photoshop CC 21.0.2
Copy link to clipboard
Copied
The problem is with the font - it contains glyphs only for CAPITAL letters.
Convert textItem contents string toUpperCase() before changing font in that case.
Copy link to clipboard
Copied
Whoops, sorry I forgot to mention that I did this as well.
I'm aware the font features only uppercase letters so included the below line of code as well, but still only the first character is changed.
doc.activeLayer.textItem.capitalization = TextCase.ALLCAPS;
doc.activeLayer.textItem.font = "GoodMorning";
Copy link to clipboard
Copied
Now problem is that capitalization = TextCase.ALLCAPS does not really change the case of letters - it changes only the style of their display (essentially it an effect that draws over the text, like any other function from the characters palette ). TextItem.contents string does not change.
To really change case of letters, you need to change the case in textItem.contents using .toUpperCase
activeDocument.activeLayer.textItem.contents = activeDocument.activeLayer.textItem.contents.toUpperCase()
activeDocument.activeLayer.textItem.font = "GoodMorning"
activeDocument.activeLayer.textItem.capitalization = TextCase.ALLCAPS
activeDocument.activeLayer.textItem.font = "GoodMorning"
activeDocument.activeLayer.textItem.capitalization = TextCase.ALLCAPS
activeDocument.activeLayer.textItem.font = "GoodMorning"
alert (activeDocument.activeLayer.textItem.contents)
Copy link to clipboard
Copied
Hello I want to NOT really change the case, just the style as you mention, which will be the code to do that to the active layer ? I am looking for the other method, thank you.
Copy link to clipboard
Copied
I managed to resolve sorry for botther you, thank you