• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

NanoMichael/AndroidLaTeXMath: A LaTeX rendering library for Android

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

NanoMichael/AndroidLaTeXMath

开源软件地址(OpenSource Url):

https://github.com/NanoMichael/AndroidLaTeXMath

开源编程语言(OpenSource Language):

Java 57.9%

开源软件介绍(OpenSource Introduction):

logo

Library for displaying LaTeX formulas on Android. It use cLaTeXMath to parse and render LaTeX code. The picture below demonstrate the demo application.

demo

Installation

Library is available in jcenter repository, add this script to your build.gradle file to install:

implementation 'io.nano:android-tex:1.0.0'

ProGuard

Add the following rule to your proguard config file:

-keep class io.nano.tex.**

How to use

First, initialize the library:

// ... code inside an Activity or Application
@override
public void onCreate() {
    // ... some other code
    // Initialize the LaTeX engine. Call of this function will copy the 
    // "TeX resources" from apk into the data files directory of the
    // host application, and parse the "TeX resources", it may takes a
    // long time, you may call it from a background thread.
    if (!LaTeX.isInitialized()) {
        LaTeX.instance().init(getApplicationContext());
    }
}

Then, parse the given LaTeX code:

String code = "\\int_{now}^{\\infty} \\text{Keep trying}";
TeXRender r = LaTeX.instance().parse(
    code,        // LaTeX code to parse
    720,         // logical width of the graphics context (in pixel)
    20,          // font size
    10,          // space between 2 lines (in pixel)
    Color.DKGRAY // foreground color
);

Last, just draw it:

@override
protected void onDraw(Canvas canvas) {
    Graphics2D g2 = new Graphics2D();
    g2.setCanvas(canvas);
    // draw the formula on the coordinate (10, 10)
    r.draw(g2, 10, 10);
}

Very simple. For more details, please check out the demo app of this project.

Build by yourself

First make sure you have a NDK that the version must be >=4.9 installed. Then add the following script to your local.properties file:

ndk.dir=/your/NDK/dir

Update the latest C++ implementation using git:

git submodule init --recursive
git submodule update --remote

Now everything is OK, just build it.

License

This project is under the Apache-2.0

Copyright 2018 Nano Michael

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap