locked
how to call SetCharacterSpacing in Directx for Windows8

    Question

  • Hello iam trying to use SetCharacterSpacing  method , as I read on documentation this function is located inside interface IDWriteTextLayout1

    now I declared an instance from IDWriteTextLayout1 but when I try to

    CreateTextLayout() to set its data , the following compilation error appears

    cannot convert parameter 6 from 'Microsoft::WRL::Details::ComPtrRef<T>' to 'IDWriteTextLayout **'

    I went to IDWriteTextLayout1 declaration and I seen that its inherited from IDWriteTextLayout interface , which should be accepted

    on CreateTextLayout() method because it uses base class (IDWriteTextLayout)

    see the sample code

      Microsoft::WRL::ComPtr<IDWriteTextLayout1> my_textLayout;
    	DX::ThrowIfFailed(
          m_dwriteFactory->CreateTextLayout(
    			text->Data(),
    			text->Length(),
    			m_textFormat.Get(),
    			700, // maxWidth.
    			1000,// maxHeight.
    			&my_textLayout // compilation error appears here
    			)
    		);

     

     

    Tuesday, December 4, 2012 2:59 PM

Answers

  • Hi,

    CreateTextLayout require IDWriteTextLayout . So that we should convert IDWriteTextLayout1 to IDWriteTextLayout.

    Please follow these codes.

    	Microsoft::WRL::ComPtr<IDWriteTextLayout1> my_textLayout;
    
    	ComPtr<IDWriteTextLayout> textLayout;
        DX::ThrowIfFailed(
            m_dwriteFactory->CreateTextLayout(
                m_sampleName->Data(),
                m_sampleName->Length(),
                nameTextFormat.Get(),
                4096.0f,
                4096.0f,
                &textLayout
                )
            );
    	textLayout.As(&my_textLayout);

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 6, 2012 8:09 AM
    Moderator