Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Khmer not support #57

Closed
bpbunthoeun opened this issue Jan 19, 2015 · 13 comments
Closed

Khmer not support #57

bpbunthoeun opened this issue Jan 19, 2015 · 13 comments

Comments

@bpbunthoeun
Copy link

Thank you so much for you library it is very helpful, but I got the problem when I use it with Khmer unicode. it doesn't working well. Can you please help me to to finger-out this problem.
Thank you.
Bunthoeun

screen shot 2015-01-19 at 2 55 13 pm
screenshot_2015-01-19-15-04-37

@mathew-kurian
Copy link
Owner

It is because your words are too long. What you can try to do is increase the font size. Make sure to use DocumentView.FORMATTED_TEXT.

@bpbunthoeun
Copy link
Author

Here is my java :

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //DocumentView documentView = (DocumentView) findViewById(R.id.doc_view1);
    DocumentView documentView = new DocumentView(this, DocumentView.FORMATTED_TEXT);
    documentView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
    documentView.getDocumentLayoutParams().setHyphenated(true);

}

}

But still get the same result.
Thank you.
Bunthoeun

@mathew-kurian
Copy link
Owner

Your words are too long. Give me a day or two to add support for this.


Sent from Mailbox

On Mon, Jan 19, 2015 at 2:18 AM, Bunthoeun notifications@github.com
wrote:

Here is my java :
public class MainActivity extends Activity {
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//DocumentView documentView = (DocumentView) findViewById(R.id.doc_view1);
DocumentView documentView = new DocumentView(this, DocumentView.FORMATTED_TEXT);
documentView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
documentView.getDocumentLayoutParams().setHyphenated(true);

}

}
But still get the same result.
Thank you.

Bunthoeun

Reply to this email directly or view it on GitHub:
#57 (comment)

@bpbunthoeun
Copy link
Author

Yes thank you so much. I can give some string: សៀវភៅដំបូងដែលគ្រឹះស្ថាន «ប្រភពប្រាជ្ញា» បានបោះពុម្ពនោះ គឺជាស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ ដែលជាការបកស្រាយអំពីកណ្ឌអេភេសូរ។ ទោះបើអ្នកប្រាជ្ញខាងគម្ពីរ និង អ្នកនិពន្ធរូបនេះ បានចែកឋានប៉ុន្មានអាទិត្យមុនពេល ដែលសៀវភៅនេះបានចែកចាយក៏ដោយ ក៏ស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ នៅតែដក់ជាប់ក្នុងចិត្តមនុស្សគ្រប់ជំនាន់ តាមរយៈសៀវភៅនេះដែរ។ បច្ចុប្បន្ននេះ «ប្រភពប្រាជ្ញា» មានទីតាំងនៅផ្ទះលេខ១១អា ផ្លូវលេខ២០០២ សង្កាត់ទឹកថ្លា ខណ្ឌសែនសុខ រាជធានីភ្នំពេញ។ មានបុគ្គលិកពេពេលជាជនជាតិខ្មែរ១១នាក់ សុទ្ធសឹងតែជាអ្នកមានជំនាញខ្ពស់ក្នុងវិស័យបោះពុម្ពផ្សាយ។ នោះជានិមិត្តចុងក្រោយរបស់លោកស្ទីវចំពោះ «ប្រភពប្រាជ្ញា» ដែលចង់ឃើញគ្រីស្ទបរិស័ទខ្មែរ ដឹកនាំពន្ធ័កិច្ចបោះពុម្ពផ្សាយដ៏សំខាន់នេះឆ្ពោះទៅពេលអនាគតដោយប្រសិទ្ធភាព។

@mathew-kurian
Copy link
Owner

@bpbunthoeun You can build your custom hyphenator for this. This way it will break the words at the right places. If you use the built in SqueezeHyphenator, then your words should fit better into one line. Make sure to use DocumentView.PLAIN_TEXT in order to achieve this and update to version 2.0.6

documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
documentView.getDocumentLayoutParams().setHyphenated(true);

If you are having trouble, refer to CustomHyphenatorTest. Let me know how this goes for you. In the event, you don't like this hyphenator, you can build your own Hyphenator, just extend IHyphenator

@bpbunthoeun
Copy link
Author

Dear Mathew, Thanks you very much for you answer, But I just get some error when use this DocumentView documentView = addDocumentView(new StringBuilder()
.append(getResources().getString(R.string.zero_spacing))
.toString(), DocumentView.PLAIN_TEXT);. I got red color on addDocumentView.

Here is my full java I just tries to copy your example come to test how it going:

package com.cambobox.documentview;

import android.app.Activity;
import android.os.Bundle;

import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
import com.bluejamesbond.text.style.TextAlignment;

public class MainActivity extends Activity {
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    DocumentView documentView = addDocumentView(new StringBuilder()
            .append(getResources().getString(R.string.zero_spacing))
            .toString(), DocumentView.PLAIN_TEXT);

    documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
    documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
    documentView.getDocumentLayoutParams().setHyphenated(true);
}

}

Thank you hope you are don't mind I'm not good in code. :)

@mathew-kurian
Copy link
Owner

It should look more like this:

package com.cambobox.documentview;

import android.app.Activity;
import android.os.Bundle;

import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
import com.bluejamesbond.text.style.TextAlignment;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // set layout
        setContentView(R.layout.activity_main);

        // text you want
        String text = "សៀវភៅដំបូងដែលគ្រឹះស្ថាន «ប្រភពប្រាជ្ញា» បានបោះពុម្ពនោះ គឺជាស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ ដែលជាការបកស្រាយអំពីកណ្ឌអេភេសូរ។ ទោះបើអ្នកប្រាជ្ញខាងគម្ពីរ និង អ្នកនិពន្ធរូបនេះ បានចែកឋានប៉ុន្មានអាទិត្យមុនពេល ដែលសៀវភៅនេះបានចែកចាយក៏ដោយ ក៏ស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ នៅតែដក់ជាប់ក្នុងចិត្តមនុស្សគ្រប់ជំនាន់ តាមរយៈសៀវភៅនេះដែរ។ បច្ចុប្បន្ននេះ «ប្រភពប្រាជ្ញា» មានទីតាំងនៅផ្ទះលេខ១១អា ផ្លូវលេខ២០០២ សង្កាត់ទឹកថ្លា ខណ្ឌសែនសុខ រាជធានីភ្នំពេញ។ មានបុគ្គលិកពេពេលជាជនជាតិខ្មែរ១១នាក់ សុទ្ធសឹងតែជាអ្នកមានជំនាញខ្ពស់ក្នុងវិស័យបោះពុម្ពផ្សាយ។ នោះជានិមិត្តចុងក្រោយរបស់លោកស្ទីវចំពោះ «ប្រភពប្រាជ្ញា» ដែលចង់ឃើញគ្រីស្ទបរិស័ទខ្មែរ ដឹកនាំពន្ធ័កិច្ចបោះពុម្ពផ្សាយដ៏សំខាន់នេះឆ្ពោះទៅពេលអនាគតដោយប្រសិទ្ធភាព។";

        // create DocumentView
        DocumentView documentView = new DocumentView(this, DocumentView.PLAIN_TEXT);

        // set the properties
        documentView.getDocumentLayoutParams().setTextColor(0xffffffff);
        documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
        documentView.getDocumentLayoutParams().setTextSize(14);
        documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
        documentView.getDocumentLayoutParams().setInsetPaddingLeft(30f);
        documentView.getDocumentLayoutParams().setInsetPaddingRight(30f);
        documentView.getDocumentLayoutParams().setInsetPaddingTop(30f);
        documentView.getDocumentLayoutParams().setInsetPaddingBottom(30f);
        documentView.getDocumentLayoutParams().setLineHeightMultiplier(1f);
        documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
        documentView.getDocumentLayoutParams().setHyphenated(true);

        // set text
        documentView.setText(text)

        // ****************** you have to edit this ******************
        ((SomeLayout) findViewById(R.id.some_layout)).addView(documentView)
    }
}

@bpbunthoeun
Copy link
Author

OK This is my Java screenshot:
java

@mathew-kurian
Copy link
Owner

Ok. I provided u with the code in my last post. Try that out.


Sent from Mailbox

On Tue, Jan 20, 2015 at 11:40 PM, Bunthoeun notifications@github.com
wrote:

OK This is my Java screenshot:

java

Reply to this email directly or view it on GitHub:
#57 (comment)

@bpbunthoeun
Copy link
Author

Thank you but please tell me what should I edit in your code? this is my XML :

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.bluejamesbond.text.DocumentView
        xmlns:ext="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/dc_view1"
        ext:documentView_textAlignment="justified"
        ext:documentView_textFormat="plain"
        ext:documentView_textSubPixel="true">

        </com.bluejamesbond.text.DocumentView>

</LinearLayout>

@bpbunthoeun
Copy link
Author

"Unfortunately, Document View has stopped" this is the message that I got when I run on my phone. and this some code that I edited
// ****************** you have to edit this ******************
((DocumentView) findViewById(R.id.dc_view1)).addView(documentView);
}
Thank you..

@mathew-kurian
Copy link
Owner

You should study more about Android, but I will help you here.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingTop="15dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <LinearLayout
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</LinearLayout>

MainActivity.java

package com.cambobox.documentview;

import android.app.Activity;
import android.os.Bundle;

import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
import com.bluejamesbond.text.style.TextAlignment;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // set layout
        setContentView(R.layout.activity_main);

        // text you want
        String text = "សៀវភៅដំបូងដែលគ្រឹះស្ថាន «ប្រភពប្រាជ្ញា» បានបោះពុម្ពនោះ គឺជាស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ ដែលជាការបកស្រាយអំពីកណ្ឌអេភេសូរ។ ទោះបើអ្នកប្រាជ្ញខាងគម្ពីរ និង អ្នកនិពន្ធរូបនេះ បានចែកឋានប៉ុន្មានអាទិត្យមុនពេល ដែលសៀវភៅនេះបានចែកចាយក៏ដោយ ក៏ស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ នៅតែដក់ជាប់ក្នុងចិត្តមនុស្សគ្រប់ជំនាន់ តាមរយៈសៀវភៅនេះដែរ។ បច្ចុប្បន្ននេះ «ប្រភពប្រាជ្ញា» មានទីតាំងនៅផ្ទះលេខ១១អា ផ្លូវលេខ២០០២ សង្កាត់ទឹកថ្លា ខណ្ឌសែនសុខ រាជធានីភ្នំពេញ។ មានបុគ្គលិកពេពេលជាជនជាតិខ្មែរ១១នាក់ សុទ្ធសឹងតែជាអ្នកមានជំនាញខ្ពស់ក្នុងវិស័យបោះពុម្ពផ្សាយ។ នោះជានិមិត្តចុងក្រោយរបស់លោកស្ទីវចំពោះ «ប្រភពប្រាជ្ញា» ដែលចង់ឃើញគ្រីស្ទបរិស័ទខ្មែរ ដឹកនាំពន្ធ័កិច្ចបោះពុម្ពផ្សាយដ៏សំខាន់នេះឆ្ពោះទៅពេលអនាគតដោយប្រសិទ្ធភាព។";

        // create DocumentView
        DocumentView documentView = new DocumentView(this, DocumentView.PLAIN_TEXT);

        // set the properties
        documentView.getDocumentLayoutParams().setTextColor(0xffffffff);
        documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
        documentView.getDocumentLayoutParams().setTextSize(14);
        documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
        documentView.getDocumentLayoutParams().setInsetPaddingLeft(30f);
        documentView.getDocumentLayoutParams().setInsetPaddingRight(30f);
        documentView.getDocumentLayoutParams().setInsetPaddingTop(30f);
        documentView.getDocumentLayoutParams().setInsetPaddingBottom(30f);
        documentView.getDocumentLayoutParams().setLineHeightMultiplier(1f);
        documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
        documentView.getDocumentLayoutParams().setHyphenated(true);

         // set text
        documentView.setText(text)

        // add to layout
        ((LinearLayout) findViewById(R.id.main_layout)).addView(documentView)
    }
}

@bpbunthoeun
Copy link
Author

Yes, thank you very much you.. it is working ..... 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants