Giter VIP home page Giter VIP logo

tehreer / tehreer-android Goto Github PK

View Code? Open in Web Editor NEW
88.0 8.0 16.0 32.97 MB

Standalone text engine for Android aimed to be free from platform limitations

License: Apache License 2.0

Java 4.41% Makefile 2.92% C++ 27.72% C 56.34% CMake 0.02% Shell 0.01% Python 1.57% Meson 0.19% Perl 0.09% Hack 5.19% Ragel 0.24% Kotlin 1.31%
unicode bidi uax-9 uax-24 opentype opentype-features text-shaping text-layout glyph-rendering text-rendering

tehreer-android's People

Contributors

mta452 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tehreer-android's Issues

Backward shaping order not working in typesetter

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.

Script analysis in typesetting process

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 .

java.lang.UnsatisfiedLinkError: Couldn't load tehreerjni from loader

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.

support for color glyphs

It should support color glyphs. CPAL/COLR opentype tables. Best solution will be to use harfbuzz for rendering.

Bidi support widget

Does this library provides widgets (Label etc) that support Bidi rendering?
Or what needs to be done to write such widget?

Null locale parameters on Samsung 4.x devices

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)
...

Chararacter measurement based on caret range distance

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.

Primitive Collections Testing

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.

Owned primitive raw lists

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.

Label disappears after setting text size

The steps to reproduce the issue are the following.

  • Set text of a TLabel with typesetter using setTypesetter() method.
  • Set text size of the label using setTextSize() method.
  • The label will become empty. If size is set before the typesetter, the label works as expected.

coloured text rendering

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

Strikeout position and thickness availability

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.

ClickableSpan support in widget

السلام علیکم ورحمة الله وبرکاته

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

Support for cluster splitting in multiple spans

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.

Any chance for iOS version?

السلام عليكم ورحمة الله وبركاته

@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:

  1. select standart architecture and build only for active in build settings (otherwise it compiles for i386)
  2. get ftapi.c from previous FT versions and place to base folder
  3. include ftgzip.c
  4. add this lines to it to fix error:
int z_verbose = 0;

void z_error(/* should be const */char* message)
{
    printf(message);
}
  1. do not comment out ttdriver in FT module config (otherwise app will fall with exception)

it's already better than stock, but it contains old bugs that were already fixed in tehreer

  • vertikal lines mentioned here #1 (comment)
  • expecting all bugs mentioned there present
  • some marks are not on places
  • there is no support for color rendering (attributed strings) which is implemented in tehreer in it's way
  • there is crash with one font (Quran_4.ttf) while it works well with tehreer

Enable module level optimization on JNI library

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.

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.