예제 #1
0
void View::DrawLyricString ( DeviceContext *dc, int x, int y, std::wstring s, int staffSize)
{
    assert( dc );
    
    dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ) );
    
    std::wistringstream iss( s  );
    std::wstring token;
    while( std::getline( iss, token, L'_' ))
    {
        dc->DrawText( UTF16to8( token.c_str() ), token );
        // no _
        if (iss.eof())
            break;
        
        FontInfo vrvTxt;
        vrvTxt.SetFaceName("VerovioText");
        vrvTxt.SetPointSize( m_doc->GetDrawingLyricFont(staffSize)->GetPointSize() );
        
        dc->SetFont( &vrvTxt );
        dc->VrvTextFont();
        std::wstring str;
        str.push_back(VRV_TEXT_E551);
        dc->DrawText( UTF16to8( str.c_str() ), str );
        dc->ResetFont();
    }
    //std::wcout << std::endl;
    
    dc->EndText( );
}
예제 #2
0
파일: view_text.cpp 프로젝트: DDMAL/verovio
void View::DrawHarmString(DeviceContext *dc, int x, int y, std::wstring s)
{
    assert(dc);

    std::size_t prev_pos = 0, pos;
    while ((pos = s.find_first_of(L"\u266D\u266E\u266F", prev_pos)) != std::wstring::npos) {
        // If pos is > than the previous, it is the substring to extract
        if (pos > prev_pos) {
            std::wstring substr = s.substr(prev_pos, pos - prev_pos);
            dc->DrawText(UTF16to8(substr), substr);
        }

        // if it is the same or we still have space, it is the accidental
        if (pos == prev_pos || pos < s.length()) {
            // Then the accidental
            std::wstring accid = s.substr(pos, 1);
            std::wstring smufl_accid;
            if (accid == L"\u266D") { // MUSIC FLAT SIGN
                smufl_accid.push_back(SMUFL_E260_accidentalFlat);
            }
            else if (accid == L"\u266E") { // MUSIC NATURAL SIGN
                smufl_accid.push_back(SMUFL_E261_accidentalNatural);
            }
            else if (accid == L"\u266F") { // MUSIC SHARP SIGN
                smufl_accid.push_back(SMUFL_E262_accidentalSharp);
            }
            else {
                smufl_accid.push_back(0xE26D);
            }

            FontInfo vrvTxt;
            vrvTxt.SetFaceName("VerovioText");
            dc->SetFont(&vrvTxt);
            dc->DrawText(UTF16to8(smufl_accid), smufl_accid);
            dc->ResetFont();
        }
        // Skip the accidental and continue
        prev_pos = pos + 1;
    }
    // Print the remainder of the string, or the full string if no accid
    if (prev_pos < s.length()) {
        std::wstring substr = s.substr(prev_pos, std::wstring::npos);
        dc->DrawText(UTF16to8(substr), substr);
    }
}