18enum class IdeographicPunctuationClass
26IdeographicPunctuationClass lcl_WhichPunctuationClass(
sal_Unicode cChar)
28 if ((cChar < 0x3001 || cChar > 0x3002) && (cChar < 0x3008 || cChar > 0x3011)
29 && (cChar < 0x3014 || cChar > 0x301F) && 0xFF62 != cChar && 0xFF63 != cChar)
31 else if (0x3001 == cChar || 0x3002 == cChar)
32 return IdeographicPunctuationClass::COMMA_OR_FULLSTOP;
33 else if (0x3009 == cChar || 0x300B == cChar || 0x300D == cChar || 0x300F == cChar
34 || 0x3011 == cChar || 0x3015 == cChar || 0x3017 == cChar || 0x3019 == cChar
35 || 0x301B == cChar || 0x301E == cChar || 0x301F == cChar || 0xFF63 == cChar)
37 return IdeographicPunctuationClass::CLOSE_BRACKET;
39 return IdeographicPunctuationClass::OPEN_BRACKET;
44 tools::Long nCount = nCharWidth > nGridWidth ? (nCharWidth - 1) / nGridWidth + 1 : 1;
45 return nCount * nGridWidth;
56 switch (lcl_WhichPunctuationClass(cChar))
60 nOffset = (nMinWidth - nCharWidth) / 2;
62 case IdeographicPunctuationClass::OPEN_BRACKET:
64 nOffset = nMinWidth - nCharWidth;
80 sal_Int32 nLast = 0, nIdx = 0;
84 nRight = rKernArray[nLast];
86 while (nIdx < nLen && rKernArray[nIdx] == rKernArray[nLast])
92 return (nX - nLeft < nRight - nX) ? nLast : nIdx;
97 }
while (nIdx < nLen);
104 assert(nStt + nLen <= sal_Int32(aText.size()));
105 assert(nLen <= sal_Int32(rKernArray.
size()));
118 const tools::Long nHalfSpace = bNoHalfSpace ? 0 : nSpaceAdd / 2;
119 const tools::Long nOtherHalf = nSpaceAdd - nHalfSpace;
123 if (nSpaceAdd && (cChPrev ==
CH_BLANK))
124 nSpaceSum = nHalfSpace;
126 sal_Int32 nPrevIdx = 0;
128 for (sal_Int32
i = 1;
i < nLen; ++
i, nKernSum += nKern)
131 while (
i < nLen && rKernArray[
i] == rKernArray[nPrevIdx])
143 nSpaceSum += nOtherHalf;
149 nSpaceSum += nSpaceAdd;
151 nSpaceSum += nHalfSpace;
155 rKernArray.
adjust(nPrevIdx, nKernSum + nSpaceSum);
160 if (bNoHalfSpace &&
i + 1 == nLen && nCh ==
CH_BLANK)
161 rKernArray.
adjust(nPrevIdx, -nSpaceAdd);
169 while (nPrevIdx < nLen)
171 rKernArray.
adjust(nPrevIdx, nKernSum + nSpaceSum);
177 sal_Int32 nLen,
tools::Long nGridWidth,
bool bForceLeft)
179 assert(nStt + nLen <= sal_Int32(aText.size()));
180 assert(nLen <= sal_Int32(rKernArray.
size()));
183 tools::Long nMinWidth = lcl_MinGridWidth(nGridWidth, nCharWidth);
184 tools::Long nDelta = lcl_OffsetFromGridEdge(nMinWidth, nCharWidth, aText[nStt], bForceLeft);
189 for (sal_Int32
i = 1;
i < nLen; ++
i)
191 if (rKernArray[
i] == rKernArray[nLast])
194 nCharWidth = rKernArray[
i] - rKernArray[nLast];
195 nMinWidth = lcl_MinGridWidth(nGridWidth, nCharWidth);
197 = nEdge + lcl_OffsetFromGridEdge(nMinWidth, nCharWidth, aText[nStt +
i], bForceLeft);
202 rKernArray.set(nLast, nX);
209 rKernArray.
set(nLast, nEdge);
219 assert(nLen <= sal_Int32(rKernArray.
size()));
222 tools::Long nEdge = lcl_MinGridWidth(nGridWidth, nCharWidth + nKern) + nSpace;
226 for (sal_Int32
i = 1;
i < nLen; ++
i)
228 if (rKernArray[
i] == rKernArray[nLast])
231 nCharWidth = rKernArray[
i] - rKernArray[nLast];
232 tools::Long nMinWidth = lcl_MinGridWidth(nGridWidth, nCharWidth + nKern);
235 rKernArray.set(nLast, nEdge);
239 nEdge += nMinWidth + nSpace;
244 rKernArray.
set(nLast, nEdge);
void set(size_t nIndex, sal_Int32 nValue)
void adjust(size_t nIndex, sal_Int32 nDiff)
tools::Long SnapToGrid(KernArray &rKernArray, std::u16string_view aText, sal_Int32 nStt, sal_Int32 nLen, tools::Long nGridWidth, bool bForceLeft)
Snap ideographs to text grids: a) Ideographic open brackets are aligned to the rightmost edge of span...
void SnapToGridEdge(KernArray &rKernArray, sal_Int32 nLen, tools::Long nGridWidth, tools::Long nSpace, tools::Long nKern)
Snap ideographs to text grids edge ( used when snap to char is off ): space will be distributed ( in ...
void SpaceDistribution(KernArray &rKernArray, std::u16string_view aText, sal_Int32 nStt, sal_Int32 nLen, tools::Long nSpaceAdd, tools::Long nKern, bool bNoHalfSpace)
Distribute space between words and letters.
sal_Int32 GetModelPosition(const KernArray &rKernArray, sal_Int32 nLen, tools::Long nX)
Get model position base on given kern array.
const sal_Unicode CH_BLANK