Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
PSD text: cleanup and handle warnings better.
Wolthera van Hövell tot Westerflierd02077b11bb0
diff --git a/libs/psd/psd_additional_layer_info_block.cpp b/libs/psd/psd_additional_layer_info_block.cppindex 3c828c0e08..e6f3c9e786 100644--- a/libs/psd/psd_additional_layer_info_block.cpp+++ b/libs/psd/psd_additional_layer_info_block.cpp@@ -656,7 +656,7 @@ void PsdAdditionalLayerInfoBlock::writeVectorMaskImpl(QIODevice &io, psd_vector_Q_FOREACH(psd_path_sub_path subPath, mask.path.subPaths) {recordType = subPath.isClosed? 0: 3;quint16 length = subPath.nodes.size();- qDebug() << "writing subpath" << subPath.nodes.size();+ dbgFile << "writing subpath" << subPath.nodes.size();SAFE_WRITE_EX(byteOrder, io, recordType);SAFE_WRITE_EX(byteOrder, io, length);// 22 empty bitsdiff --git a/libs/psd/psd_layer_section.cpp b/libs/psd/psd_layer_section.cppindex a989de0770..2dbf920e5f 100644--- a/libs/psd/psd_layer_section.cpp+++ b/libs/psd/psd_layer_section.cpp@@ -738,7 +738,7 @@ void PSDLayerMaskSection::writePsdImpl(QIODevice &io, KisNodeSP rootLayer, psd_cif (shapeLayer->shapes().size() == 1) {KoSvgTextShape * text = dynamic_cast<KoSvgTextShape*>(shapeLayer->shapes().first());if (text) {- PsdTextDataConverter convert(text);+ PsdTextDataConverter convert;KoSvgTextShapeMarkupConverter svgConverter(text);QString svgtext;QString styles;@@ -747,7 +747,12 @@ void PSDLayerMaskSection::writePsdImpl(QIODevice &io, KisNodeSP rootLayer, psd_ctextData.boundingBox = text->boundingRect().normalized();textData.bounds = text->outlineRect().normalized();- convert.convertToPSDTextEngineData(svgtext, textData.bounds, text->shapesInside(), globalInfoSection.txt2Data, textData.textIndex, textData.text, textData.isHorizontal, FlaketoPixels);+ bool res = convert.convertToPSDTextEngineData(svgtext, textData.bounds, text->shapesInside(), globalInfoSection.txt2Data, textData.textIndex, textData.text, textData.isHorizontal, FlaketoPixels);+ if (!res && !convert.errors().isEmpty()) {+ qWarning() << convert.errors();++ }+ dbgFile << convert.warnings();textData.engineData = KisTxt2Utils::tyShFromTxt2(globalInfoSection.txt2Data, FlaketoPixels.mapRect(textData.boundingBox), textData.textIndex);textCount += 1;if (!text->shapesInside().isEmpty()) {diff --git a/libs/psdutils/cos/psd_text_data_converter.cpp b/libs/psdutils/cos/psd_text_data_converter.cppindex 15e1a936bb..58c59a4336 100644--- a/libs/psdutils/cos/psd_text_data_converter.cpp+++ b/libs/psdutils/cos/psd_text_data_converter.cpp@@ -26,9 +26,6 @@#include <QXmlStreamWriter>#include <QtMath>struct PsdTextDataConverter::Private {- Private(KoSvgTextShape *_shape) : shape(_shape) {}-- KoSvgTextShape *shape;QStringList errors;QStringList warnings;@@ -38,8 +35,8 @@ struct PsdTextDataConverter::Private {warnings.clear();}};-PsdTextDataConverter::PsdTextDataConverter(KoSvgTextShape *shape)- : d(new Private(shape))+PsdTextDataConverter::PsdTextDataConverter()+ : d(new Private){}diff --git a/libs/psdutils/cos/psd_text_data_converter.h b/libs/psdutils/cos/psd_text_data_converter.hindex 6475968736..d9b02a60f9 100644--- a/libs/psdutils/cos/psd_text_data_converter.h+++ b/libs/psdutils/cos/psd_text_data_converter.h@@ -28,7 +28,7 @@ class QDomElement;class KRITAPSDUTILS_EXPORT PsdTextDataConverter{public:- PsdTextDataConverter(KoSvgTextShape *shape);+ PsdTextDataConverter();~PsdTextDataConverter();bool convertPSDTextEngineDataToSVG(const QVariantHash tySh,diff --git a/plugins/impex/psd/psd_loader.cpp b/plugins/impex/psd/psd_loader.cppindex 50922283f5..18273b2c58 100644--- a/plugins/impex/psd/psd_loader.cpp+++ b/plugins/impex/psd/psd_loader.cpp@@ -481,7 +481,7 @@ KisImportExportErrorCode PSDLoader::decode(QIODevice &io)KisAslXmlParser parser;parser.parseXML(layerRecord->infoBlocks.textData, catcher);KoSvgTextShape *shape = new KoSvgTextShape();- PsdTextDataConverter converter(shape);+ PsdTextDataConverter converter;KoSvgTextShapeMarkupConverter svgConverter(shape);QString svg;@@ -501,8 +501,9 @@ KisImportExportErrorCode PSDLoader::decode(QIODevice &io)offset1, offsetByAscent,text.isHorizontal, scaleToPt);if (!res || !converter.errors().isEmpty()) {- qDebug() << converter.errors();+ qWarning() << converter.errors();}+ dbgFile << converter.warnings();svgConverter.convertFromSvg(svg, styles, m_image->bounds(), m_image->xRes()*72.0);if (offsetByAscent) {QPointF offset2 = QPointF() - shape->outlineRect().topLeft();