use of com.mta.tehreer.graphics.Renderer in project Tehreer-Android by mta452.
the class TypefaceGlyphsActivity method loadTypeface.
private void loadTypeface(Typeface typeface) {
if (typeface != mTypeface) {
mTypeface = typeface;
float density = getResources().getDisplayMetrics().density;
float typeSize = 28.0f * density;
Renderer renderer = new Renderer();
renderer.setTypeface(typeface);
renderer.setTypeSize(typeSize);
mGlyphsGridView.setAdapter(new GlyphAdapter(this, renderer));
}
}
use of com.mta.tehreer.graphics.Renderer in project Tehreer-Android by mta452.
the class OpenTypeInfoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opentype_info);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
Intent intent = getIntent();
String typefaceName = intent.getStringExtra(TYPEFACE_NAME);
int typeSize = intent.getIntExtra(TYPE_SIZE, 0);
int scriptTag = intent.getIntExtra(SCRIPT_TAG, 0);
int languageTag = intent.getIntExtra(LANGUAGE_TAG, 0);
String sourceText = intent.getCharSequenceExtra(SOURCE_TEXT).toString();
WritingDirection writingDirection = ShapingEngine.getScriptDirection(scriptTag);
Typeface typeface = TypefaceManager.getTypefaceByName(typefaceName);
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
float displaySize = 18.0f * displayMetrics.scaledDensity;
float sizeScale = displaySize / typeSize;
Renderer renderer = new Renderer();
renderer.setTypeface(typeface);
renderer.setTypeSize(typeSize);
renderer.setScaleX(sizeScale);
renderer.setScaleY(sizeScale);
ShapingEngine shapingEngine = ShapingEngine.finalizable(new ShapingEngine());
shapingEngine.setTypeface(typeface);
shapingEngine.setTypeSize(typeSize);
shapingEngine.setScriptTag(scriptTag);
shapingEngine.setLanguageTag(languageTag);
shapingEngine.setWritingDirection(writingDirection);
ShapingResult shapingResult = ShapingResult.finalizable(shapingEngine.shapeText(sourceText, 0, sourceText.length()));
IntList clusterMap = shapingResult.getClusterMap();
int length = clusterMap.size();
int[] initials = new int[length + 1];
int cluster = -1;
int previous = -1;
for (int i = 0; i < length; i++) {
int value = clusterMap.get(i);
if (value != previous) {
initials[++cluster] = i;
}
previous = value;
}
initials[++cluster] = length;
ListView infoListView = findViewById(R.id.list_view_info);
infoListView.setAdapter(new ClusterAdapter(this, renderer, sourceText, shapingResult, IntList.of(initials).subList(0, cluster + 1)));
}
Aggregations