159 QColor strokecolor = gc->
stroke->color();
161 if (params ==
"inherit")
164 if (command ==
"fill") {
165 if (params ==
"none") {
167 }
else if (params.startsWith(QLatin1String(
"url("))) {
168 unsigned int start = params.indexOf(
'#') + 1;
169 unsigned int end = params.indexOf(
')', start);
170 gc->
fillId = params.mid(start, end - start);
173 parseColor(fillcolor, params.mid(end + 1).trimmed());
179 }
else if (command ==
"fill-rule") {
180 if (params ==
"nonzero")
182 else if (params ==
"evenodd")
184 }
else if (command ==
"stroke") {
185 if (params ==
"none") {
187 }
else if (params.startsWith(QLatin1String(
"url("))) {
188 unsigned int start = params.indexOf(
'#') + 1;
189 unsigned int end = params.indexOf(
')', start);
190 gc->
strokeId = params.mid(start, end - start);
193 parseColor(strokecolor, params.mid(end + 1).trimmed());
199 }
else if (command ==
"stroke-width") {
201 }
else if (command ==
"stroke-linejoin") {
202 if (params ==
"miter")
203 gc->
stroke->setJoinStyle(Qt::MiterJoin);
204 else if (params ==
"round")
205 gc->
stroke->setJoinStyle(Qt::RoundJoin);
206 else if (params ==
"bevel")
207 gc->
stroke->setJoinStyle(Qt::BevelJoin);
208 }
else if (command ==
"stroke-linecap") {
209 if (params ==
"butt")
210 gc->
stroke->setCapStyle(Qt::FlatCap);
211 else if (params ==
"round")
212 gc->
stroke->setCapStyle(Qt::RoundCap);
213 else if (params ==
"square")
214 gc->
stroke->setCapStyle(Qt::SquareCap);
215 }
else if (command ==
"stroke-miterlimit") {
216 gc->
stroke->setMiterLimit(params.toFloat());
217 }
else if (command ==
"stroke-dasharray") {
219 if (params !=
"none") {
220 QString dashString = params;
221 QStringList dashes = dashString.replace(
',',
' ').simplified().split(
' ');
222 for (QStringList::Iterator it = dashes.begin(); it != dashes.end(); ++it) {
227 if (array.size() & 1) {
231 gc->
stroke->setLineStyle(Qt::CustomDashLine, array);
232 }
else if (command ==
"stroke-dashoffset") {
233 gc->
stroke->setDashOffset(params.toFloat());
236 else if (command ==
"stroke-opacity")
238 else if (command ==
"fill-opacity") {
244 fillcolor.setAlphaF(opacity);
245 }
else if (command ==
"opacity") {
247 }
else if (command ==
"paint-order") {
249 }
else if (command ==
"font-family") {
251 }
else if (command ==
"font-size") {
253 }
else if (command ==
"font-style") {
256 }
else if (command ==
"font-variant" || command ==
"font-variant-caps" || command ==
"font-variant-alternates" || command ==
"font-variant-ligatures"
257 || command ==
"font-variant-numeric" || command ==
"font-variant-east-asian" || command ==
"font-variant-position") {
260 }
else if (command ==
"font-feature-settings") {
262 }
else if (command ==
"font-stretch") {
264 }
else if (command ==
"font-weight") {
266 }
else if (command ==
"font-variation-settings") {
268 }
else if (command ==
"font-optical-sizing") {
270 }
else if (command ==
"font-size-adjust") {
272 }
else if (command ==
"font-synthesis"
273 || command ==
"font-synthesis-weight" || command ==
"font-synthesis-style"
274 || command ==
"font-synthesis-small-caps" || command ==
"font-synthesis-position") {
276 }
else if (command ==
"font") {
277 qWarning() <<
"Krita does not support the 'font' shorthand";
278 }
else if (command ==
"text-decoration" || command ==
"text-decoration-line" || command ==
"text-decoration-style" || command ==
"text-decoration-color"
279 || command ==
"text-decoration-position") {
282 }
else if (command ==
"color") {
286 }
else if (command ==
"display") {
287 if (params ==
"none")
289 }
else if (command ==
"visibility") {
291 gc->
visible = params ==
"visible";
292 }
else if (command ==
"filter") {
293 if (params !=
"none" && params.startsWith(
"url(")) {
294 unsigned int start = params.indexOf(
'#') + 1;
295 unsigned int end = params.indexOf(
')', start);
296 gc->
filterId = params.mid(start, end - start);
298 }
else if (command ==
"clip-path") {
299 if (params !=
"none" && params.startsWith(
"url(")) {
300 unsigned int start = params.indexOf(
'#') + 1;
301 unsigned int end = params.indexOf(
')', start);
302 gc->
clipPathId = params.mid(start, end - start);
304 }
else if (command ==
"shape-inside") {
306 }
else if (command ==
"shape-subtract") {
308 }
else if (command ==
"clip-rule") {
309 if (params ==
"nonzero")
311 else if (params ==
"evenodd")
313 }
else if (command ==
"mask") {
314 if (params !=
"none" && params.startsWith(
"url(")) {
315 unsigned int start = params.indexOf(
'#') + 1;
316 unsigned int end = params.indexOf(
')', start);
317 gc->
clipMaskId = params.mid(start, end - start);
319 }
else if (command ==
"marker-start") {
320 if (params !=
"none" && params.startsWith(
"url(")) {
321 unsigned int start = params.indexOf(
'#') + 1;
322 unsigned int end = params.indexOf(
')', start);
325 }
else if (command ==
"marker-end") {
326 if (params !=
"none" && params.startsWith(
"url(")) {
327 unsigned int start = params.indexOf(
'#') + 1;
328 unsigned int end = params.indexOf(
')', start);
331 }
else if (command ==
"marker-mid") {
332 if (params !=
"none" && params.startsWith(
"url(")) {
333 unsigned int start = params.indexOf(
'#') + 1;
334 unsigned int end = params.indexOf(
')', start);
337 }
else if (command ==
"marker") {
338 if (params !=
"none" && params.startsWith(
"url(")) {
339 unsigned int start = params.indexOf(
'#') + 1;
340 unsigned int end = params.indexOf(
')', start);
345 }
else if (command ==
"font-kerning" || command ==
"line-height" || command ==
"white-space" || command ==
"xml:space" || command ==
"text-transform" || command ==
"text-indent"
346 || command ==
"word-break" || command ==
"line-break" || command ==
"hanging-punctuation" || command ==
"text-align"
347 || command ==
"text-align-all" || command ==
"text-align-last" || command ==
"inline-size" || command ==
"overflow" || command ==
"text-overflow"
348 || command ==
"tab-size" || command ==
"overflow-wrap" || command ==
"word-wrap" || command ==
"vertical-align"
349 || command ==
"shape-padding" || command ==
"shape-margin" || command ==
"text-orientation" || command ==
"text-rendering") {
351 }
else if (command ==
"krita:marker-fill-method") {
353 }
else if (
d->textAttributes.contains(command)) {
358 gc->
stroke->setColor(strokecolor);
376 qreal& previousOffset)
379 QString offsetStr = stop.attribute(
"offset").trimmed();
380 if (offsetStr.endsWith(
'%')) {
381 offsetStr = offsetStr.left(offsetStr.length() - 1);
382 offset = offsetStr.toFloat() / 100.0;
384 offset = offsetStr.toFloat();
388 offset = qBound(0.0, offset, 1.0);
391 offset = qMax(offset, previousOffset);
392 previousOffset = offset;
396 QString stopColorStr = stop.attribute(
"stop-color");
397 QString stopOpacityStr = stop.attribute(
"stop-opacity");
399 const QStringList attributes({
"stop-color",
"stop-opacity"});
403 if (styles.contains(
"stop-color")) {
404 stopColorStr = styles.value(
"stop-color");
407 if (styles.contains(
"stop-opacity")) {
408 stopOpacityStr = styles.value(
"stop-opacity");
411 if (stopColorStr.isEmpty() && stopColorStr ==
"inherit") {
417 if (!stopOpacityStr.isEmpty() && stopOpacityStr !=
"inherit") {
420 return QPair<qreal, QColor>(offset, color);
480 Q_FOREACH (
const QString & command,
d->fontAttributes) {
481 const QString attribute = e.attribute(command);
482 if (!attribute.isEmpty())
483 styleMap[command] = attribute;
485 Q_FOREACH (
const QString &command,
d->styleAttributes) {
486 const QString attribute = e.attribute(command);
487 if (!attribute.isEmpty())
488 styleMap[command] = attribute;
490 Q_FOREACH (
const QString & command,
d->textAttributes) {
491 const QString attribute = e.attribute(command);
492 if (!attribute.isEmpty())
493 styleMap[command] = attribute;
497 QStringList cssStyles =
d->context.matchingCssStyles(e);
500 Q_FOREACH (
const QString &style, cssStyles) {
501 QStringList substyles = style.split(
';', Qt::SkipEmptyParts);
502 if (!substyles.count())
504 for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) {
506 if (substyle.count() != 2)
508 QString command = substyle[0].trimmed();
509 QString params = substyle[1].trimmed();
512 command.replace(
"|",
":");
515 if (
d->styleAttributes.contains(command) ||
516 d->fontAttributes.contains(command) ||
517 d->textAttributes.contains(command)) {
519 styleMap[command] = params;
527 QMutableMapIterator<QString, QString> it(styleMap);
528 while (it.hasNext()) {
530 if (it.value() ==
"inherit") {
void parseSvgTextAttribute(const SvgLoadingContext &context, const QString &command, const QString &value)
parseSvgTextAttribute add a property according to an XML attribute value.
static QStringList supportedXmlAttributes()
bool visible
controls visibility of the shape (inherited)
QString fillId
the current fill id (used for gradient/pattern fills)
KoSvgTextProperties textProperties
Stores textProperties.
QString shapeSubtractValue
String of value shape-subtract, will be parsed later.
QString strokeId
the current stroke id (used for gradient strokes)
bool display
controls display of shape
QString paintOrder
String list indicating paint order;.
QString shapeInsideValue
String of value shape-inside, will be parsed later.
@ Complex
gradient or pattern style
QColor fillColor
the current fill color. Default is black fill as per svg spec
Contains data used for loading svg.