| 35 | }; |
| 36 | |
| 37 | static 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 | |
| 72 | static float MapToPathPosition(float position, const TextPathLayout& pathLayout) { |
| 73 | if (pathLayout.forceAlignment || |
no test coverage detected