创建文本单元格 Args: text: 文字内容 x, y: 左上角坐标 width, height: 尺寸 font_size: 字号(pt) is_latex: 是否为公式 rotation: 旋转角度 font_weight: 字重 ("normal", "bold") font_style: 样式 ("normal", "italic")
(
self, text: str, x: float, y: float, width: float, height: float,
font_size: float, is_latex: bool = False, rotation: float = 0.0,
font_weight: Optional[str] = None, font_style: Optional[str] = None,
font_color: Optional[str] = None, font_family: Optional[str] = None,
is_bold: bool = False, is_italic: bool = False
)
| 233 | geometry.set("as", "geometry") |
| 234 | |
| 235 | def create_text_cell( |
| 236 | self, text: str, x: float, y: float, width: float, height: float, |
| 237 | font_size: float, is_latex: bool = False, rotation: float = 0.0, |
| 238 | font_weight: Optional[str] = None, font_style: Optional[str] = None, |
| 239 | font_color: Optional[str] = None, font_family: Optional[str] = None, |
| 240 | is_bold: bool = False, is_italic: bool = False |
| 241 | ) -> TextCellData: |
| 242 | """ |
| 243 | 创建文本单元格 |
| 244 | |
| 245 | Args: |
| 246 | text: 文字内容 |
| 247 | x, y: 左上角坐标 |
| 248 | width, height: 尺寸 |
| 249 | font_size: 字号(pt) |
| 250 | is_latex: 是否为公式 |
| 251 | rotation: 旋转角度 |
| 252 | font_weight: 字重 ("normal", "bold") |
| 253 | font_style: 样式 ("normal", "italic") |
| 254 | font_color: 颜色 (十六进制,如 "#1d1d1d") |
| 255 | font_family: 字体名称 (如 "Arial", "Times New Roman") |
| 256 | is_bold: 是否加粗(与 font_weight="bold" 等效) |
| 257 | is_italic: 是否斜体(与 font_style="italic" 等效) |
| 258 | |
| 259 | Returns: |
| 260 | TextCellData 对象 |
| 261 | """ |
| 262 | # 兼容 is_bold/is_italic 参数 |
| 263 | if is_bold and font_weight is None: |
| 264 | font_weight = "bold" |
| 265 | if is_italic and font_style is None: |
| 266 | font_style = "italic" |
| 267 | |
| 268 | # 默认字体 |
| 269 | if font_family is None: |
| 270 | font_family = "Arial" |
| 271 | |
| 272 | return TextCellData( |
| 273 | cell_id=self._get_next_id(), |
| 274 | text=text, x=x, y=y, width=width, height=height, |
| 275 | font_size=font_size, is_latex=is_latex, rotation=rotation, |
| 276 | font_weight=font_weight, font_style=font_style, |
| 277 | font_color=font_color, font_family=font_family |
| 278 | ) |
| 279 | |
| 280 | def save_to_file(self, cells: list[TextCellData], output_path: str) -> None: |
| 281 | """ |
no test coverage detected