tehreer / tehreer-android Goto Github PK
View Code? Open in Web Editor NEWStandalone text engine for Android aimed to be free from platform limitations
License: Apache License 2.0
Standalone text engine for Android aimed to be free from platform limitations
License: Apache License 2.0
When script direction is opposite to that of bidi run direction, the rendered characters do not follow the bidi direction. For example, the string "\u202ELive on time"
should be rendered reversed due to the presence of RLO character in the beginning.
Currently, it is assumed that a right-to-left run has Arabic script while a left-to-right run has Latin script. Only these two scripts are passed to open type shaping engine, which can produce unexpected glyphs. It is true that the underlying SheenFigure
library does not support many scripts, but typesetter should pass the correct script tags and let the underlying engine handle the fallback mechanism.
This issue effectively dependent on #3 .
Hello I am currently upgrading my app from 2.0 to 2.1 of your library to fix the issues with Android 4.x.
At this line I am getting an UnsatisfiedLinkError:
tehreerTypeface = new com.mta.tehreer.graphics.Typeface(context.getAssets(), "fonts/font.ttf");
The Exception:
java.lang.UnsatisfiedLinkError: Couldn't load tehreerjni from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.jesusfilmmedia.android.jesusfilm-1.apk,libraryPath=/data/app-lib/com.jesusfilmmedia.android.jesusfilm-1]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:355)
at java.lang.System.loadLibrary(System.java:525)
at com.mta.tehreer.internal.JniBridge.loadLibrary(JniBridge.java:27)
at com.mta.tehreer.graphics.Typeface.<clinit>(Typeface.java:39)
...
This does not appear to be an issue on my Pixel (8.1), but it is an issue on my SamsungGalaxy S4 (Android 4.3)
Please let me know if I am doing something wrong or if I need to wait for this to be fixed on your side.
Android support annotations should be used throughout the project to improve code inspection. Nullability annotations are of particular importance.
Documentation: https://developer.android.com/studio/write/annotations
It should support color glyphs. CPAL/COLR opentype tables. Best solution will be to use harfbuzz for rendering.
it should support text justification.
Does this library provides widgets (Label etc) that support Bidi
rendering?
Or what needs to be done to write such widget?
For whatever reason Samsung devices are crashing in some cases (Android 4.x only).
Fatal Exception: java.lang.NullPointerException
at java.util.Locale.(Locale.java:273)
at com.mta.tehreer.sfnt.tables.NameTable$Record.locale(NameTable.java:165)
at com.mta.tehreer.graphics.TypefaceDescription.getEnglishName(TypefaceDescription.java:65)
at com.mta.tehreer.graphics.TypefaceDescription.getFamilyName(TypefaceDescription.java:97)
at com.mta.tehreer.graphics.TypefaceDescription.deduce(TypefaceDescription.java:143)
at com.mta.tehreer.graphics.Typeface.init(Typeface.java:133)
at com.mta.tehreer.graphics.Typeface.(Typeface.java:84)
...
Now that cluster splitting has been implemented for #10 with the use of character extents, it is a good time to replace traditional glyph-based measurement with character-based measurement. The idea is that character distances are calculated during the run creation phase, and then these are used to measure the character range irrespective of glyph advances. With this approach, the measurement could be much faster as it involves just a single subtraction of upper and lower distances.
The primitive collections are at the core of the library. Even a minor mistake can have a huge impact on the stability. General test cases should be available to check the correctness of concrete implementations.
Support for variable fonts is now available in both FreeType and SheenFigure. It should also be added in Tehreer-Android along with a working demo.
Currently, raw lists are always unowned which introduces an undefined behavior even for Finalizable objects. If GC decides to dispose the Finalizable object and its raw lists are still being used, they might cause the application to crash. So the Finalizable version of a native object should return owned raw lists holding the reference to the native object. This will prevent the GC of reclamation.
The steps to reproduce the issue are the following.
TLabel
with typesetter using setTypesetter()
method.setTextSize()
method.as-Salamu alaykum wa rahmatuLLahi wa barakatuh.
Brother please consider implementing coloured rendering in widget like regular textview does when applying setText with formatted strings like this:
<item><![CDATA[<br>some <font color="#00ff00">couloured</font> text]]></item>
<item><![CDATA[<br><font color="#2693ff">another</font> one]]></item>
Due to lack of knowledge of android internals and java in general i've only done partial demo app modification. Now it's accepting formatted strings like above example.
Here is gist with patch and images https://gist.github.com/AbdullahRusi/0a55169396653a06db3452ba79c7f4dd
As seen on screenshots standart textview lacks of good font rendering/shaping engine.
It produce many artifacts(broken ligatures, marks not on right places).
Your excellent library does that part (shaping and rendering glyphs) very well (besides vertical line).
On desctop firefox browser is correctly rendering that formatted text. As i know it uses Harfbuzz or something, so it's good.
so it may become very useful for many Muslims and big sawab(ajr) for you inshaaLLah
There should be an API to iterate over script runs as described in UAX #24
Currently a custom annotation, @Sustain
is being used for correct proguard behavior. It can be replaced with @Keep support annotation for the same purpose.
There should be an API to get the properties of a code point, such as:
The Typeface
class exposes properties to access underline position and thickness in font units. Similarly, strikeout position and thickness should also be made available. The info can be obtained from OS/2 table.
السلام علیکم ورحمة الله وبرکاته
Brother please consider implementing this useful feature, use cases include support of clicking on individual word, having some links with references etc
As of now widget doesn't have ClickableSpan support to use something like this:
static View.OnTouchListener ssilkaToch = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean ret = false;
CharSequence text = ((TextView) v).getText();
Spannable stext = Spannable.Factory.getInstance().newSpannable(text);
TextView widget = (TextView) v;
int action = event.getAction();
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = stext.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
link[0].onClick(widget);
}
ret = true;
}
}
return ret;
}
};
My use case is support of clicking on individual word and get it recitated or meaning searched through dictionary. Also needed setLineSpacing
Thank you for your effort and support
This issue is a continuation of discussion in #1
Consider three characters form a ligature, but its individual characters have different color spans. The typesetter does not break runs based on color spans, but whole ligature is rendered in a single color, which is a deviation from intended behavior. The same thing happens if multiple characters form a cluster, such as marks followed by a base.
As characters are not recognizable in a ligature/cluster, they can be estimated by dividing the total advance of the cluster with the number of characters in it. Then, the whole cluster should be rendered in defined edges with clipping mode.
The end result should be similar to the following image, where the estimated portion of س
and ت
is rendered in red color.
السلام عليكم ورحمة الله وبركاته
@mta452 Brother is there any chance for iOS version of your excellent library?
Got Xcode 11 GM and tested stock iOS 13 UITextView in simulator and found awful rendering with lots of glitches
with fonts which are working well in android when using your library.
Also i tried SheenFigureLegacy and managed to compile and run demo both with CG and latest FT (both seemed perform same)
last one required extra steps:
int z_verbose = 0; void z_error(/* should be const */char* message) { printf(message); }
it's already better than stock, but it contains old bugs that were already fixed in tehreer
Currently, native methods are being exported in the dynamic table even if they are not being used on Java side. This restricts the compiler to perform potential optimizations. By using visibility feature along with JNIEXPORT
and JNICALL
macros on shared functions, a much better binary can be produced.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.