TextStyle — Aspose.Note FOSS for Python API Reference
Sınıf: TextStyle
Enumerations: aspose.note Enumerations: from aspose.note import TextStyle Enumerations: Node
TextStyle tek bir karakter için tam karakter bazlı biçimlendirme öznitelikleri kümesini taşır TextRun. Bu, şu aracılığıyla sunulur TextRun.Style. Tüm boolean bayraklar varsayılan olarak False; tüm isteğe bağlı alanlar varsayılan olarak None.
Enumerations
Tüm özellikler Okunabilir/Yazılabilir.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
FontName | `str | None` | None |
FontSize | `float | None` | None |
FontColor | `int | None` | None |
Highlight | `int | None` | None |
Stil Bayrakları
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
Bold | bool | False | Kalın ağırlık |
Italic | bool | False | Enumerations |
Underline | bool | False | Enumerations |
Strikethrough | bool | False | Enumerations |
Superscript | bool | False | Üst simge taban çizgisi |
Subscript | bool | False | Alt simge taban çizgisi |
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
Language | `int | None` | None |
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
IsHyperlink | bool | False | True bu çalıştırma tıklanabilir bir bağlantı olduğunda. |
HyperlinkAddress | `str | None` | None |
ARGB Renk Kodlaması
FontColor ve HighlightColor paketlenmiş 32-bit ARGB tamsayıları olarak depolanır, MS-ONE ikili biçimiyle eşleşir. Bunları çözmek için:
argb = run.Style.FontColor
if argb is not None:
a = (argb >> 24) & 0xFF
r = (argb >> 16) & 0xFF
g = (argb >> 8) & 0xFF
b = argb & 0xFF
print(f"RGBA({r}, {g}, {b}, {a})")Kullanım Örneği
Her çalıştırma için biçimlendirme niteliklerini yazdır
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
for run in rt.TextRuns:
s = run.Style
parts = []
if s.IsBold: parts.append("bold")
if s.IsItalic: parts.append("italic")
if s.IsUnderline: parts.append("underline")
if s.IsStrikethrough: parts.append("strikethrough")
if s.FontName: parts.append(f"font={s.FontName!r}")
if s.FontSize: parts.append(f"size={s.FontSize}pt")
if s.IsHyperlink: parts.append(f"href={s.HyperlinkAddress!r}")
label = ", ".join(parts) or "plain"
print(f" [{label}] {run.Text!r}")Benzersiz stillere sahip tüm segmentleri topla
from aspose.note import Document, RichText
doc = Document("MyNotes.one")
bold_runs = []
for rt in doc.GetChildNodes(RichText):
for run in rt.TextRuns:
if run.Style.IsBold and run.Text.strip():
bold_runs.append(run.Text)
print(f"Bold segments ({len(bold_runs)}):", bold_runs)None-Güvenliği
Enumerations None-türündeki özellikler olabilir None özellik kaynak dosyada yoksa. Her zaman şununla koruyun if s.FontColor is not None: renk değerlerini bit kaydırmadan önce.
Ayrıca Bakınız
- TextRun: bir … sahip olan koşu
TextStyle - RichText: üst metin bloğu
- Enumerations: temel sınıf
- Geliştirici Kılavuzu