codebe / indic-text-renderer

Automatically exported from code.google.com/p/indic-text-renderer
Other
0 stars 0 forks source link

Is giving fontFilePath ="/sdcard/Android/data/org.iisc.mile.indictext.android/Lohit-Kannada.ttf"; is necessary #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
First of all thanks a lot for this awesome class.I need to implement this on my 
app,so that the app renders the font My sole purpose is only rendering correct 
font on my app only.For that also do I need to give the fontFilePath?
I can't understand all the codes of complex-script-rendering.c.So could you 
just hint me on how to proceed for this
Thanks in advance

Original issue reported on code.google.com by sant...@braindigit.com on 30 Sep 2012 at 6:40

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Actually I found on how to do it....After making the changes to 
complex-script-rendering.c, I need to recompile it again using the procedure 
defined on your wiki page.And further any path on your Device is ok
The thing I was doing wrong was,I was always running java compiler and didn't 
compile complex-script-rendering.c,due to which I wasn't getting any results
But your code compiles well to Lohit-Kannada.ttf only,but when I try to add any 
other file like Lohit-Devanagari.ttf,it doesn't render anything(this is same 
ReferenceTable overflow error mentioned on one of the issues)

Original comment by sant...@braindigit.com on 30 Sep 2012 at 10:35

Attachments:

GoogleCodeExporter commented 8 years ago
After going through lot of stackoverflow answers regarding "ReferenceTable 
overflow error",I found that on complex-script-rendering.c,there must be some 
freeing of memory or like. So on method draw_bitmap of 
complex-script-rendering.c,when I added these lines below codes
(*env)->ExceptionClear(env);
    (*env)->MonitorEnter(env, lock);
    (*env)->CallVoidMethod(env, jobj, mid, ret, xStart, yStart);
    (*env)->MonitorExit(env, lock);

(*env)->DeleteLocalRef(env,row);
    (*env)->DeleteLocalRef(env,ret);
    (*env)->DeleteLocalRef(env,cls);
I could get some more glyphs.Frankly speaking,I don't know what it does.Though 
this is not the permanent solution,I could view some of the fonts(if the text 
length is small).
So I sincerely request you to optimize complex-script-rendering.c  draw_bitmap 
method to accomodate other fonts and large length text.
Thanks in advance

Original comment by sanimap@gmail.com on 30 Sep 2012 at 12:54

GoogleCodeExporter commented 8 years ago
I did the same

     (*env)->DeleteLocalRef(env,row);

     (*env)->DeleteLocalRef(env,ret);
now it is showing text string  of 1024 length with font size 14. and  it is 
showing ReferenceTable overflow error when I increased the length of  text to 
be rendered  or increase the font size so to fix it  temporarily what i did is 
I have divided the String text into substring depending on  text font size  and 
calling drawIndicText in a loop and passing subString it is showing long string 
now 

private ArrayList<String> returnSubStringArr(String leftString){
        if(leftString.length() > substrSize ){
            String splittedString = leftString.substring(0 , substrSize );
            subStrList.add(splittedString);
            leftString = leftString.substring(substrSize);
            returnSubStringArr(leftString);
        }else{
            subStrList.add(leftString);
            return subStrList;  
        }
         return subStrList;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int count = getLineCount();
        String[] textLines = getText().toString().split("\\n");
        System.err.println("!!!!!Length " + textLines[0].length());
        Rect r = mRect;
        String val = null;
        StringBuffer charBuffer = new StringBuffer();
        for (int i = 0; i < count; i++) {

           savedCanvas = canvas;
           String currentText = 0 < textLines.length ? textLines[0] : "";
           ArrayList<String> strarr =  returnSubStringArr(currentText);
           int strLength = strarr.size();
           for(int j = 0 ; j < strLength ; j ++){
               int baseline = getLineBounds(j, r);
               drawIndicText(strarr.get(j), r.left, baseline, fontSize, lock,fontsPath[fontValue],fontsnam[fontValue]
                            );      
           }
                subStrList.clear();
        }
    }

Original comment by deep.NITT@gmail.com on 1 Oct 2012 at 3:41

GoogleCodeExporter commented 8 years ago
@deep.N:
Thank a lot for the reply and I am in the process of understanding your 
logic,but in your code
 drawIndicText(strarr.get(j), r.left, baseline, fontSize, lock,fontsPath[fontValue],fontsnam[fontValue]);
I couldn't understand two params fontsPath[fontValue] and fontsnam[fontValue] 
and further how should we modify this method
public native void drawIndicText(String unicodeText, int xStart,
            int yBaseLine, int charHeight, Boolean lock);
to take on two params.
Once again thanks a lot

Original comment by sant...@braindigit.com on 1 Oct 2012 at 5:22

GoogleCodeExporter commented 8 years ago
hi sant...@braindigit.com,
Actually we have to give font path (path where the lohit-font is saved in SD 
card) before it was hardcoded so  i have created an array of path and  taking 
value  from attributes.  User can define the font name in xml and according to 
the font needed i will pass the font path (as i am working on three to indic 
fonts) (Kannada , devnagri and tamil  ) so fontValue is the index which will 
define what font path i will need to display text.

and fontsnam is used to tell the font name as in  JNI method
Java_org_iisc_mile_indictext_android_EditIndicText_drawIndicText 
 we are setting hb buffer
//hb_buffer_set_direction(buffer, HB_DIRECTION_LTR); /* or LTR */
hb_buffer_set_script(buffer, HB_SCRIPT_KANNADA); /* see hb-unicode.h */

depending on font used this font name will tell what hb buffer we have to set 

i hae added if else condition in JNI method to suports multiple fonts i t is 
working fine i have tested for Edittext and textview now i am implementing it 
for check boxes 

Original comment by deep.NITT@gmail.com on 4 Oct 2012 at 2:48

GoogleCodeExporter commented 8 years ago
Dear Santosh and Deep, it's very fulfilling to know that this project has been 
of some use to you. Thank you for letting me know that.

There is something else that is needing my focus for next few months, and hence 
my interactions here will be very minimal.

Please continue with your efforts on this, and sometime next week I will 
incorporate your suggestions into the main source code.

Thanks again for your interest and commitment.

Original comment by shiv...@gmail.com on 4 Oct 2012 at 4:40

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi Deep ,
 On your second portion, how does "substrSize"  and "subStrList" fits??
And Deep and Shiva
          I have an urgent project which deadline is due this week.And this library is able to display text up to some character and some font size.I am not good at modifying "complex-rendering.c" so that I could accommodate any length character and any font size.
I have already tried everything from hit and trial until now,but now I don't 
have time for it.
So could you please,give me some logic on how proceed?

Thanks in advance

Original comment by sant...@braindigit.com on 27 Nov 2012 at 8:36

GoogleCodeExporter commented 8 years ago
Hi Santosh,
I am sorry, I won't be able to spend much time on this project for some more 
time. I have created some code walk through videos and pasted the link on 
http://mile.ee.iisc.ernet.in/~shivahr/Android_IndicTextRenderer/ . Please see 
if that helps.

Original comment by shiv...@gmail.com on 27 Nov 2012 at 1:30

GoogleCodeExporter commented 8 years ago
Thanks Shiv,
         I will look into it.And I have recently modified your complex-rendering.c in such a way,so that the user doesn't have to manually add font file to sdcard,instead it is added pro-grammatically and that path is passed to complex-rendering.c file.I think this would be more useful to anyone using this class.
        Further I think I need to understand more on IndicText  onDraw method so that I could implement Deep way of accommodating  text drawing.
        Once again,thanks.

Original comment by sant...@braindigit.com on 28 Nov 2012 at 4:14

GoogleCodeExporter commented 8 years ago
That's great Santosh. Programatically passing the location of font file was one 
of the pending tasks that were on my list. I am glad to know that you have done 
that. Please consider contributing your changes so that the main code stream on 
this site can have those changes as well for the benefit of others.

Original comment by shiv...@gmail.com on 29 Nov 2012 at 5:14

GoogleCodeExporter commented 8 years ago
Sure I will contribute it the source repo,but frankly speaking I don't know how 
to push repo here or simply mail you with the overall codes.

Original comment by sant...@braindigit.com on 6 Dec 2012 at 12:05

GoogleCodeExporter commented 8 years ago
Alternative solution is to use "/system/fonts/tunga.ttf" or any other font in 
that folder at the function
Java_org_iisc_mile_indictext_android_EditIndicText_drawIndicText
in complex-script-rendering.c file.

that way you only need to keep populating your system/font folder with the 
fonts that you need. And you dont need to create org.... folder just for fonts

Original comment by rgubb...@gmail.com on 21 Jan 2013 at 10:43