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

Function CreateTextPathLayout

src/rendering/renderers/TextPathRender.cpp:37–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35};
36
37static TextPathLayout CreateTextPathLayout(const TextDocument* textDocument,
38 const TextPathOptions* pathOptions, Frame frame) {
39 auto firstMargin = pathOptions->firstMargin->getValueAt(frame);
40 auto lastMargin = pathOptions->lastMargin->getValueAt(frame);
41 auto inverted = pathOptions->reversedPath->getValueAt(frame);
42 auto forceAlignment = pathOptions->forceAlignment->getValueAt(frame);
43 auto perpendicularToPath = pathOptions->perpendicularToPath->getValueAt(frame);
44
45 TextPathLayout textPathLayout = {};
46 if (textDocument) {
47 // 横排框文本
48 if (textDocument->boxText && textDocument->direction != TextDirection::Vertical) {
49 textPathLayout.layoutWidth = textDocument->boxTextSize.x;
50 }
51 textPathLayout.justification = textDocument->justification;
52 }
53
54 textPathLayout.forceAlignment = forceAlignment;
55 textPathLayout.firstMargin = firstMargin;
56 textPathLayout.lastMargin = lastMargin;
57 textPathLayout.perpendicularToPath = perpendicularToPath;
58
59 auto pathData = *pathOptions->path->maskPath->getValueAt(frame);
60 if (inverted) {
61 pathData.reverse();
62 }
63 textPathLayout.pathData = pathData;
64
65 auto meas = tgfx::PathMeasure::MakeFrom(ToPath(pathData));
66 auto pathLength = meas->getLength();
67 textPathLayout.pathLength = pathLength;
68
69 return textPathLayout;
70}
71
72static float MapToPathPosition(float position, const TextPathLayout& pathLayout) {
73 if (pathLayout.forceAlignment ||

Callers 2

applyToGlyphsMethod · 0.85

Calls 4

ToPathFunction · 0.85
getValueAtMethod · 0.45
reverseMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected