| 193 | } |
| 194 | |
| 195 | void TextPathRender::applyForceAlignmentToGlyphs(const std::vector<std::vector<GlyphHandle>>& lines, |
| 196 | Frame layerFrame) { |
| 197 | if (pathOptions == nullptr || textDocument == nullptr) { |
| 198 | return; |
| 199 | } |
| 200 | |
| 201 | auto textPathLayout = CreateTextPathLayout(textDocument, pathOptions, layerFrame); |
| 202 | if (!textPathLayout.forceAlignment) { |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | std::vector<std::vector<GlyphHandle>> glyphLines; |
| 207 | for (const auto& line : lines) { |
| 208 | float spacing = CalculateForceAlignmentLetterSpacing(textPathLayout, line); |
| 209 | float posX = 0; |
| 210 | for (const auto& glyph : line) { |
| 211 | auto matrix = glyph->getMatrix(); |
| 212 | // 分散对齐会无视排版的段落属性,如左对齐等,需要重新排版,因此这里重新生成 x 轴坐标 |
| 213 | matrix.setTranslateX(posX); |
| 214 | glyph->setMatrix(matrix); |
| 215 | posX += glyph->getAdvance() + spacing; |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void TextPathRender::applyToGlyphs(const std::vector<std::vector<GlyphHandle>>& glyphLines, |
| 221 | Frame layerFrame) { |
no test coverage detected