(self, ctx: PipelineContext)
| 234 | |
| 235 | class MultiRichTextGenerator(Generator): |
| 236 | def process(self, ctx: PipelineContext): |
| 237 | text_segments: List[TextSegment] = TextSegment.from_dicts(ctx.get("text_segments")) |
| 238 | text_alignment = ctx.get("text_alignment") |
| 239 | text_spacing = ctx.getint("text_spacing") |
| 240 | height = ctx.get("height", 100) |
| 241 | |
| 242 | text_images = [] |
| 243 | for segment in text_segments: |
| 244 | segment.height = height |
| 245 | context = PipelineContext(asdict(segment)) |
| 246 | context.set("save_buffer", False) |
| 247 | RichTextGenerator().process(context) |
| 248 | text_images.extend(context.get_buffer()) |
| 249 | |
| 250 | # 使用 start_process 替代直接调用 ConcatMerger,解耦对 Merger 的直接依赖 |
| 251 | from processor.core import start_process |
| 252 | pipeline = [ |
| 253 | { |
| 254 | "processor_name": "concat", |
| 255 | "alignment": text_alignment, |
| 256 | "spacing": text_spacing, |
| 257 | "save_buffer": False, |
| 258 | } |
| 259 | ] |
| 260 | result = start_process(pipeline, initial_buffer=text_images) |
| 261 | |
| 262 | ctx.update_buffer([result]).save_buffer(self.name()).success() |
| 263 | |
| 264 | def name(self) -> str: |
| 265 | return "multi_rich_text" |
nothing calls this directly
no test coverage detected