In Word, bold is None — does that actually mean not bold?
Direct formatting's None means "not set", not False. This only checks direct formatting and the explicit character style chain; when no value is found it returns None, leaving paragraph styles, document defaults, and OOXML toggle rules to be resolved further. It should not be called a complete effective-style calculator.
Key points of this article
- Run.bold being None means it is not set directly; it does not mean the text is not bold, so the style chain must be searched upward.
- The sample code only checks direct formatting and the explicit character style chain; it is not a complete effective-style calculator.
- When a style name is a Chinese alias, the code raises AttributeError, and this should be blocked and handled as an error.
- When both the direct formatting and the style's bold are None, settings such as docDefaults need manual review.
- This method only applies to standard .docx files; for .doc converted files, or files that are protected or modified by macros, the results may differ significantly from the visual presentation.
In Word, if bold is None, does it count as bold? One-sentence conclusion.
If you use python-docx to batch-check the formatting of Word documents, you have probably run into this confusion: run.bold returns None. Is it bold, not bold, or something else? The problem comes up in format reviews, batch cleanup, and layout checks before translation, and a wrong judgment makes the formatting conclusions unreliable.
This article is for developers and documentation engineers who need to write their own scripts to parse .docx styles. After reading it, you will understand why None is not equal to False, learn how to use a recursive function to trace back along the style chain, and know which judgments can be trusted and which must be handed over to human review.
Does a Word run with bold set to None count as bold? One-sentence conclusion
run.bold indicates to None that bold is not set in direct formatting, which does not mean it is not bold; the lookup should continue upward through paragraph styles, document defaults, and so on. The code in this article only checks direct formatting and the explicit character style chain, and is not a complete effective-style calculator.
| Your situation | Recommended Practices | Cause |
|---|---|---|
run.bold returns None | Continue searching along the character style chain; do not treat it directly as False | None indicates "not set," not negation. |
run.bold returns False | Treat as explicit removal of bold | Explicit override corresponding to <w:b w:val="0"/> |
| No value was found anywhere in the style chain. | Marked as requiring manual review | It may involve unresolved settings such as docDefaults or theme fonts. |
| Style name is the Chinese alias | Block and raise an error; do not handle it silently. | python-docx has unreliable support for localized style names |
Complex list items, or files that have been converted, protected, or modified by macros: .doc | Subject to manual review | The parsing results may not match the visual presentation. |
Which problem does this article solve first?
Direct formatting "None" means unset, not "False". This only checks direct formatting and the explicit character style chain; when no value is found it returns "None", leaving paragraph styles, document defaults, and OOXML toggle rules to be resolved further, and it cannot be called a complete effective-style calculator.
Self-contained Synthetic Example
Dependencies are listed in the import list.
from docx import Document
from docx.enum.style import WD_STYLE_TYPE
def partial_bold(run):
if run.bold is not None:
return run.bold
style, seen = run.style, set()
while style is not None and style.style_id not in seen:
seen.add(style.style_id)
if style.font.bold is not None:
return style.font.bold
style = style.base_style
return None
doc = Document()
style = doc.styles.add_style("DemoBold", WD_STYLE_TYPE.CHARACTER)
style.font.bold = True
run = doc.add_paragraph().add_run("Example")
run.style = style
assert partial_bold(run) is True
run.bold = False
assert partial_bold(run) is False
plain = doc.add_paragraph().add_run("Plain")
assert partial_bold(plain) is None
Understanding the Three-State Logic of Style Inheritance
In Word, the bold property has three states, each of which should be understood separately:
- Explicit bold: In the interface, select the text and click the bold button; the XML writes
<w:b/>, andrun.boldisTrue. - Explicit unbold: Deliberately cancel a bold style effect that would otherwise apply; the XML writes
<w:b w:val="0"/>, andrun.boldisFalse. - Not set: The text simply sits in the paragraph without any direct bold tag; whether it is bold depends on the associated style definition, and
run.boldisNone.
None means "please look up," not "no."
Why the Style Chain Needs to Be Traced Back
This design is intended to reduce file size and keep formatting consistent. As the official documentation states, built-in styles are not even written into the file (styles.xml) until they are used; they exist inside the Word application as "Latent Styles." Therefore, the code must be able to trace back through the style chain, rather than relying solely on the properties of the Run object itself.
To determine safely whether text is really bold, we need to write a recursive function that traverses the style inheritance chain. The following code demonstrates the three-state judgment logic and has been checked with synthetic samples. A real production environment would still need to handle circular reference protection, namespace resolution, and more property types.
Acceptance Criteria and Boundaries for Manual Review
Automated parsing cannot perfectly replicate Word's rendering engine. When processing documents in bulk, establish a clear acceptance matrix that distinguishes which cases can be trusted to code and which must be handed off to manual review.
| Observe the phenomenon | Code return value | Actual rendering | Processing decision | Remarks |
|---|---|---|---|---|
| Run.bold=None, Style.bold=True | True | Bold | Automatically approved ✅ | Standard style inheritance scenario |
| Run.bold=False, Style.bold=True | False | General | Automatically approved ✅ | Explicit override; the code logic is correct. |
| Run.bold=None, Style.bold=None | False | Bold | ⚠️ Requires manual review | It may have missed the docDefaults or theme font settings |
| Style name is the Chinese alias | AttributeError | - | Blocked and reported an error | python-docx has unreliable support for localized style names |
| Text in complex list items | True/False | Not sure | ⚠️ Requires manual review | List style and paragraph style interact in a very complex way |
Out of Scope
This parsing logic applies only to standard .docx-format files. For files converted from .doc, protected documents, or documents whose formatting is dynamically modified by macros, the parsed results may differ significantly from the visual presentation. In addition, the code demonstrates attribute extraction logic rather than end-to-end layout restoration. If the goal is to reproduce the layout precisely, relying on attribute values alone is not sufficient.
📊 Core Comparison
| Status | Direct format notation | run.bold Return | Meaning |
|---|---|---|---|
| Explicit bold | <w:b/> | True | Bold directly |
| Explicit cancellation | <w:b w:val="0"/> | False | Overriding bold in styles |
| Not set | No bold tags | None | Continue searching along the style chain |
🎯 Which Approach Suits You?
If you need to determine whether text is bold
Trace back along the style chain, and do not read only run.bold.
If you only need to read direct formatting
True and False can be taken at face value, while None requires further judgment.
If you need to reproduce the layout exactly
Attribute extraction is only the starting point; you also need to combine it with the rendered output and manual inspection.
If you are working with .doc, protected, or macro-modified files
Handle them first through the manual review process.
❓ Frequently Asked Questions (FAQ)
1. Does run.bold being None mean that bold is not applied?
No. None means that no direct formatting is set here, so the lookup should continue along the style chain.
2. Can this code fully reproduce Word's layout?
No. The code demonstrates the logic of attribute extraction, not end-to-end layout reproduction.
3. What to do when encountering Chinese style names?
python-docx has unreliable support for localized style names, so the decision in the acceptance matrix is to block and raise an error.
4. What should be done before processing important files?
Keep the original, and review the results against the boundaries and acceptance items described in the text.
References and Further Reading
Using this checklist for document translation
Word translation tends to mix up content issues with formatting issues. Leaving style, header and table checks to the delivery checklist lets reviewers know where to look for them.
OmniDoc's document translation supports formats such as PDF, Word, PPT, and Excel. Scanned documents have their text recognized first, tables are translated cell by cell with rows and columns preserved, and PDFs produce two versions: a bilingual side-by-side version and a translation-only version. Paid translation also lets you upload a glossary and enable context-aware translation.
📝 Summary
None means "not set", not "no". When judging bold text, continue tracing back along the style chain. When a case cannot be determined, hand it over to manual review according to the acceptance matrix.
Try it now: upload a document and start translating right away, with the original layout preserved.


