locked
Show WebView content with Custom font family RRS feed

  • Question

  • Hi 

    I am using webview to display html text in my UWP app like

    webView2.NavigateToString( "<html><body><h2>This is an HTML fragment</h2></body></html>");

    Can I changed the webview default font family because same html displaying with different font family for android device.

    I need to make same as android font.


    sandeep chauhan

    Thursday, September 20, 2018 7:37 AM

All replies

  • Hello,

    You can modify the html yourself to set the font, like:

      webview1.NavigateToString("<html><body><p style=font-size:50px>This is a paragraph.</p><h2>This is an HTML fragment</h2></body></html>");

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 21, 2018 8:49 AM
  • Hi Barry

    Thanks for reply.

    Actually HTML is not fixed. there would be no <html> tag and <body> tag and html can be start from any tag so would be complex for modification this html bcs we dont know key tag.


    sandeep chauhan

    Tuesday, September 25, 2018 1:44 PM
  • @sandeep chauhan,

    So what about custom font by using @font-face. Webview control itself does not contain such a method for you to format the whole format.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, September 27, 2018 3:05 AM