diff --git a/include/vrv/devicecontextbase.h b/include/vrv/devicecontextbase.h index 3db45409c47..faa51c6d05d 100644 --- a/include/vrv/devicecontextbase.h +++ b/include/vrv/devicecontextbase.h @@ -133,6 +133,7 @@ class FontInfo { FontInfo() { m_pointSize = 0; + m_letterSpacing = 0.0; m_family = 0; // was wxFONTFAMILY_DEFAULT; m_style = FONTSTYLE_NONE; m_weight = FONTWEIGHT_NONE; @@ -147,6 +148,7 @@ class FontInfo { // accessors and modifiers for the font elements int GetPointSize() const { return m_pointSize; } + int GetLetterSpacing() const { return m_letterSpacing; } data_FONTSTYLE GetStyle() const { return m_style; } data_FONTWEIGHT GetWeight() const { return m_weight; } bool GetUnderlined() const { return m_underlined; } @@ -158,6 +160,7 @@ class FontInfo { SmuflTextFont GetSmuflFont() const { return m_smuflFont; } void SetPointSize(int pointSize) { m_pointSize = pointSize; } + void SetLetterSpacing(double letterSpacing) { m_letterSpacing = letterSpacing; } void SetStyle(data_FONTSTYLE style) { m_style = style; } void SetWeight(data_FONTWEIGHT weight) { m_weight = weight; } void SetUnderlined(bool underlined) { m_underlined = underlined; } @@ -171,6 +174,7 @@ class FontInfo { private: int m_pointSize; + int m_letterSpacing; int m_family; data_FONTSTYLE m_style; data_FONTWEIGHT m_weight; diff --git a/src/devicecontext.cpp b/src/devicecontext.cpp index c601d8d6e05..09a868e56ab 100644 --- a/src/devicecontext.cpp +++ b/src/devicecontext.cpp @@ -316,6 +316,12 @@ void DeviceContext::AddGlyphToTextExtend(const Glyph *glyph, TextExtend *extend) tmp = advX * m_fontStack.top()->GetPointSize(); advX = ceil(tmp / (double)glyph->GetUnitsPerEm()); + const int letterSpacing = m_fontStack.top()->GetLetterSpacing(); + // This is not the first letter, add a letter spacing + if ((letterSpacing != 0) && (extend->m_width > 0)) { + extend->m_width += letterSpacing; + } + // Changed because the width should only be the sum of advX // Alternatively we could add what is below 0 for the first and what is beyond the advx for the last // extend->m_width += std::max(partialWidth + x, advX); diff --git a/src/options.cpp b/src/options.cpp index fa70509cb30..08aa84dad59 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1372,7 +1372,7 @@ Options::Options() this->Register(&m_lyricTopMinMargin, "lyricTopMinMargin", &m_generalLayout); m_lyricWordSpace.SetInfo("Lyric word space", "The lyric word space length"); - m_lyricWordSpace.Init(1.20, 0.50, 10.00); + m_lyricWordSpace.Init(1.20, 0.00, 10.00); this->Register(&m_lyricWordSpace, "lyricWordSpace", &m_generalLayout); m_lyricVerseCollapse.SetInfo("Lyric verse collapse", "Collapse empty verse lines in lyrics"); diff --git a/src/svgdevicecontext.cpp b/src/svgdevicecontext.cpp index 5071cec78f9..4451b067d8c 100644 --- a/src/svgdevicecontext.cpp +++ b/src/svgdevicecontext.cpp @@ -969,6 +969,10 @@ void SvgDeviceContext::DrawText( if (m_fontStack.top()->GetPointSize() != 0) { textChild.append_attribute("font-size") = StringFormat("%dpx", m_fontStack.top()->GetPointSize()).c_str(); } + if (m_fontStack.top()->GetLetterSpacing() != 0.0) { + textChild.append_attribute("letter-spacing") + = StringFormat("%dpx", m_fontStack.top()->GetLetterSpacing()).c_str(); + } textChild.text().set(svgText.c_str()); if ((x != 0) && (y != 0) && (x != VRV_UNSET) && (y != VRV_UNSET) && (width != 0) && (height != 0) diff --git a/src/view_element.cpp b/src/view_element.cpp index 8edc887561b..c970d76b031 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -1762,6 +1762,9 @@ void View::DrawSyl(DeviceContext *dc, LayerElement *element, Layer *layer, Staff if (syl->GetStart() && syl->GetStart()->GetDrawingCueSize()) { currentFont.SetPointSize(m_doc->GetCueSize(currentFont.GetPointSize())); } + if (syl->HasLetterspacing()) { + currentFont.SetLetterSpacing(syl->GetLetterspacing() * m_doc->GetDrawingUnit(staff->m_drawingStaffSize)); + } dc->SetFont(¤tFont); TextDrawingParams params; diff --git a/src/view_text.cpp b/src/view_text.cpp index 7466cf5694b..2d2839dd935 100644 --- a/src/view_text.cpp +++ b/src/view_text.cpp @@ -127,6 +127,7 @@ void View::DrawDynamString(DeviceContext *dc, const std::u32string &str, TextDra bool isFallbackNeeded = (m_doc->GetResources()).IsSmuflFallbackNeeded(smuflStr); vrvTxt.SetSmuflWithFallback(isFallbackNeeded); vrvTxt.SetStyle(FONTSTYLE_normal); + vrvTxt.SetLetterSpacing(90); dc->SetFont(&vrvTxt); this->DrawTextString(dc, smuflStr, params); dc->ResetFont(); @@ -419,6 +420,10 @@ void View::DrawRend(DeviceContext *dc, Rend *rend, TextDrawingParams ¶ms) rendFont.SetWeight(rend->GetFontweight()); customFont = true; } + if (rend->HasLetterspacing()) { + rendFont.SetLetterSpacing(rend->GetLetterspacing() * m_doc->GetDrawingUnit(100)); + customFont = true; + } if (customFont) dc->SetFont(&rendFont);