Review Request 116065: Implement FontLoader type.
Nikita Skovoroda
chalkerx at gmail.com
Thu Apr 10 14:55:38 UTC 2014
> On March 5, 2014, 10:08 a.m., Anton Kreuzkamp wrote:
> > src/qtcore.js, line 2095
> > <https://git.reviewboard.kde.org/r/116065/diff/2/?file=246157#file246157line2095>
> >
> > Why do you set the name property here, before actually loading the font? You wouldn't need all the touchName-stuff, if you just make font_name (->fontName) a private member (==constructor local) and set the name when the font finished loading, would you?
> > Regarding to how i understand the Qt-docs and what I observed, this is what QtQuick does as well.
>
> Nikita Skovoroda wrote:
> touchName would still be needed for the fallback case.
>
> Nikita Skovoroda wrote:
> Fallback case (without FontLoader.js):
> 1) Setting the font.name earlier is better because we don't know when the font is actually loaded. It's not nice to delay setting the font name for a fixed timeout if the font is already loaded.
> 2) At the moment of styling the first element with that font in a browser, the font is not actually loaded, so measuring dimensions will return old results. We need to make sure that some element has that font name applied some time before triggering re-measuring. Could be solved with adding some invisible elements, but that doesn't look better than touching the name to me.
>
> FontLoader.js:
> I thought that it might be better to set the name earlier, because if the font is loaded after the timeout, it would be still applied this way (without triggering re-measuring or setting the status). That can be alternatively solved by setting 'name' property if the timeout is reached and the font is not loaded, but if the FontLoader.js is somewhy not functioning correctly, the 'name' property won't be set at all. I guess that it's reasonable to assume that if FontLoader.js is loaded then it's working correctly, so font FontLoader.js code path I will remove touchName()-stuff.
Fixed for the case when FontLoader.js is used, should not be changed for the fallback case.
- Nikita
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/116065/#review50989
-----------------------------------------------------------
On April 10, 2014, 2:54 p.m., Nikita Skovoroda wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/116065/
> -----------------------------------------------------------
>
> (Updated April 10, 2014, 2:54 p.m.)
>
>
> Review request for QML Web and Anton Kreuzkamp.
>
>
> Repository: qmlweb
>
>
> Description
> -------
>
> Implement FontLoader type.
>
> See http://qt-project.org/doc/qt-5/qml-qtquick-fontloader.html and http://qt-project.org/doc/qt-4.7/qml-fontloader.html
>
> This currently depends on smnh's MIT-licensed FontLoader.js library
> to get notifications when a font is loaded and trigger all events in time.
>
> Elements that are using that font through 'font.family: fontId.name' get their dimensions recalculated correctly when the font loads.
>
> If FontLoader.js is not provided the font is still loaded, but 'status' property is set to Error and dimensions recalculation is triggered after a fixed timeout (3 seconds).
> In this case the user gets a notice in console.log.
>
>
> Timeout (3 seconds) is the maximum time for a font to load. If font isn't loaded in this time, status is set to Error.
> Without FontLoader.js dimensions recalculations for elements are triggered after that time.
>
> For both cases (with and without FontLoader.js) if the font takes more than this time to load, dimensions recalculations for elements that are using this font will not be triggered or will have no effect.
>
> On the other hand, if the font could not be loaded (with FontLoader.js enabled), the Error status will be set only when this timeout expires.
>
>
> Diffs
> -----
>
> src/qtcore.js a3f408e
>
> Diff: https://git.reviewboard.kde.org/r/116065/diff/
>
>
> Testing
> -------
>
> Works as expected (as described above) with or without FontLoader.js.
> Tested cases when the font should load and when it should fail to load.
>
> Tested «Text {font.family: fontId.name}» dimensions recalculations.
>
> Works well for me.
>
>
> Thanks,
>
> Nikita Skovoroda
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/qmlweb/attachments/20140410/1928d9a7/attachment.html>
More information about the QmlWeb
mailing list