Skip to content

Commit

Permalink
Fix: 文字の間隔の適用値が今までと異なる
Browse files Browse the repository at this point in the history
[patchunicode:#1003] Contributed by Moca
文字間隔回りがおかしいのを修正します。
1. プロポーショナル版で全角の文字間隔が2倍になるように
2. CTextMetrics::CalcTextWidth2/3の文字間隔の引数がずれてたバグの修正
3. CLayoutMgr::getIndentOffsetの文字幅にさらに文字間隔が足されていたバグの修正

git-svn-id: https://svn.code.sf.net/p/sakura-editor/code/sakura/trunk2@4046 f7ce1907-e4c7-47ca-9f76-12c87ed2c91c
  • Loading branch information
syat committed Oct 11, 2015
1 parent 7247748 commit 7ce12cc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
6 changes: 5 additions & 1 deletion sakura_core/doc/layout/CLayoutMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ class CLayoutMgr : public CProgressSubject
BOOL CalculateTextWidth( BOOL bCalLineLen = TRUE, CLayoutInt nStart = CLayoutInt(-1), CLayoutInt nEnd = CLayoutInt(-1) ); /* テキスト最大幅を算出する */ // 2009.08.28 nasukoji
void ClearLayoutLineWidth( void ); /* 各行のレイアウト行長の記憶をクリアする */ // 2009.08.28 nasukoji
CLayoutXInt GetLayoutXOfChar( const wchar_t* pData, int nDataLen, int i ) const {
return CNativeW::GetColmOfChar( pData, nDataLen, i ) + m_nSpacing;
CLayoutXInt nSpace = CLayoutXInt(0);
if( m_nSpacing ){
nSpace = CLayoutXInt(CNativeW::GetKetaOfChar(pData, nDataLen, i)) * m_nSpacing;
}
return CNativeW::GetColmOfChar( pData, nDataLen, i ) + nSpace;
}
CLayoutXInt GetLayoutXOfChar( const CStringRef& str, int i ) const {
return GetLayoutXOfChar(str.GetPtr(), str.GetLength(), i);
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/doc/layout/CLayoutMgr_New.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ CLayoutInt CLayoutMgr::getIndentOffset_Tx2x( CLayout* pLayoutPrev )
}
// 2010.07.06 Moca TAB=8などの場合に折り返すと無限ループする不具合の修正. 6固定を m_nTabSpace + 2に変更
if ( GetMaxLineLayout() - nIpos < GetTabSpace() + 2
* (m_nCharLayoutXPerKeta + m_nSpacing)
* (m_nCharLayoutXPerKeta)
){
nIpos = t_max(CLayoutInt(0), GetMaxLineKetas() - (GetTabSpace() + 2)); // 2013.05.12 Chg:0だったのを最大幅に変更
}
Expand Down Expand Up @@ -263,7 +263,7 @@ CLayoutInt CLayoutMgr::getIndentOffset_LeftSpace( CLayout* pLayoutPrev )
}
// 2010.07.06 Moca TAB=8などの場合に折り返すと無限ループする不具合の修正. 6固定を m_nTabSpace + 2に変更
if ( GetMaxLineLayout() - nIpos < GetTabSpace() + 2
* (m_nCharLayoutXPerKeta + m_nSpacing)
* (m_nCharLayoutXPerKeta)
){
nIpos = t_max(CLayoutInt(0), GetMaxLineKetas() - (GetTabSpace() + 2)); // 2013.05.12 Chg:0だったのを最大幅に変更
}
Expand Down
7 changes: 4 additions & 3 deletions sakura_core/mem/CMemoryIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ class CMemoryIterator
} else if (m_pLine[m_nIndex] == L',' && m_tsvInfo.m_nTsvMode == TSV_MODE_CSV){
m_nColumn_Delta = m_tsvInfo.GetActualTabLength(m_nColumn, m_tsvInfo.m_nMaxCharLayoutX);
}else{
m_nColumn_Delta = CNativeW::GetColmOfChar( m_pLine, m_nLineLen, m_nIndex )
+ CLayoutInt(m_nSpacing)
;
m_nColumn_Delta = CNativeW::GetColmOfChar( m_pLine, m_nLineLen, m_nIndex );
if( m_nSpacing ){
m_nColumn_Delta += CLayoutXInt(CNativeW::GetKetaOfChar(m_pLine, m_nLineLen, m_nIndex) * m_nSpacing);
}
// if( 0 == m_nColumn_Delta ) // 削除 サロゲートペア対策 2008/7/5 Uchi
// m_nColumn_Delta = CLayoutInt(1);
}
Expand Down
20 changes: 17 additions & 3 deletions sakura_core/view/CTextMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,29 @@ const int* CTextMetrics::GenerateDxArray(
}else
if(IsUTF16High(*x)){
if(i+1 < nLength && IsUTF16Low(x[1])){
*p = WCODE::CalcPxWidthByFont2(x) + nCharSpacing;
int n = 0;
if(nCharSpacing){
n = CNativeW::GetKetaOfChar(pText, nLength, i) * nCharSpacing;
}
*p = WCODE::CalcPxWidthByFont2(x) + n;
p++;
x++;
i++;
*p = 0;
}else{
*p = WCODE::CalcPxWidthByFont(*x) + nCharSpacing;
int n = 0;
if(nCharSpacing){
n = CNativeW::GetKetaOfChar(pText, nLength, i) * nCharSpacing;
}
*p = WCODE::CalcPxWidthByFont(*x) + n;
nLayoutCnt += *p;
}
}else{
*p = WCODE::CalcPxWidthByFont(*x) + nCharSpacing;
int n = 0;
if(nCharSpacing){
n = CNativeW::GetKetaOfChar(pText, nLength, i) * nCharSpacing;
}
*p = WCODE::CalcPxWidthByFont(*x) + n;
nLayoutCnt += *p;
}
}
Expand Down Expand Up @@ -235,6 +247,8 @@ int CTextMetrics::CalcTextWidth2(
pText,
nLength,
nHankakuDx,
8,
0,
nCharSpacing
);

Expand Down

0 comments on commit 7ce12cc

Please sign in to comment.