I’m writing a react text replacement plugin in UXP and got a problem with special characters like ►. It transfers it to the sp-text-area from a layer without any issues, but when the text gets back to the layer I get double-crossed square instead of the proper sign. Any ideas on how to solve this one?
Sounds like the font, used on the layer where you send this text back, does not support this symbol. Could this be the case? Do you use the same font which you read from and and which you write to?
does it show the correct character in console?
if yes then we way conclude the issue is not with reading the value from sp-text-area but may be with the text engine itself.
maybe try setting the font to a known safe font like “tahoma” and try setting the value using console.
I’d try using both layer.textItem.contents
and batchPlay
just to narrow down the cause of the issue
I think that PSD internally uses UTF-16 for layer names. But UXP is probably using UTF-8 everywhere? Maybe there is some issue with conversion?
var ps = require("photoshop");
var {executeAsModal} = require("photoshop").core;
var {batchPlay} = require("photoshop").action;
async function actionCommands() {
ps.app.activeDocument.activeLayers[0].name="►"
}
async function runModalFunction() {
await executeAsModal(actionCommands, {"commandName": "Action Commands"});
}
await runModalFunction();
This works without a problem.
OK, so here’s another question Are we talking about layer name or a text inside a text layer?
The text inside of the layer; the font is the same (reading from Myriad and sending to Myriad), it’s just a textItem.contents change. In the console it looks fine. I’ll try to check up on the rest tomorrow.