Giter Club home page Giter Club logo

androidfreetype's Introduction

在根目录的build.gradle中添加依赖

allprojects {
   repositories {
      maven { url "https://raw.githubusercontent.com/tianheng812/AndroidFreetype/master" }
   }
}

在项目中的build.gradle添加依赖

dependencies {
    implementation 'com.xian:freestype:1.0.0'
}

在AndroidManifest.xml加入读写权限

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

初始化

WordManager.getInstance().init(this);//默认是宋体

WordManager.getInstance().init(this,字体路径);//更改字体

销毁

 WordManager.getInstance().destroy();

1.使用freetype提取字的模式,并可以转化为bmp图,如图

byte[] bytes = WordManager.getInstance().stringToBmpByte("我们", 16, 0);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);

2.提取点阵:

 StringBuilder builder = new StringBuilder();   
 byte[][] arr = WordManager.getInstance().stringToLattice(content, fontSize, 0);
 for (int i = 0; i < arr.length; i++) {
      for (int j = 0; j < arr[0].length; j++) {
           if (arr[i][j] == 1) {
                 builder.append("1");
             } else {
                  builder.append("0");
             }
       }
            builder.append("\n");
  }

 Log.i("点阵", builder.toString());

androidfreetype's People

Contributors

tianheng812 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.