首页/ 接口索引/ Text 文本对象

shape.Text.Story.CharSpacing

字距,单位是百分比。代码里 180 = 180% 的疏排,50 = 收紧。中文标题加宽靠它。

签名

shape.Text.Story.CharSpacing

说明

字距,单位是百分比。代码里 180 = 180% 的疏排,50 = 收紧。中文标题加宽靠它。

Python 示例(可直接运行)

依赖 pywin32。示例假定 app / doc / page / layer 已就绪。 见「连接与初始化」
Python
shape = app.ActiveSelectionRange(1)
story = shape.Text.Story

story.CharSpacing = 180             # 字距,单位是百分比:180 = 180%
print("字距:", story.CharSpacing)

# 常用套路:标题字少就疏排(180),字多就收紧(50)
n = len(shape.Text.Contents.strip())
story.CharSpacing = 180 if n <= 10 else 50
print("按字数自动调整后:", story.CharSpacing)

关于本类:Text 文本对象

文字接口分两层:Shape.Text 是入口,真正读写字体字号要下到 Story.Characters.All。

同类其他接口