MCPcopy Create free account
hub / github.com/Tencent/libpag / applyForceAlignmentToGlyphs

Method applyForceAlignmentToGlyphs

src/rendering/renderers/TextPathRender.cpp:195–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void 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
220void TextPathRender::applyToGlyphs(const std::vector<std::vector<GlyphHandle>>& glyphLines,
221 Frame layerFrame) {

Callers 1

createContentMethod · 0.80

Calls 6

CreateTextPathLayoutFunction · 0.85
setTranslateXMethod · 0.80
getAdvanceMethod · 0.80
getMatrixMethod · 0.45
setMatrixMethod · 0.45

Tested by

no test coverage detected