add conversion from qfont weight to html weight

This commit is contained in:
arcan1s 2014-09-04 20:51:45 +04:00
parent 4a9402a487
commit 5c645f972c
2 changed files with 65 additions and 0 deletions

View File

@ -33,12 +33,75 @@ QColor CFont::color()
} }
int CFont::htmlWeight()
{
int htmlWeight = 400;
switch(weight()) {
case 16:
htmlWeight = 100;
break;
case 25:
htmlWeight = 300;
break;
case 50:
htmlWeight = 400;
break;
case 63:
htmlWeight = 600;
break;
case 75:
htmlWeight = 800;
break;
case 87:
htmlWeight = 900;
break;
default:
break;
}
return htmlWeight;
}
void CFont::setCurrentColor(const QColor color) void CFont::setCurrentColor(const QColor color)
{ {
currentColor = color; currentColor = color;
} }
void CFont::setHtmlWeight(const int htmlWeight)
{
int weight = 16;
switch(htmlWeight) {
case 100:
weight = 16;
break;
case 200:
case 300:
weight = 25;
break;
case 400:
weight = 50;
break;
case 500:
case 600:
weight = 63;
break;
case 700:
case 800:
weight = 75;
break;
case 900:
weight = 87;
break;
default:
break;
}
setWeight(weight);
}
QFont CFont::toQFont() QFont CFont::toQFont()
{ {
return QFont(family(), pointSize(), weight(), italic()); return QFont(family(), pointSize(), weight(), italic());

View File

@ -32,7 +32,9 @@ public:
int weight = -1, bool italic = false, int weight = -1, bool italic = false,
QColor color = QColor(QString("#000000"))); QColor color = QColor(QString("#000000")));
QColor color(); QColor color();
int htmlWeight();
void setCurrentColor(const QColor color); void setCurrentColor(const QColor color);
void setHtmlWeight(const int htmlWeight);
QFont toQFont(); QFont toQFont();
private: private: