| Previous | Next |
| D2DERR_TARGET_NOT_GDI_COMPATIBLE | D2DERR_TEXT_RENDERER_NOT_RELEASED |
D2DERR_TEXT_EFFECT_IS_WRONG_TYPE
D2DERR_TEXT_EFFECT_IS_WRONG_TYPE identifies a failure in Direct2D and DirectWrite text callback contracts. A drawing effect attached to a text range is not of the type expected by the Direct2D text renderer. Investigation of D2DERR_TEXT_EFFECT_IS_WRONG_TYPE should preserve the original object generation before cleanup, retry, or fallback creates a secondary result.
Facts worth preserving
| Record | Why it matters here |
|---|---|
| Text range and effect object identity | For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, recording text range and effect object identity separates the Direct2D and DirectWrite text callback contracts boundary from a later wrapper symptom. |
| COM interfaces supported by the effect object | In D2DERR_TEXT_EFFECT_IS_WRONG_TYPE diagnostics, recording COM interfaces supported by the effect object ties the HRESULT to the Direct2D and DirectWrite text callback contracts boundary rather than to the final visible failure. |
| Custom IDWriteTextRenderer implementation | Comparing custom IDWriteTextRenderer implementation shows whether D2DERR_TEXT_EFFECT_IS_WRONG_TYPE follows input, object state, or environment. |
| DrawText or DrawTextLayout call and callback sequence | Preserving DrawText or DrawTextLayout call and callback sequence provides the evidence needed to test this distinction: iNVALID_PROPERTY concerns Direct2D effect metadata; this code concerns DirectWrite text drawing effects passed through rendering callbacks. |
Subsystem boundary
Text rendering crosses IDWriteTextLayout, drawing effects, renderer callbacks, COM reference counting, font resources, and optional glyph-image formats in the D2DERR_TEXT_EFFECT_IS_WRONG_TYPE path. For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, a drawing-effect type mismatch, retained callback renderer, and invalid glyph image are separate failures even though all may occur during one DrawTextLayout call.
For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, inspect the following boundary: iDWriteTextLayout drawing-effect objects and renderer interpretation.
Isolation procedure
When D2DERR_TEXT_EFFECT_IS_WRONG_TYPE is returned, render plain outline text with no drawing effect, then add the effect object, custom renderer, and requested glyph image format one at a time. Track AddRef and Release around callbacks and retain the exact font face and glyph index in the D2DERR_TEXT_EFFECT_IS_WRONG_TYPE path.
- Use a known brush as the drawing effect in the D2DERR_TEXT_EFFECT_IS_WRONG_TYPE path.
- For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, query the expected interface before rendering.
- When D2DERR_TEXT_EFFECT_IS_WRONG_TYPE is returned, remove effects from ranges to establish baseline text rendering.
- Test custom renderer and Direct2D default renderer separately in the D2DERR_TEXT_EFFECT_IS_WRONG_TYPE path.
Do not hide the original condition
INVALID_PROPERTY concerns Direct2D effect metadata; this code concerns DirectWrite text drawing effects passed through rendering callbacks. For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, do not respond with a universal render-target recreation loop unless the returned status specifically documents device-loss recovery; graph, property, numeric, lifetime, and print-state errors require correcting their contract.
What each result would imply
| Test | Interpretation | Hold constant |
|---|---|---|
| Same environment, reduced input | If D2DERR_TEXT_EFFECT_IS_WRONG_TYPE disappears with a smaller faithful case, complexity within Direct2D and DirectWrite text callback contracts is implicated. | For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, keep text range and effect object identity fixed while simplifying custom IDWriteTextRenderer implementation. |
| Same input, fresh object generation | If D2DERR_TEXT_EFFECT_IS_WRONG_TYPE changes after rebuilding state, examine ownership across the caller’s object graph, custom effect or renderer, Direct2D validation layer, backing device, and deferred draw boundary. | For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, place COM interfaces supported by the effect object on the timeline of the last successful transition. |
| Same operation on a controlled second path | If D2DERR_TEXT_EFFECT_IS_WRONG_TYPE follows one environment, the failure is not explained by source data alone. | For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, compare adapter and feature level, factory and device generations, target identity, debug-layer output, and thread ownership while preserving DrawText or DrawTextLayout call and callback sequence. |
Verification after repair
A correction for D2DERR_TEXT_EFFECT_IS_WRONG_TYPE should let the operation at the Direct2D and DirectWrite text callback contracts boundary complete repeatedly under the original supported conditions. Repeat the control that begins with “Use a known brush as the drawing effect” and confirm that the following lifecycle step also succeeds. For D2DERR_TEXT_EFFECT_IS_WRONG_TYPE, keep the original failing sample and one deliberate negative case so fallback cannot be mistaken for repair.
Technical references
When D2DERR_TEXT_EFFECT_IS_WRONG_TYPE is returned, these references define the public API family, object model, or error list used to interpret this status.
- Microsoft: Direct2D error codes.
- Microsoft: Direct2D API overview.
- Microsoft: Introducing DirectWrite.
- Microsoft: Glyph image formats in DirectWrite.
Looking for a different code? Search another status or error code.