Open myangelkamikaze opened 2 years ago
Disabling some security features lets you access the frame via js:
browserArgs.Add("--disable-web-security");
browserArgs.Add("--disable-site-isolation-trials");
From top level:
let style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '@font-face { font-family: "font_j"; src: local("MS Gothic"); font-weight: normal; }';
style.innerHTML += '\n';
style.innerHTML += '@font-face { font-family: "font_j"; src: local("MS UI Gothic"); font-weight: bold; }';
document.getElementById("game_frame").contentWindow.document.getElementById("htmlWrap").contentWindow.document.getElementsByTagName('head')[0].appendChild(style);
With the initial implementation, the custom browser font gets applied as expected.
The main problem currently seems to be that the game fails to display it correctly unless you load the default game font first. The failed display looks like this:
The current procedure to make everything look correct would be:
We could make a dropdown that tracks the loaded screens (this would be handled in CustomRequestHandler.cs
) and add a button to apply the font (5.) after everything is loaded.
Note that this would have to be done after every game refresh, so it's a very annoying procedure, which is why I just hid the option for now.
The ideal solution would be to figure out why custom fonts cause the incorrect display, but I have no idea how to figure that out.
Setting the browser font is possible by adding a style to the kancolle frame head: https://twitter.com/noro_006/status/1487288329372827648
WebView2 currently doesn't support accessing nested iframes, so it's not possible right now.
Script for testing: