项目作者: gregcockroft

项目描述 :
Render beautiful LaTeX Math Equations in an Android View
高级语言: Kotlin
项目地址: git://github.com/gregcockroft/AndroidMath.git
创建时间: 2018-05-16T13:01:30Z
项目社区:https://github.com/gregcockroft/AndroidMath

开源协议:MIT License

下载


AndroidMath

  • Rendering of LaTeX Math inside of an Android View
  • No dependency on WebView
  • Easy to use.

Installation from the command line

  1. git clone https://github.com/gregcockroft/AndroidMath.git
  2. cd AndroidMath
  3. ./gradlew installDebug

Installation for Android Studio

Clone this project, run CDep.
CDep pulls in the freetype dependency.

  1. git clone https://github.com/gregcockroft/AndroidMath.git
  2. cd AndroidMath/mathdisplaylib
  3. ./cdep

Open the project in Android Studio

Using library in your app

This is using jitpack.io
Add below lines to root’s build.gradle

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add below lines to apps’s build.gradle

  1. dependencies {
  2. implementation 'com.github.gregcockroft:AndroidMath:ALPHA'
  3. }
  1. <ConstraintLayout ...>
  2. <TextView
  3. android:id="@+id/description"
  4. android:layout_width="wrap_content"
  5. android:layout_height="wrap_content"
  6. android:text="Hello Math!"
  7. app:layout_constraintBottom_toTopOf="@+id/mathview"
  8. app:layout_constraintLeft_toLeftOf="parent"
  9. app:layout_constraintRight_toRightOf="parent"
  10. app:layout_constraintTop_toTopOf="parent" ></TextView>
  11. <com.agog.mathdisplay.MTMathView
  12. android:id="@+id/mathview"
  13. android:layout_width="wrap_content"
  14. android:layout_height="wrap_content"
  15. android:layout_marginTop="56dp"
  16. app:layout_constraintLeft_toLeftOf="parent"
  17. app:layout_constraintRight_toRightOf="parent"
  18. app:layout_constraintTop_toBottomOf="@id/description" ></com.agog.mathdisplay.MTMathView>
  19. </ConstraintLayout>
  1. override fun onCreate(savedInstanceState: Bundle?) {
  2. super.onCreate(savedInstanceState)
  3. setContentView(activity_main)
  4. mathview.latex = "x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"
  5. }

API

Look at MTMathView
This is the central access class.

Credits:

  • iosMath This project is a Kotlin port for Android of the iosMath project
  • Freetype is used for rendering glyphs and font metrics.
  • Freetype jni was copied as a starting point to access the native freetype library.

For people looking for things beyond just rendering math, there are two
related projects:

  • MathEditor: A WYSIWYG editor
    for math equations on iOS.
  • MathSolver: A library for
    solving math equations.

License

AndroidMath is available under the MIT license. See the LICENSE
file for more info.

Fonts

This distribution contains the following fonts. These fonts are
licensed as follows: