当前位置: 首页>>代码示例>>C++>>正文


C++ Sym::code方法代码示例

本文整理汇总了C++中Sym::code方法的典型用法代码示例。如果您正苦于以下问题:C++ Sym::code方法的具体用法?C++ Sym::code怎么用?C++ Sym::code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sym的用法示例。


在下文中一共展示了Sym::code方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: symToHtml

QString symToHtml(const Sym& s1, const Sym& s2, int leftMargin)
      {
      QFont f        = s1.font();
#ifdef USE_GLYPHS
      qreal size = s1.font().pointSizeF();
#else
      qreal size = s1.font().pixelSize();
#endif
      QString family = f.family();

      return QString(
      "<data>"
        "<html>"
          "<head>"
            "<meta name=\"qrichtext\" content=\"1\" >"
            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\" />"
            "<style type=\"text/css\">"
              "p, li { white-space: pre-wrap; }"
              "</style>"
            "</head>"
          "<body style=\" font-family:'%1'; font-size:%2pt;\">"
            "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:%3px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
                "&#%4;&#%5;"
              "</p>"
            "</body>"
          "</html>"
      "</data>").arg(family).arg(size).arg(leftMargin).arg(s1.code()).arg(s2.code());
      }
开发者ID:Skibol,项目名称:MuseScore,代码行数:28,代码来源:sym.cpp

示例2: initSymbols

void initSymbols(int idx)
      {
      if (symbolsInitialized[idx])
            return;
      symbolsInitialized[idx] = true;
      symbols[idx] = QVector<Sym>(lastSym);

      symbols[idx][clefEightSym] = Sym(0x38, 2);
      symbols[idx][clefOneSym]   = Sym(0x31, 2);
      symbols[idx][clefFiveSym]  = Sym(0x35, 2);
      symbols[idx][letterTSym]   = Sym('T',  2);
      symbols[idx][letterSSym]   = Sym('S',  2);
      symbols[idx][letterPSym]   = Sym('P',  2);

      QString path;
#ifdef Q_OS_IOS
      {
      extern QString resourcePath();
      QString rpath = resourcePath();
      path = rpath + QString(idx == 0 ? "/mscore20.xml" : "/mscore/gonville.xml");
      }
#else
      path = idx == 0 ? ":/fonts/mscore20.xml" : ":/fonts/gonville.xml";
#endif
      QFile f(path);
      if (!f.open(QFile::ReadOnly)) {
            qDebug("cannot open symbols file %s", qPrintable(path));
            if (!MScore::debugMode)
                  exit(-1);
            }
      XmlReader e(&f);
      int fid = idx == 0 ? 0 : 3;

      while (e.readNextStartElement()) {
            if (e.name() == "museScore") {
                  while (e.readNextStartElement()) {
                        if (e.name() == "Glyph") {
                              QString name;
                              int code = -1;
                              QPointF p;
                              QRectF b;
                              while (e.readNextStartElement()) {
                                    const QStringRef& tag(e.name());
                                    if (tag == "name")
                                          name = e.readElementText();
                                    else if (tag == "code") {
                                          QString val(e.readElementText());
                                          bool ok;
                                          code = val.mid(2).toInt(&ok, 16);
                                          if (!ok)
                                                qDebug("cannot read code");
                                          }
                                    else if (tag == "attach")
                                          p = e.readPoint();
                                    else if (tag == "bbox")
                                          b = e.readRect();
                                    else
                                          e.unknown();
                                    }
                              if (code == -1)
                                    qDebug("no code for glyph <%s>", qPrintable(name));
                              SymId idx1 = Sym::name2id(name);
                              if (idx1 != noSym)
                                    symbols[idx][idx1] = Sym(code, fid, p, b);
                              else {
                                    qDebug("symbol <%s> declared in %s for symbol set %d not used",
                                       qPrintable(name), qPrintable(path), idx);
                                    }
                              }
                        else
                              e.unknown();
                        }
                  }
            else
                  e.unknown();
            }
      for (int i = 0; i < lastSym; ++i) {
            Sym* sym = &symbols[idx][i];
            if (sym->code() == -1) {
                  qDebug("no code for symbol %s", Sym::id2name(SymId(i)));
                  if (idx > 0) {
                        //fallback to default font
                        symbols[idx][i] = symbols[0][i];
                        }
                  }
            }
      }
开发者ID:Skibol,项目名称:MuseScore,代码行数:87,代码来源:sym.cpp


注:本文中的Sym::code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。