我在更新文本的时候,文本内容显示不全
textLayer.UpdateText(“D’Lany”, new Point((int)customLayer.Position.x, (int)customLayer.Position.y), 150, color);
foreach (var portion in textLayer.TextData.Items)
{
portion.Style.FontName = “AlineSignature”
}
textLayer.TextData.UpdateLayerData();
PS:附件中是相关字体和图片
1.zip (83.4 KB)
@yuluojie
在更新文本时,如果文本内容显示不全,可能是由于文本层的设置或字体问题。您可以尝试以下步骤来解决此问题:
-
检查文本框的大小:确保您为文本层指定的矩形区域足够大,以容纳所有文本内容。您可以通过调整矩形的宽度和高度来实现。
-
字体设置:确保所使用的字体(在您的例子中是 “AlineSignature”)在系统中可用,并且支持您要显示的所有字符。如果字体不支持某些字符,可能会导致文本显示不全。
-
更新文本数据:在更新文本后,确保调用 textLayer.TextData.UpdateLayerData()
方法,以确保文本层的数据被正确更新。
-
调整文本样式:如果文本仍然显示不全,您可以尝试调整文本样式,例如字体大小、行间距等,以确保文本能够适应指定的区域。
以下是一个示例代码,展示如何设置文本层并更新文本:
// 创建文本层
TextLayer textLayer = new TextLayer("初始文本", new Rectangle(0, 0, 300, 100));
textLayer.UpdateText("D’Lany", new Point((int)customLayer.Position.x, (int)customLayer.Position.y), 150, color);
// 设置字体样式
foreach (var portion in textLayer.TextData.Items)
{
portion.Style.FontName = "AlineSignature";
}
// 更新文本层数据
textLayer.TextData.UpdateLayerData();
请确保在更新文本之前,文本层的矩形区域足够大,以容纳所有文本内容。如果问题仍然存在,请检查字体文件是否正确,并确保它在您的环境中可用。
@yuluojie could you please provide original input file in psd format or code to create the file that was used for this code.
Also, please provide version of Aspose.PSD that you use, operation system and .NET version.
你好,感谢你的回复。
附件中是我这边的原始psd文件和字体文件。
我的目标是:这这个psd文件里面找到 名称为 【S1-Text1 Input 1】的文本图层,然后把文本内容 【D’Lany】更新上去 (updatetext)。
当我发现使用这个字体【AlineSignature】更新的文本内容里面带有 【y】字母时,这个字母就会被截取显示部分。如果没有y字母,则显示正常的。
PS: 1.操作系统 windows 10
2.aspose.psd 版本:24.12.0.0
example.zip (9.4 MB)
AlineSignature.zip (41.7 KB)
@yuluojie
我可以确认这个问题。我创建了高优先级的问题来解决这个问题
我们已经在内部问题跟踪系统中打开了以下新工单,并将根据以下条款提供修复:Free Support Policies.
Issue ID(s): PSDNET-2369
如果您需要优先支持,您可以获得Paid Support Services,以及直接联系我们的付费支持管理团队。