MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / parseFont

Method parseFont

Gui/KnobGuiString.cpp:763–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

761} // restoreTextInfoFromString
762
763void
764KnobGuiString::parseFont(const QString & label,
765 QFont *f,
766 QColor *color)
767{
768 QString toFind = QString::fromUtf8(kFontSizeTag);
769 int startFontTag = label.indexOf(toFind);
770
771 assert(startFontTag != -1);
772 startFontTag += toFind.size();
773 int j = startFontTag;
774 QString sizeStr;
775 while ( j < label.size() && label.at(j).isDigit() ) {
776 sizeStr.push_back( label.at(j) );
777 ++j;
778 }
779
780 toFind = QString::fromUtf8(kFontFaceTag);
781 startFontTag = label.indexOf(toFind, startFontTag);
782 assert(startFontTag != -1);
783 startFontTag += toFind.size();
784 j = startFontTag;
785 QString faceStr;
786 while ( j < label.size() && label.at(j) != QLatin1Char('"') ) {
787 faceStr.push_back( label.at(j) );
788 ++j;
789 }
790
791 f->setPointSize( sizeStr.toInt() );
792 f->setFamily(faceStr);
793
794 {
795 toFind = QString::fromUtf8(kBoldStartTag);
796 int foundBold = label.indexOf(toFind);
797 if (foundBold != -1) {
798 f->setBold(true);
799 }
800 }
801
802 {
803 toFind = QString::fromUtf8(kItalicStartTag);
804 int foundItalic = label.indexOf(toFind);
805 if (foundItalic != -1) {
806 f->setItalic(true);
807 }
808 }
809 {
810 toFind = QString::fromUtf8(kFontColorTag);
811 int foundColor = label.indexOf(toFind);
812 if (foundColor != -1) {
813 foundColor += toFind.size();
814 QString currentColor;
815 int j = foundColor;
816 while ( j < label.size() && label.at(j) != QLatin1Char('"') ) {
817 currentColor.push_back( label.at(j) );
818 ++j;
819 }
820 *color = QColor(currentColor);

Callers

nothing calls this directly

Calls 5

QColorClass · 0.85
atMethod · 0.80
setBoldMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected