silexlabs / Cocktail

An HTML/CSS rendering engine for the Haxe language
http://www.silexlabs.org/haxe/cocktail/
Other
192 stars 34 forks source link

error with openfl and cocktail on linux hxcpp #425

Closed francescoagati closed 9 years ago

francescoagati commented 9 years ago

Hi, while i can compile my project in html5 and flash, in target linux/hxcpp i get this error:

Assets.hx:233: [Assets] There is no Font asset with an ID of "_serif"

serif should be a standard font?

francescoagati commented 9 years ago

same problem with monospace

Assets.hx:233: [Assets] There is no Font asset with an ID of "_typewriter"

and sans serif

Assets.hx:233: [Assets] There is no Font asset with an ID of "_sans"
francescoagati commented 9 years ago

only on linux platform

yanhick commented 9 years ago

Hi, I'm looking into it, I'm building and running on Linux. The font thing seems to be due to a change in OpenFL asset embedding since last year, I deactivated some code and the error is gone. I have a runtime bug after that, debugging now.

francescoagati commented 9 years ago

yes if i try go give a complete path like 'assets/font.ttf' i get a segmentation fault in c++

francescoagati commented 9 years ago

this is the code i use for test this issue

package;

import openfl.display.Sprite;
import openfl.text.Font;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.Assets;
import cocktail.api.CocktailView;

class Main extends Sprite {

    private var _cv:CocktailView;

    //public static function main() {}

    public function new () {

        super ();

        _cv = new CocktailView();

        var format = new TextFormat ("Katamotz Ikasi", 30, 0x7A0026);
        var textField = new TextField ();

        textField.defaultTextFormat = format;
        textField.embedFonts = true;
        textField.selectable = false;

        textField.x = 50;
        textField.y = 50;
        textField.width = 200;

        textField.text = "Hello World";

        addChild (textField);

try {
    _cv.loadHTML("
        <html>
        <head>
            <meta name=\"defaultFont\" content=\"assets/KatamotzIkasi.ttf\"></meta>
        </head>
        <body >
            <div style=\"color:red;background:yellow;font-family:'assets/KatamotzIkasi.ttf'\">ciao</div>
        </body>
        </html>

    ");
    addChild(_cv.root);
} catch(e:Dynamic) {
    trace(e);
}
        //_cv.window.document.body.style.backgroundColor = '#ff0000';
        //_cv.window.onload = function(e) {
        //_cv.viewport.width = 200;
        //_cv.viewport.height = 300;
        //_cv.viewport.x = 2010;
        //_cv.viewport.y = 10;

        //}

    }

}
yanhick commented 9 years ago

Thanks for the sample, I'll try with this. I'm trying helloworld for now.

By the way, If you're interested in the implementation the code dealing with font loading is here: https://github.com/silexlabs/Cocktail/blob/master/cocktail/port/platform/flash_player/FontBuilder.hx#L107

I you comment out the #if openfl block, you shouldn't have the error anymore (but custom font won't work)

yanhick commented 9 years ago

I made some progress, I can build and run the first 2 samples. It turns out there is a regression in OpenFL in one of the drawing apis, I haven't checked is the bug has been reported.

I've pushed temporary fixes here if you want to try: https://github.com/silexlabs/Cocktail/tree/fixes-for-openfl

francescoagati commented 9 years ago

sorry for the late in responding. Yes now it works also on linux. Fantastic thanks.

yanhick commented 9 years ago

Nice ! I think I'll take some time this weekend to see if the other samples work with OpenFL.

2015-06-22 16:25 GMT-07:00 francesco agati notifications@github.com:

sorry for the late in responding. Yes now it works also on linux. Fantastic thanks.

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-114301282.

francescoagati commented 9 years ago

Yes i think that there are othere issue. Images fonts and styles now works good. I see that forms aren't rendered in html5 and linux. trying this example the text is rendered but not form inputs

package;

import openfl.display.Sprite;
import openfl.text.Font;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.Assets;
import cocktail.api.CocktailView;

class Main extends Sprite {

    private var _cv:CocktailView;

    //public static function main() {}

    public function new () {

        super ();

        _cv = new CocktailView();

        var format = new TextFormat ("Katamotz Ikasi", 30, 0x7A0026);
        var textField = new TextField ();

        textField.defaultTextFormat = format;
        textField.embedFonts = true;
        textField.selectable = false;

        textField.x = 50;
        textField.y = 50;
        textField.width = 200;

        textField.text = "Hello World";

        addChild (textField);

try {

    /*
    _cv.loadHTML("
        <html>
        <head>
            <meta name=\"defaultFont\" content=\"assets/KatamotzIkasi.ttf\"></meta>
        </head>
        <body>
            <center>
               <img src=\"assets/veespo.png\" />
            </center>

            <center>
                 <textarea>
                   CIAOCIAOCIAO
                </textarea>
            </center>

            <div style=\"color:red;background:yellow;font-family:'assets/KatamotzIkasi.ttf'\">ciao</div>
        </body>
        </html>

    ");
    */

    _cv.loadHTML('

    <!DOCTYPE html>
    <html>
        <head>
        <meta name="defaultFont" content="assets/KatamotzIkasi.ttf"></meta>
          <style>

            h2, h3 {
                border-bottom:black solid thin;
            }

            form {
                width:500px;
                border:black solid thin;
                padding:20px;
                font-family:"assets/KatamotzIkasi.ttf";
            }

            textarea {
                width:100%;
                background:red;
                font-family:"assets/KatamotzIkasi.ttf";
            }

            input {
                background:red;
                font-family:"assets/KatamotzIkasi.ttf";

            }
            input[type=reset], input[type=submit] {
                box-sizing:content-box;
                padding-left:0;
                padding-right:0;
                background:red;
                font-family:"assets/KatamotzIkasi.ttf";
            }
          </style>
        </head>
        <body>
            <form id="frm" >
                <h1>Subscribe</h1>
                <h4>(Dont worry, its fake )</h4>
                <div>
                    <h3>Info</h3>
                    name : <input name="name"></input>
                    password : <input type="password" name="pass" />
                </div>
                <div>
                    <h3>Iam a...</h3>
                    man : <input type="radio" name="sex" value="man" />
                    woman : <input type="radio" name="sex" value="woman" />
                    other : <input type="radio" name="sex" value="other" />
                </div>
                <div>
                    <h3>I want to...</h3>
                    subscribe : <input type="checkbox" checked="true" name="subscribe" />
                    receive update : <input type="checkbox" name="update" />
                    receive spam : <input type="checkbox" name="spam" />
                </div>
                <div>
                    <h3>comment</h3>
                    <textarea name="comment">I think that...</textarea>
                </div>
                <div>
                    <input type="submit" />
                    <input type="reset" />
                </div>
            </form>
        </body>
    </html>

    ');

    addChild(_cv.root);
} catch(e:Dynamic) {
    trace(e);
}
        //_cv.window.document.body.style.backgroundColor = '#ff0000';
        //_cv.window.onload = function(e) {
        //_cv.viewport.width = 200;
        //_cv.viewport.height = 300;
        //_cv.viewport.x = 2010;
        //_cv.viewport.y = 10;

        //}

    }

}
yanhick commented 9 years ago

Yes it was working at some point but I barely worked on this project this year and OpenFL moves fast. I'm starting to think about automating building and running those samples on Travis.ci to catch those regressions.

2015-06-22 17:11 GMT-07:00 francesco agati notifications@github.com:

Yes i think that there are othere issue. Images fonts and styles now works good. I see that forms aren't rendered in html5 and linux. trying this example the text is rendered but not form inputs

package;

import openfl.display.Sprite; import openfl.text.Font; import openfl.text.TextField; import openfl.text.TextFormat; import openfl.Assets; import cocktail.api.CocktailView;

class Main extends Sprite {

private var _cv:CocktailView;

//public static function main() {}

public function new () {

    super ();

    _cv = new CocktailView();

    var format = new TextFormat ("Katamotz Ikasi", 30, 0x7A0026);
    var textField = new TextField ();

    textField.defaultTextFormat = format;
    textField.embedFonts = true;
    textField.selectable = false;

    textField.x = 50;
    textField.y = 50;
    textField.width = 200;

    textField.text = "Hello World";

    addChild (textField);

try {

/*
_cv.loadHTML("
    <html>
    <head>
        <meta name=\"defaultFont\" content=\"assets/KatamotzIkasi.ttf\"></meta>
    </head>
    <body>
        <center>
           <img src=\"assets/veespo.png\" />
        </center>

        <center>
             <textarea>
               CIAOCIAOCIAO
            </textarea>
        </center>

        <div style=\"color:red;background:yellow;font-family:'assets/KatamotzIkasi.ttf'\">ciao</div>
    </body>
    </html>

");
*/

_cv.loadHTML('

<!DOCTYPE html>
<html>
    <head>
    <meta name="defaultFont" content="assets/KatamotzIkasi.ttf"></meta>
      <style>

        h2, h3 {
            border-bottom:black solid thin;
        }

        form {
            width:500px;
            border:black solid thin;
            padding:20px;
            font-family:"assets/KatamotzIkasi.ttf";
        }

        textarea {
            width:100%;
            background:red;
            font-family:"assets/KatamotzIkasi.ttf";
        }

        input {
            background:red;
            font-family:"assets/KatamotzIkasi.ttf";

        }
        input[type=reset], input[type=submit] {
            box-sizing:content-box;
            padding-left:0;
            padding-right:0;
            background:red;
            font-family:"assets/KatamotzIkasi.ttf";
        }
      </style>
    </head>
    <body>
        <form id="frm" >
            <h1>Subscribe</h1>
            <h4>(Dont worry, its fake )</h4>
            <div>
                <h3>Info</h3>
                name : <input name="name"></input>
                password : <input type="password" name="pass" />
            </div>
            <div>
                <h3>Iam a...</h3>
                man : <input type="radio" name="sex" value="man" />
                woman : <input type="radio" name="sex" value="woman" />
                other : <input type="radio" name="sex" value="other" />
            </div>
            <div>
                <h3>I want to...</h3>
                subscribe : <input type="checkbox" checked="true" name="subscribe" />
                receive update : <input type="checkbox" name="update" />
                receive spam : <input type="checkbox" name="spam" />
            </div>
            <div>
                <h3>comment</h3>
                <textarea name="comment">I think that...</textarea>
            </div>
            <div>
                <input type="submit" />
                <input type="reset" />
            </div>
        </form>
    </body>
</html>

');

addChild(_cv.root);

} catch(e:Dynamic) { trace(e); } //_cv.window.document.body.style.backgroundColor = '#ff0000'; //_cv.window.onload = function(e) { //_cv.viewport.width = 200; //_cv.viewport.height = 300; //_cv.viewport.x = 2010; //_cv.viewport.y = 10;

    //}

}

}

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-114309724.

francescoagati commented 9 years ago

Yes if you wanna i can help you to write tests for travis

yanhick commented 9 years ago

Yes, that would be cool ! We started an effort last year with @zabojad to add unit tests to cocktail but I add to stop due to lack of time.

We started splitting Cocktail into modules and adding tests here: https://github.com/haxecocktail

I'm really not convinced anymore about splitting the codebase right now, the overhead in packaging everything for haxelib and managing dependencies doesn't seem worth it.

What I'd like to do next:

What do you think ?

francescoagati commented 9 years ago

i think that is a good idea. Cocktail is an important project for haxe. I think that also write an email in haxe Google group for motivate users to test and use it should be a good idea

francescoagati commented 9 years ago

have see travis tests. is possible testing travis with openfl and differents backend openfl?

yanhick commented 9 years ago

Yep, you got me motivated yesterday, the haxefoundation guys did a great job with the haxe travis integration !

I started by running unit tests since its simpler but the end goal is to run the samples with openfl backends (html5, flash and linux).

If you're interested to work on this, I think the first steps would be to focus on the hello-world sample:

This would be a good start, I suspect there might be issues just getting openfl installed on travis and getting it to build projects. When it's done we can think about how to actually run the samples on travis.

2015-06-23 9:49 GMT-07:00 francesco agati notifications@github.com:

have see travis tests. is possible testing travis with openfl and differents backend openfl?

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-114568881.

francescoagati commented 9 years ago

Good in this days i try to start to test openfl and hello wold and try to integrate it with tests

yanhick commented 9 years ago

Cool, I'll let you figure this out then. I'll work on adding more tests to other part of the code, probably this weekend.

2015-06-24 10:35 GMT-07:00 francesco agati notifications@github.com:

Good in this days i try to start to test openfl and hello wold and try to integrate it with tests

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-114949927.

francescoagati commented 9 years ago

sorry for late response. i start to porting the demo on a new project for build with openfl whe in try do to an innerHTML i get this error on all targets

Called from ? line 1
Called from ApplicationMain.hx line 123
Called from ApplicationMain.hx line 55
Called from lime/app/Application.hx line 163
Called from lime/_backend/native/NativeApplication.hx line 107
Called from a C function
Called from lime/app/Event.hx line 59
Called from lime/app/Application.hx line 568
Called from openfl/display/Stage.hx line 956
Called from openfl/display/DisplayObjectContainer.hx line 639
Called from a C function
Called from openfl/display/DisplayObject.hx line 1000
Called from a C function
Called from openfl/events/EventDispatcher.hx line 292
Called from cocktail/port/platform/flash_player/PlatformTimer.hx line 68
Called from cocktail/core/timer/Timer.hx line 143
Called from cocktail/api/CocktailView.hx line 422
Called from cocktail/core/html/HTMLDocument.hx line 639
Called from cocktail/core/invalidation/InvalidationManager.hx line 233
Called from cocktail/core/invalidation/InvalidationManager.hx line 484
Called from cocktail/core/invalidation/InvalidationManager.hx line 733
Called from cocktail/core/renderer/BlockBoxRenderer.hx line 195
Called from cocktail/core/renderer/BlockBoxRenderer.hx line 247
Called from cocktail/core/renderer/BlockBoxRenderer.hx line 279
Called from cocktail/core/renderer/ElementRenderer.hx line 334
Called from cocktail/core/renderer/InvalidatingElementRenderer.hx line 81
Called from cocktail/core/renderer/InvalidatingElementRenderer.hx line 315
Uncaught exception - Invalid field access : invalidateLayout
francescoagati commented 9 years ago

this is the test project i have create

https://github.com/francescoagati/test-open-fl

yanhick commented 9 years ago

Thanks for the update, I'll take a look early next week

2015-07-03 9:07 GMT-07:00 francesco agati notifications@github.com:

this is the test project i have create

https://github.com/francescoagati/test-open-fl

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-118383702.

yanhick commented 9 years ago

I've pushed a couple fixes, your project now works for me on linux.

I had to disable transparent bitmap drawing in my last commit which doesn't work in openfl. https://github.com/silexlabs/Cocktail/commit/7a60a6fe23f7113027ce6abd9404f59c561693c4

The rendering won't be correct for overlapping assets but at least you can make some progress, it will be enough for now.

2015-07-05 18:13 GMT-07:00 Yannick Dominguez yannick.dominguez@gmail.com:

Thanks for the update, I'll take a look early next week

2015-07-03 9:07 GMT-07:00 francesco agati notifications@github.com:

this is the test project i have create

https://github.com/francescoagati/test-open-fl

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-118383702 .

francescoagati commented 9 years ago

yes now dom manipolation works good. I have see that with linux cpp project external assets aren't load for example <img src="http://...." /> but in html5 are loaded

francescoagati commented 9 years ago

i think there is a bug in html5 render. Sometimes text is truncated. I think the problem is in recent updates on lime html5 target. The same problem was in stablexui.

https://github.com/RealyUniqueName/StablexUI/commit/607d9d88db5e3874b34de01692fdf3c3523556be

yanhick commented 9 years ago

Yes, unfortunately the text support in openfl often has regressions. Do you have an example for the assets not being loaded in linux cpp ? It works for my simple tests

2015-07-13 15:15 GMT-07:00 francesco agati notifications@github.com:

i think there is a bug in html5 render. Sometimes text is truncated. I think the problem is in recent updates on lime html5 target. The same problem was in stablexui.

RealyUniqueName/StablexUI@607d9d8 https://github.com/RealyUniqueName/StablexUI/commit/607d9d88db5e3874b34de01692fdf3c3523556be

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-121077973.

francescoagati commented 9 years ago

yes, tonight (italy time) i can prepare an example. The text is rendered ok with cpp neko and flash. Only in html5 is truncated if the text is big (like a font-size:32)

2015-07-14 17:34 GMT+02:00 Yannick Dominguez notifications@github.com:

Yes, unfortunately the text support in openfl often has regressions. Do you have an example for the assets not being loaded in linux cpp ? It works for my simple tests

2015-07-13 15:15 GMT-07:00 francesco agati notifications@github.com:

i think there is a bug in html5 render. Sometimes text is truncated. I think the problem is in recent updates on lime html5 target. The same problem was in stablexui.

RealyUniqueName/StablexUI@607d9d8 < https://github.com/RealyUniqueName/StablexUI/commit/607d9d88db5e3874b34de01692fdf3c3523556be

— Reply to this email directly or view it on GitHub <https://github.com/silexlabs/Cocktail/issues/425#issuecomment-121077973 .

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-121283620.

yanhick commented 9 years ago

Cool thanks

2015-07-14 8:36 GMT-07:00 francesco agati notifications@github.com:

yes, tonight (italy time) i can prepare an example. The text is rendered ok with cpp neko and flash. Only in html5 is truncated if the text is big (like a font-size:32)

2015-07-14 17:34 GMT+02:00 Yannick Dominguez notifications@github.com:

Yes, unfortunately the text support in openfl often has regressions. Do you have an example for the assets not being loaded in linux cpp ? It works for my simple tests

2015-07-13 15:15 GMT-07:00 francesco agati notifications@github.com:

i think there is a bug in html5 render. Sometimes text is truncated. I think the problem is in recent updates on lime html5 target. The same problem was in stablexui.

RealyUniqueName/StablexUI@607d9d8 <

https://github.com/RealyUniqueName/StablexUI/commit/607d9d88db5e3874b34de01692fdf3c3523556be

— Reply to this email directly or view it on GitHub < https://github.com/silexlabs/Cocktail/issues/425#issuecomment-121077973 .

— Reply to this email directly or view it on GitHub <https://github.com/silexlabs/Cocktail/issues/425#issuecomment-121283620 .

— Reply to this email directly or view it on GitHub https://github.com/silexlabs/Cocktail/issues/425#issuecomment-121284130.

francescoagati commented 9 years ago

hi, this is the project with html5 text truncation

https://github.com/francescoagati/cocktail-text-format-html5

and this and example image inside the issue

https://github.com/francescoagati/cocktail-text-format-html5/issues/1

after compile in html5 you can play with key down to see differents texts