When replacing text with the Aspose SDK, two issues have arisen:
- The font has changed and is inconsistent with the source file. How can this be resolved, or how can I specify a specific font?
- The visual effects are lost – the white stroke and white background have disappeared. How can these issues be fixed?
I am using the Python version 25.11 of the SDK. Thank you.
11.png (33.2 KB)
22.jpg (28.7 KB)
@hellokimi56
-
Font inconsistency during text replacement:
When replacing text in a PSD file using Aspose.PSD, the font may not match the original because the getFont() method retrieves the base font object, but there are reports that the returned font size does not reflect the actual size used in Photoshop — it may appear uniform across layers regardless of visual differences . You can retrieve the font family and size via textLayer.getFont().getFamilyName() and getFont().getSize(), but discrepancies in size interpretation may occur. To maintain consistency, you should manually specify the desired font and size after retrieving or inspecting the original values. However, there is no direct method shown in the current context to set the font or size explicitly on a text layer after modification in Aspose.PSD for Python, which suggests a potential limitation or need for post-replacement styling workarounds .
-
Loss of visual effects (stroke and background):
Visual effects such as white stroke (outline) and background fill are part of the layer’s blending options and effects. You can access these using getBlendingOptions().getEffects(), which returns an array of ILayerEffect objects containing stroke color, width, and other properties . However, these effects may not persist automatically when modifying text content, as Aspose.PSD may not fully preserve advanced text effects like outlines during manipulation . This behavior is consistent with known limitations in other Aspose products when handling complex text styling, such as WordArt or layered effects in DOCX conversions .
Unfortunately, based on the provided documentation and forum discussions, there is no clear example or method in Aspose.PSD for Python (v25.11) to reapply or preserve these visual effects after text replacement [2, 5]. The API allows reading effects but does not demonstrate how to write or restore them programmatically in the Python SDK.
Recommendations:
- Retrieve original font and effect properties before replacement using
textLayer.getFont() and layer.getBlendingOptions().getEffects().
- If possible, manually reapply styling (font, stroke, fill) after replacement — though this requires unsupported or undocumented steps not currently detailed in the available resources.
- Consider reporting this as a feature request or limitation to the Aspose team, referencing the loss of text effects and font fidelity during edit operations.
Are there any examples of python code?