开发者

Using Typeface.js within a GWT app

开发者 https://www.devze.com 2022-12-29 08:56 出处:网络
I am looking for some sample Java code demonstrating how to get AJAX content displayed into a custom font using Typeface.js within a GWT app.

I am looking for some sample Java code demonstrating how to get AJAX content displayed into a custom font using Typeface.js within a GWT app. I have tried a little bit by calling the following native function

    native void Typeface_renderDocument() /*-{ 
        $wnd._typeface_js.renderDocument();
    }-*/;
  • after having filled the relevant widget with the AJAX content, and
  • after calling the following function on the widget :

    void applyTypeface(Widget widget) {
        widget.addStyl开发者_开发技巧eName("typeface-js");
        widget.getElement().getStyle().setProperty("fontFamily", "Helvetiker");
        Typeface_renderDocument();
    }
    

...where Helvetiker is a custom font (actually available from Typeface.js fonts page (http://typeface.neocracy.org/fonts.html). But the above attempt didn't work.

Any suggestions are very welcome, I am bit stuck here...


A guess, but try running Typeface_renderDocument() in a DeferredCommand -- perhaps those style changes aren't visible in the DOM at the point that the JS executes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号