| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.emojirenderingtestapp; |
| 18 |
|
| 19 |
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; |
| 20 |
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; |
| 21 |
|
| 22 |
import android.app.Activity; |
| 23 |
import android.graphics.fonts.Font; |
| 24 |
import android.graphics.fonts.SystemFonts; |
| 25 |
import android.os.Bundle; |
| 26 |
import android.widget.LinearLayout; |
| 27 |
import android.widget.TextView; |
| 28 |
|
| 29 |
public class GetAvailableFontsTestActivity extends Activity { |
| 30 |
|
| 31 |
@Override |
| 32 |
protected void onCreate(Bundle savedInstanceState) { |
| 33 |
super.onCreate(savedInstanceState); |
| 34 |
String emojiFontPath = "<Not found>"; |
| 35 |
for (Font font : SystemFonts.getAvailableFonts()) { |
| 36 |
|
| 37 |
font.getAxes(); |
| 38 |
font.getFile(); |
| 39 |
font.getLocaleList(); |
| 40 |
font.getStyle(); |
| 41 |
font.getTtcIndex(); |
| 42 |
if ("NotoColorEmoji.ttf".equals(font.getFile().getName())) { |
| 43 |
emojiFontPath = font.getFile().getAbsolutePath(); |
| 44 |
} |
| 45 |
} |
| 46 |
LinearLayout container = new LinearLayout(this); |
| 47 |
container.setOrientation(LinearLayout.VERTICAL); |
| 48 |
TextView textView = new TextView(this); |
| 49 |
textView.setText(emojiFontPath); |
| 50 |
container.addView(textView, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)); |
| 51 |
setContentView(container); |
| 52 |
} |
| 53 |
} |