Class CharacterFormat
Sparse run-level formatting (ECMA-376 Part 1 §17.3.2 w:rPr). Every property is nullable: null means "not specified here" and the value comes from the style chain. The DOM never flattens formatting at parse time — editing and re-saving depend on the distinction between explicit and inherited values.
public sealed class CharacterFormat : UnknownXmlHost
- Inheritance
-
CharacterFormat
- Inherited Members
Remarks
The toggle properties (§17.7.3: b, bCs, i, iCs, caps, smallCaps, strike, dstrike, outline, shadow, emboss, imprint, vanish) get XOR semantics in the style resolver; here they are stored exactly as written. All lengths are twips.
Constructors
Properties
- Bold
Gets or sets bold for non-complex scripts (w:b, toggle), or null.
- BoldComplexScript
Gets or sets bold for complex scripts (w:bCs, toggle), or null.
- Border
Gets or sets the run border (w:bdr), or null.
- Caps
Gets or sets display-as-capitals (w:caps, toggle), or null.
- CharacterSpacing
Gets or sets expanded/condensed inter-character spacing (w:spacing, signed twips), or null.
- Color
Gets or sets the text color (w:color, literal or theme reference), or null.
- DoubleStrike
Gets or sets double strikethrough (w:dstrike, toggle), or null.
- Emboss
Gets or sets embossed text (w:emboss, toggle), or null.
- FontAscii
Gets or sets the font for ASCII characters (w:rFonts w:ascii), or null.
- FontAsciiTheme
Gets or sets the theme font for ASCII characters (w:rFonts w:asciiTheme), or null. Takes precedence over FontAscii.
- FontComplexScript
Gets or sets the font for complex-script characters (w:rFonts w:cs), or null.
- FontComplexScriptTheme
Gets or sets the theme font for complex-script characters (w:rFonts w:cstheme), or null.
- FontEastAsia
Gets or sets the font for East Asian characters (w:rFonts w:eastAsia), or null.
- FontEastAsiaTheme
Gets or sets the theme font for East Asian characters (w:rFonts w:eastAsiaTheme), or null.
- FontHighAnsi
Gets or sets the font for high-ANSI characters (w:rFonts w:hAnsi), or null.
- FontHighAnsiTheme
Gets or sets the theme font for high-ANSI characters (w:rFonts w:hAnsiTheme), or null.
- FontHint
Gets or sets the ambiguous-character classification hint (w:rFonts w:hint), or null.
- FontSize
Gets or sets the font size for non-complex scripts (w:sz half-points, stored in twips), or null.
- FontSizeComplexScript
Gets or sets the font size for complex scripts (w:szCs half-points, stored in twips), or null.
- FormatChange
Gets or sets the tracked formatting change (w:rPrChange), or null. The properties above stay the run's current formatting; the annotation carries what preceded it.
Deliberately excluded from ContentEquals(CharacterFormat?) and GetContentHash(), for the same reason unknown-XML islands are: it does not affect how the run resolves, so two bags carrying different change records still share a resolved format and must still share the resolver's memo entry. Code that needs to tell them apart compares the annotations directly.
- Highlight
Gets or sets the highlight color (w:highlight), or null.
- Imprint
Gets or sets imprinted text (w:imprint, toggle), or null.
- Italic
Gets or sets italic for non-complex scripts (w:i, toggle), or null.
- ItalicComplexScript
Gets or sets italic for complex scripts (w:iCs, toggle), or null.
- Kerning
Gets or sets the minimum font size at which kerning applies (w:kern half-points, stored in twips; zero disables), or null.
- Language
Gets or sets the run languages (w:lang), or null.
- NoProof
Gets or sets the do-not-proof flag (w:noProof), or null.
- Outline
Gets or sets outline text (w:outline, toggle), or null.
- Position
Gets or sets baseline offset (w:position half-points, stored in signed twips), or null.
- RightToLeft
Gets or sets right-to-left run direction (w:rtl), or null.
- Scale
Gets or sets horizontal character scaling as a percentage (w:w, 100 = none), or null.
- Shading
Gets or sets run shading (w:shd), or null.
- Shadow
Gets or sets shadowed text (w:shadow, toggle), or null.
- SmallCaps
Gets or sets small capitals (w:smallCaps, toggle), or null.
- Strike
Gets or sets single strikethrough (w:strike, toggle), or null.
- StyleId
Gets or sets the referenced character style id (w:rStyle), or null.
- Underline
Gets or sets the underline pattern (w:u w:val), or null.
- UnderlineColor
Gets or sets the underline color (w:u w:color/theme attributes), or null.
- Vanish
Gets or sets hidden text (w:vanish, toggle), or null.
- VerticalAlignment
Gets or sets sub/superscript positioning (w:vertAlign), or null.
Methods
- Clone()
Creates a deep copy, including preserved unknown-XML islands.
- ContentEquals(CharacterFormat?)
Determines whether another bag specifies exactly the same values. Unknown-XML islands are ignored: two bags that resolve identically compare equal. Used by the style resolver's memoization and by future compare/merge features.
- GetContentHash()
Computes a hash over the specified values, consistent with ContentEquals(CharacterFormat?). Allocation-free.
- OverlayOnto(CharacterFormat, bool)
Copies every specified value onto
target, leaving the target's other values untouched. This is plain last-writer-wins layering; the style resolver applies toggle XOR semantics separately.