[英]Developing Cordova plugins for Firefox OS
How does one go about creating cordova plugins on Firefox OS? 如何在Firefox OS上创建Cordova插件?
I've got a cordova plugin that I've written for iOS and Android that I'd like to add firefox OS support to. 我有一个为iOS和Android编写的cordova插件,我想向其中添加firefox OS支持。 Specifically, it enumerates the fonts that have been installed on the mobile device (my use case is a mostly-offline editor / translation tool). 具体来说,它枚举了已在移动设备上安装的字体(我的用例是主要是脱机编辑器/翻译工具)。
It looks like firefox OS uses the Android Open Source Project at a lower layer of its OS called Gonk . 看起来firefox操作系统在其操作系统的下层Gonk中使用了Android Open Source Project。 But, it also looks like Gronk is buried a couple layers deeper than the applications live. 但是,看起来Gronk似乎比应用程序的实际存在还要深几层。 Is this where I need to be writing the plugin code? 这是我需要编写插件代码的地方吗? It doesn't seem like code written there would be exposed through the gecko / gaia layers, and unfortunately the Cordova plugin developer's guide doesn't have any info on where to begin. 看起来那里编写的代码似乎不会通过gecko / gaia层公开,而且不幸的是, Cordova插件开发人员指南没有关于从何开始的任何信息。
If you could mess with Gonk at that level I think that it could be counted as a major security threat. 如果您可以在该级别上与Gonk混淆,我认为可以将其视为主要的安全威胁。 Today Fira is the system font and you can use your own font simply including it in your application with css. 今天,Fira是系统字体,您可以使用自己的字体,只需将其包含在CSS中即可。
I guess that now there isn't such a thing in Firefox OS but I will keep you updated in case I find something. 我想现在Firefox OS中没有这样的东西了,但是我会及时通知您,以防万一。
I'm afraid that there is no ability to get any info from "Android" layer in Firefox OS. 恐怕无法从Firefox OS的“ Android”层获取任何信息。 You could certainly do it for your machine, but as there is no Javascript font API it's not possible to create such a code in JavaScript. 您当然可以为您的机器执行此操作,但是由于没有Java字体字体API,因此无法在JavaScript中创建这样的代码。 All Cordova apps have exactly the same rights as other Firefox OS apps. 所有Cordova应用程序都具有与其他Firefox OS应用程序完全相同的权限。
Okay, it looks like this is a two-part answer: 好的,这看起来像是一个分为两个部分的答案:
There is kind of a hack-y way to dynamically get fonts based on whether a browser is doing font substitution here: http://www.lalit.org/lab/javascript-css-font-detect/ . 有一种黑客攻击-Y方式动态获取基于浏览器是否在这里做字体替换字体: http://www.lalit.org/lab/javascript-css-font-detect/ 。 I had tried this earlier and it did work on firefox, but not on webkit/chrome -- hence my desire to make this plugin for iOS/Android in the first place. 我之前曾尝试过,但它确实在firefox上起作用,但在webkit / chrome上却不起作用-因此,我希望首先将其用于iOS / Android。 I might end up using this method for the firefoxos port of my plugin. 我可能最终将这种方法用于插件的firefoxos端口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.