r14359 by fschmid - Xara Importer: More bits of text handling, esp properties like bold, italic etc...

scribus-commit scribus-commit at lists.scribus.net
Thu Nov 26 12:30:25 CET 2009


Revision: 14359
Author: fschmid
Date: 2009-11-26T02:10:27.414031Z
Commit message: Xara Importer: More bits of text handling, esp properties like bold, italic etc...

Changeset: 
M  /trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
M  /trunk/Scribus/scribus/plugins/import/xar/importxar.h

Diffs:
Index: scribus/plugins/import/xar/importxar.cpp
===================================================================
--- scribus/plugins/import/xar/importxar.cpp	(revision 14358)
+++ scribus/plugins/import/xar/importxar.cpp	(revision 14359)
@@ -394,8 +394,9 @@
 	}
 	color.name = "Yellow";
 	XarColorMap.insert(-9, color);
-	ignoreableTags << 2 << 40 << 41 << 43 << 46 << 47 << 53 << 61 << 62 << 63 << 80 << 90 << 91 << 92 << 93 << 111 << 2200 << 2205 << 4031;
-	ignoreableTags << 4087 << 4114 << 4115 << 4116 << 4124;
+	ignoreableTags << 2 << 40 << 41 << 43 << 46 << 47 << 53 << 61 << 62 << 63 << 80 << 90 << 91 << 92 << 93 << 111;
+	ignoreableTags << 2150 << 2151 << 2205 << 2900 << 2901;
+	ignoreableTags << 4031 << 4087 << 4114 << 4115 << 4116 << 4124;
 	if(progressDialog)
 	{
 		progressDialog->setOverallProgress(2);
@@ -649,6 +650,24 @@
 		handleTextFontSize(ts);
 	else if (tag == 2907)
 		handleTextFont(ts);
+	else if (tag == 2908)
+		gc->FontBold = true;
+	else if (tag == 2909)
+		gc->FontBold = false;
+	else if (tag == 2910)
+		gc->FontItalic = true;
+	else if (tag == 2911)
+		gc->FontItalic = false;
+	else if (tag == 2912)
+		gc->FontUnderline = true;
+	else if (tag == 2913)
+		gc->FontUnderline = false;
+	else if (tag == 2918)
+		handleTextTracking(ts);
+	else if (tag == 2919)
+		handleTextAspectRatio(ts);
+	else if (tag == 2920)
+		handleTextBaseline(ts);
 	else if (tag == 4075)
 		handleMultiGradient(ts, true);
 	else if (tag == 4076)
@@ -667,11 +686,11 @@
 		finishClip();
 	else
 	{
-/*		if (m_gc.count() > 3)
-		{
-			if ((tag > 1999) && (tag < 3000))
-				qDebug() << QString("Unhandled OpCode: %1 Data Len %2").arg(tag).arg(dataLen, 8, 16, QLatin1Char('0'));
-		} */
+//		if (m_gc.count() > 3)
+//		{
+//			if ((tag > 1999) && (tag < 3000))
+//				qDebug() << QString("Unhandled OpCode: %1 Data Len %2").arg(tag).arg(dataLen, 8, 16, QLatin1Char('0'));
+//		}
 		ts.skipRawData(dataLen);
 	}
 }
@@ -769,6 +788,30 @@
 		gc->TextAlignment = 2;
 }
 
+void XarPlug::handleTextTracking(QDataStream &ts)
+{
+	qint32 val;
+	ts >> val;
+//	qDebug() << "Tracking" << val;
+}
+
+void XarPlug::handleTextAspectRatio(QDataStream &ts)
+{
+	quint32 val;
+	ts >> val;
+	double scaleX = decodeFixed16(val);
+	XarStyle *gc = m_gc.top();
+	gc->FontStretch = scaleX;
+//	qDebug() << "Aspect Ratio" << scaleX;
+}
+
+void XarPlug::handleTextBaseline(QDataStream &ts)
+{
+	qint32 val;
+	ts >> val;
+	TextY += val / 1000.0;
+}
+
 void XarPlug::endTextLine()
 {
 	XarStyle *gc = m_gc.top();
@@ -779,11 +822,15 @@
 		textFont.setPixelSize(gc->FontSize);
 	else
 		textFont.setPointSizeF(gc->FontSize * 72.0 / 96.0);
+	textFont.setBold(gc->FontBold);
+	textFont.setItalic(gc->FontItalic);
+	textFont.setUnderline(gc->FontUnderline);
 	painterPath.addText( 0, 0, textFont, gc->itemText);
 	QRectF bound = painterPath.boundingRect();
 	Coords.resize(0);
 	Coords.fromQPainterPath(painterPath);
 	Coords.map(textMatrix);
+	Coords.scale(gc->FontStretch, 1.0);
 	Coords.translate(TextX, TextY);
 	if (gc->TextAlignment == 1)
 		Coords.translate(-bound.width() / 2.0, 0);
@@ -795,7 +842,7 @@
 		finishItem(z);
 	}
 	gc->itemText = "";
-//	qDebug() << "End of Line, new Y-Pos" << TextY << "Align" << gc->TextAlignment << "Moved by" << gc->LineWidth - txtW;
+//	qDebug() << "End of Line, new Y-Pos" << TextY;
 }
 
 void XarPlug::startSimpleText(QDataStream &ts, quint32 dataLen)
Index: scribus/plugins/import/xar/importxar.h
===================================================================
--- scribus/plugins/import/xar/importxar.h	(revision 14358)
+++ scribus/plugins/import/xar/importxar.h	(revision 14359)
@@ -33,13 +33,14 @@
 	XarStyle() :
 		dashOffset(0),
 		FontFamily(""),
-		FontStyle("normal"),
-		FontWeight("normal"),
-		FontStretch("normal"),
 		itemText(""),
 		FontSize(12.0),
 		LineHeight(15.0),
 		LineWidth(0.0),
+		FontStretch(1.0),
+		FontBold(false),
+		FontUnderline(false),
+		FontItalic(false),
 		TextAlignment(0),
 		FillCol(CommonStrings::None),
 		fillRule(true),
@@ -97,13 +98,14 @@
 	QVector<double> dashArray;
 	double dashOffset;
 	QString FontFamily;
-	QString FontStyle;
-	QString FontWeight;
-	QString FontStretch;
 	QString itemText;
 	double FontSize;
 	double LineHeight;
 	double LineWidth;
+	double FontStretch;
+	bool FontBold;
+	bool FontUnderline;
+	bool FontItalic;
 	int TextAlignment;
 	QString FillCol;
 	bool fillRule;
@@ -200,6 +202,9 @@
 	void handleTextChar(QDataStream &ts);
 	void handleLineInfo(QDataStream &ts);
 	void handleTextAlignment(quint32 tag);
+	void handleTextTracking(QDataStream &ts);
+	void handleTextAspectRatio(QDataStream &ts);
+	void handleTextBaseline(QDataStream &ts);
 	void endTextLine();
 	void startSimpleText(QDataStream &ts, quint32 dataLen);
 	void startComplexText(QDataStream &ts, quint32 dataLen);




More information about the scribus-commit mailing list