Make XAML markup DPI-aware? |
Post Reply |
Author | ||||
MacW
Senior Member Joined: 26 June 2007 Status: Offline Points: 253 |
Post Options
Thanks(0)
Posted: 21 January 2015 at 10:27am |
|||
I use the latest version of XTP.
I tried to render XAML markup into a device context that has 300 DPI. XTPMarkupParseText(...) XTPMarkupRenderElement(...,*pDC,Rect); XTPMarkupReleaseElement(...); But all measures used in the markup, e.g. FontSize='24pt' do not scale to the DPI settings of the output device context. Looking at the markup source code in XTP reveals that measurements like 24pt are transformed assuming a DPI setting of 96 DPI. For example, look at CXTPMarkupBuilder::ConvertLength in Source\Markup\XTPMarkupBuilder.cpp. Thís makes it impossible to render markup device-independently. All font-measurements (and others) have to be parametrized and calculated and inserted at runtime, before calling the XTP MarkupParseText and MarkupRenderElement methods. There are now monitors with more than 96 DPI, font-scaling may be used in Windows or a programmer may want to render Codejock XAML markup into a printer or PDF device context. Is there hope that this will be corrected in the foreseeable future or do I need to come up with my own solution to this hard-coded DPI dependency? |
||||
astoyan
Admin Group Joined: 24 August 2013 Status: Offline Points: 304 |
Post Options
Thanks(0)
|
|||
Hello MacW,
All previous version of ToolkitPro, including the most recent 16.4.0, mostly do not support DPI scalling. But the next version which should be released in a few weeks will support DPI scalling for most of the components, it's already implemented and is currently in the testing stage. Note, for Markup DPI scalling will be disabled by default in order to provide backward compatibility, but it'll be easy to enable it by setting to TRUE an new bDpiAware argument of XTPMarkupParseText or calling CXTPMarkupContext::SetDpiAware. Once an update is out please re-test all your markup related functionality with the DpiAware option enabled to make sure nothing is broken and let me know if you find any issues. Thank you. Regards, Alexander Stoyan
|
||||
MacW
Senior Member Joined: 26 June 2007 Status: Offline Points: 253 |
Post Options
Thanks(0)
|
|||
That's good news, Alexander
Lets hope that it all works (because you write 'will support DPI scalling for most of the components'). I don't need much, I just use the XAML engine to render text, no graphics, no UI elements etc. So far I have been able to work around this by supplying the absolute font sizes to the markup at runtime. |
||||
MacW
Senior Member Joined: 26 June 2007 Status: Offline Points: 253 |
Post Options
Thanks(0)
|
|||
Will this feature be configurable?
Because my code has a lot of places where I manually scale the font-size I need to match the screen's DPI setting, and then hand over something like 14pt to the Codejock XAML parser. 14pt may be the result of scaling the desired 11pt size to a 140 DPI screen. Codejock should not scale the 14pt again. Otherwise I would have to change al my code when I install the promised update. There should be a switch for the markup context which allows me to tell if it should scale font sizes or not. |
||||
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
|
|||
I was also surprised to find the following code in CXTPMarkupImage two times:
This breaks my Markup images because I use them together with some markup drawing elements. I thought that Markup DPI awareness should be default off, but the line above does not look at this flag. For v1700 I did the following fast fix:
In v1710 the correct solution would be to add a ScaleSize member to the CXTPDpi class, and a similar ScaleSize method in CXTPMarkupContext calling this method if m_pDpi existed, and then finally change the line
to something like
Please fix this. -cpede |
||||
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
||||
astoyan
Admin Group Joined: 24 August 2013 Status: Offline Points: 304 |
Post Options
Thanks(0)
|
|||
Hello cpede,
XTP_DPI should not appear in CXTPMarkupImage, it was a bug which we've just fixed. Please try the following below DIFF patch and let me know if it works fine for you:
Thanks, Alexander
|
||||
astoyan
Admin Group Joined: 24 August 2013 Status: Offline Points: 304 |
Post Options
Thanks(0)
|
|||
Hello MacW, Please provide a test XAML and try attach 2 screenshots, one of Codejock Markup rendered in 140DPI, another one from WPF application rendering the same markup in 140DPI. Thank you. Alexander
|
||||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |