📄 notefont.cpp
字号:
int charBase = 0; SystemFont *systemFont = m_fontMap.getSystemFont(m_size, charName, charBase); if (!systemFont) { if (!inverted && m_fontMap.hasInversion(m_size, charName)) { if (!getPixmap(charName, pixmap, !inverted)) return false; found = new QPixmap(PixmapFunctions::flipVertical(pixmap)); add(charName, inverted, found); pixmap = *found; return true; } std::cerr << "NoteFont::getPixmap: Warning: No system font for character \"" << charName << "\"" << (inverted ? " (inverted)" : "") << " in font \"" << m_fontMap.getName() << "\"" << std::endl; add(charName, inverted, 0); pixmap = *m_blankPixmap; return false; } SystemFont::Strategy strategy = m_fontMap.getStrategy(m_size, charName); bool success; found = new QPixmap(systemFont->renderChar(charName, glyph, code + charBase, strategy, success)); if (success) { add(charName, inverted, found); pixmap = *found; return true; } else { add(charName, inverted, 0); pixmap = *m_blankPixmap; return false; } } add(charName, inverted, 0); pixmap = *m_blankPixmap; return false;}boolNoteFont::getColouredPixmap(CharName baseCharName, QPixmap &pixmap, int hue, int minValue, bool inverted) const{ CharName charName(getNameWithColour(baseCharName, hue)); QPixmap *found = 0; bool ok = lookup(charName, inverted, found); if (ok) { if (found) { pixmap = *found; return true; } else { pixmap = *m_blankPixmap; return false; } } QPixmap basePixmap; ok = getPixmap(baseCharName, basePixmap, inverted); if (!ok) { add(charName, inverted, 0); pixmap = *m_blankPixmap; return false; } found = new QPixmap (PixmapFunctions::colourPixmap(basePixmap, hue, minValue)); add(charName, inverted, found); pixmap = *found; return ok;}boolNoteFont::getShadedPixmap(CharName baseCharName, QPixmap &pixmap, bool inverted) const{ CharName charName(getNameShaded(baseCharName)); QPixmap *found = 0; bool ok = lookup(charName, inverted, found); if (ok) { if (found) { pixmap = *found; return true; } else { pixmap = *m_blankPixmap; return false; } } QPixmap basePixmap; ok = getPixmap(baseCharName, basePixmap, inverted); if (!ok) { add(charName, inverted, 0); pixmap = *m_blankPixmap; return false; } found = new QPixmap(PixmapFunctions::shadePixmap(basePixmap)); add(charName, inverted, found); pixmap = *found; return ok;}CharNameNoteFont::getNameWithColour(CharName base, int hue) const{ return qstrtostr(QString("%1__%2").arg(hue).arg(strtoqstr(base)));}CharNameNoteFont::getNameShaded(CharName base) const{ return qstrtostr(QString("shaded__%1").arg(strtoqstr(base)));}boolNoteFont::getDimensions(CharName charName, int &x, int &y, bool inverted) const{ QPixmap pixmap; bool ok = getPixmap(charName, pixmap, inverted); x = pixmap.width(); y = pixmap.height(); return ok;}intNoteFont::getWidth(CharName charName) const{ int x, y; getDimensions(charName, x, y); return x;}intNoteFont::getHeight(CharName charName) const{ int x, y; getDimensions(charName, x, y); return y;}boolNoteFont::getHotspot(CharName charName, int &x, int &y, bool inverted) const{ int w, h; getDimensions(charName, w, h, inverted); bool ok = m_fontMap.getHotspot(m_size, charName, w, h, x, y); if (!ok) { x = 0; y = h / 2; } if (inverted) { y = h - y; } return ok;}QPointNoteFont::getHotspot(CharName charName, bool inverted) const{ int x, y; (void)getHotspot(charName, x, y, inverted); return QPoint(x, y);}boolNoteFont::getCharacter(CharName charName, NoteCharacter &character, CharacterType type, bool inverted){ QPixmap pixmap; if (!getPixmap(charName, pixmap, inverted)) return false; if (type == Screen) { character = NoteCharacter(pixmap, getHotspot(charName, inverted), 0); } else { // Get the pointer direct from cache (depends on earlier call // to getPixmap to put it in the cache if available) QPixmap *pmapptr = 0; bool found = lookup(charName, inverted, pmapptr); NoteCharacterDrawRep *rep = 0; if (found && pmapptr) rep = lookupDrawRep(pmapptr); character = NoteCharacter(pixmap, getHotspot(charName, inverted), rep); } return true;}NoteCharacterNoteFont::getCharacter(CharName charName, CharacterType type, bool inverted){ NoteCharacter character; getCharacter(charName, character, type, inverted); return character;}boolNoteFont::getCharacterColoured(CharName charName, int hue, int minValue, NoteCharacter &character, CharacterType type, bool inverted){ QPixmap pixmap; if (!getColouredPixmap(charName, pixmap, hue, minValue, inverted)) { return false; } if (type == Screen) { character = NoteCharacter(pixmap, getHotspot(charName, inverted), 0); } else { // Get the pointer direct from cache (depends on earlier call // to getPixmap to put it in the cache if available) QPixmap *pmapptr = 0; CharName cCharName(getNameWithColour(charName, hue)); bool found = lookup(cCharName, inverted, pmapptr); NoteCharacterDrawRep *rep = 0; if (found && pmapptr) rep = lookupDrawRep(pmapptr); character = NoteCharacter(pixmap, getHotspot(charName, inverted), rep); } return true;}NoteCharacterNoteFont::getCharacterColoured(CharName charName, int hue, int minValue, CharacterType type, bool inverted){ NoteCharacter character; getCharacterColoured(charName, hue, minValue, character, type, inverted); return character;}boolNoteFont::getCharacterShaded(CharName charName, NoteCharacter &character, CharacterType type, bool inverted){ QPixmap pixmap; if (!getShadedPixmap(charName, pixmap, inverted)) { return false; } if (type == Screen) { character = NoteCharacter(pixmap, getHotspot(charName, inverted), 0); } else { // Get the pointer direct from cache (depends on earlier call // to getPixmap to put it in the cache if available) QPixmap *pmapptr = 0; CharName cCharName(getNameShaded(charName)); bool found = lookup(cCharName, inverted, pmapptr); NoteCharacterDrawRep *rep = 0; if (found && pmapptr) rep = lookupDrawRep(pmapptr); character = NoteCharacter(pixmap, getHotspot(charName, inverted), rep); } return true;}NoteCharacterNoteFont::getCharacterShaded(CharName charName, CharacterType type, bool inverted){ NoteCharacter character; getCharacterShaded(charName, character, type, inverted); return character;}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -