[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra=5D_plugins/vectorshape/libsvm=3A_SVM=3A_Im?=
From: Inge Wallin <inge () lysator ! liu ! se>
Date: 2011-04-30 14:53:55
Message-ID: 20110430145355.30B30A60A4 () git ! kde ! org
[Download RAW message or body]
Git commit 096e08232709e9f6cab577c473fb4b96141bd61f by Inge Wallin.
Committed on 30/04/2011 at 16:52.
Pushed by ingwa into branch 'master'.
SVM: Implement the META_FONT_ACTION to set fonts
M +75 -6 plugins/vectorshape/libsvm/SvmParser.cpp
M +2 -0 plugins/vectorshape/libsvm/SvmParser.h
http://commits.kde.org/calligra/096e08232709e9f6cab577c473fb4b96141bd61f
diff --git a/plugins/vectorshape/libsvm/SvmParser.cpp b/plugins/vectorshape/libsvm/SvmParser.cpp
index ba0af9f..9c941ce 100644
--- a/plugins/vectorshape/libsvm/SvmParser.cpp
+++ b/plugins/vectorshape/libsvm/SvmParser.cpp
@@ -279,12 +279,7 @@ bool SvmParser::parse(const QByteArray &data)
QString string;
stream >> startPoint;
- stream >> strLength;
- for (uint i = 0; i < strLength; ++i) {
- quint8 ch;
- stream >> ch;
- string += char(ch);
- }
+ parseString(stream, string);
// FIXME: Much more here
kDebug(31000) << "Text: " << startPoint << string;
@@ -347,6 +342,10 @@ bool SvmParser::parse(const QByteArray &data)
}
break;
case META_FONT_ACTION:
+ {
+ parseFont(stream, mContext.font);
+ mContext.changedItems |= GCFont;
+ }
break;
case META_PUSH_ACTION:
{
@@ -431,6 +430,76 @@ void SvmParser::parsePolygon(QDataStream &stream, QPolygon &polygon)
}
}
+void SvmParser::parseString(QDataStream &stream, QString &string)
+{
+ quint16 length;
+
+ stream >> length;
+ for (uint i = 0; i < length; ++i) {
+ quint8 ch;
+ stream >> ch;
+ string += char(ch);
+ }
+}
+
+void SvmParser::parseFont(QDataStream &stream, QFont &font)
+{
+ quint16 version;
+ quint32 totalSize;
+
+ // the VersionCompat struct
+ stream >> version;
+ stream >> totalSize;
+
+ // Name and style
+ QString family;
+ QString style;
+ parseString(stream, family);
+ parseString(stream, style);
+ font.setFamily(family);
+
+ // Font size
+ quint32 width;
+ quint32 height;
+ stream >> width;
+ stream >> height;
+ font.setPointSize(height);
+
+ qint8 temp8;
+ bool tempbool;
+ quint16 tempu16;
+ stream >> tempu16; // charset
+ stream >> tempu16; // family
+ stream >> tempu16; // pitch
+ stream >> tempu16; // weight
+ stream >> tempu16; // underline
+ stream >> tempu16; // strikeout
+ stream >> tempu16; // italic
+ stream >> tempu16; // language
+ stream >> tempu16; // width
+
+ stream >> tempu16; // orientation
+
+ stream >> tempbool; // wordline
+ stream >> tempbool; // outline
+ stream >> tempbool; // shadow
+ stream >> temp8; // kerning
+
+ if (version > 1) {
+ stream >> temp8; // relief
+ stream >> tempu16; // language
+ stream >> tempbool; // vertical
+ stream >> tempu16; // emphasis
+ }
+
+ if (version > 2) {
+ stream >> tempu16; // overline
+ }
+
+ // FIXME: Read away the rest of font here to allow for higher versions than 3.
+}
+
+
void SvmParser::dumpAction(QDataStream &stream, quint16 version, quint32 totalSize)
{
qDebug() << "Version: " << version;
diff --git a/plugins/vectorshape/libsvm/SvmParser.h b/plugins/vectorshape/libsvm/SvmParser.h
index 343264d..8c136c0 100644
--- a/plugins/vectorshape/libsvm/SvmParser.h
+++ b/plugins/vectorshape/libsvm/SvmParser.h
@@ -44,6 +44,8 @@ class SVM_EXPORT SvmParser
private:
void parseRect(QDataStream &stream, QRect &rect);
void parsePolygon(QDataStream &stream, QPolygon &polygon);
+ void parseString(QDataStream &stream, QString &string);
+ void parseFont(QDataStream &stream, QFont &font);
void dumpAction(QDataStream &stream, quint16 version, quint32 totalSize);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic