Jump to content

Search the Community

Showing results for tags 'idwritetextrenderer'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hello, I am trying to make a custom text renderer using DirectWrite. According to this I have made a custom renderer using ObjectFromTag. Global $oMyRenderer = ObjectFromTag("MyRenderer_", $tagIDWriteTextRenderer, $tStruct, False, False, True, $sIID_IDWriteTextRenderer) This renderer is then used in subcalssed Draw method of IDWriteTextLayout. ;create IDWriteTextLayout object Local $oDW_Layout = _DWrite_Factory_CreateTextLayout($oDW_Factory, $sString, $oDW_Format, 300, 450) ;max width, max height ;replace Draw method of $oDW_Layout with our own so that custom text renderer can be used Local $hLayoutDrawCallback_New = DllCallbackRegister("Draw", "long", "ptr;ptr;ptr;float;float") ;Draw hresult(struct*;struct*;float;float)-https://docs.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritetextlayout-draw Local $pLayoutDrawCallback_New = DllCallbackGetPtr($hLayoutDrawCallback_New) Local $pDW_Layout = Ptr($oDW_Layout()) $pTextLayout_Draw_Original = ReplaceVTableFuncPtr($pDW_Layout, (56 + 3 - 1) * 4, $pLayoutDrawCallback_New) Right now I am having two issues. First one is as it seems there is some issue with pointers. Func MyRenderer_DrawGlyphRun($pSelf, $pClientDrawingContext, $fBaselineOriginX, $fBaselineOriginY, $iMeasuringMode, $pGlyphRun, $pGlyphRunDescription, $pClientDrawingEffect) ; Ret: long Par: struct*;float;float;uint;struct*;struct*;struct* ConsoleWrite("MyRenderer_DrawGlyphRun()" & @CRLF & @CRLF) ConsoleWrite(@TAB & "x:" & $fBaselineOriginX & ", y:" & $fBaselineOriginY & @CRLF) ConsoleWrite(@TAB & "$pClientDrawingEffect=" & $pClientDrawingEffect & @CRLF) $tData = DllStructCreate($tagDWRITE_GLYPH_RUN_DESCRIPTION, $pGlyphRun) If @error Then ConsoleWrite(@TAB & "!DllStructCreate error:" & @error & ", ptr=" & $pGlyphRun & @CRLF) Else ConsoleWrite(@TAB & "FontEmSize:" & DllStructGetData($tData, "FontEmSize") & @CRLF) EndIf Return 0 ; S_OK = 0x00000000 EndFunc ;==>MyRenderer_DrawGlyphRun For $pGlyphRunI keep getting 0. Same situation happens with MyRenderer_DrawUnderline and pointers there. If the default renderer is used in subclassed Draw method then text draws fine. Floating point values are fine. I have checked tag generation in ObjectFromTag. That looks good. Func Draw($pSelf, $oClientDrawingContext, $oRenderer, $fOriginX, $fOriginY) ConsoleWrite("Draw called" & @CRLF) ConsoleWrite("x=" & $fOriginX & ",y=" & $fOriginY & @CRLF) $aResult = DllCallAddress("long", $pTextLayout_Draw_Original, "ptr", $pSelf, "ptr", $oClientDrawingContext, "ptr", $oMyRenderer, "float", $fOriginX, "float", $fOriginY) ;~ If @error Then MsgBox(0,"Error at draw",@error) ;uncomment next line to see text $aResult = DllCallAddress("long", $pTextLayout_Draw_Original, "ptr", $pSelf, "ptr", $oClientDrawingContext, "ptr", $oRenderer, "float", $fOriginX, "float", $fOriginY) ;~ Return $aResult[0] EndFunc ;==>Draw Maybe I have done something wrong in those callbacks. Second issue I am having is with *clientDrawingContext. I am not sure whether I should define that and then use in custom renderer. Microsoft's documentation says "clientDrawingContext Type: void* The application-defined drawing context passed to IDWriteTextLayout::Draw". HRESULT DrawUnderline( void *clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, [in] DWRITE_UNDERLINE const *underline, IUnknown *clientDrawingEffect ); I am attaching full script here. DirectWrite UDF can be downloaded from https://autoit.de/wcf/attachment/82843-direct2d-7z/. _DWrite_IDWriteTextRenderer.au3
×
×
  • Create New...