Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text being cut off from front for a particular font

The first letter of each word on new line is cut off for us denealian cursive font.enter image description here

see the picture this one is with padding.If I am not using any padding ,it will be like in pic 2 enter image description here

This is my code

<com.font.anything.writinghelper
    android:id="@+id/textView" 
   android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textColor="#000000"
    android:padding="20dip"
    android:textSize="60sp"
    android:text="japanese google donkey elephant ostrich"
    />

Here writing helper is a class extending textview just to underline the text

     protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    Rect r = mRect;
    int padding =55;
    Paint paint = mPaint;
    int count = getLineCount();
    for (int i = 0; i < count; i++) {
    int baseline = getLineBounds(i, r);
    canvas.drawLine(r.left - padding, baseline, r.right + padding,
            baseline, paint);
    }
    super.onDraw(canvas);
}

Can anyone help.?

Edit

Requested screenshot

enter image description here

Is There a way to put some extra space towards left side of the TextView ?

like image 203
sunil sunny Avatar asked Feb 18 '15 05:02

sunil sunny


People also ask

Why is word cutting off the top of my font?

The zoom percentage that the document is set to may cause characters to have the top or bottom portion of the screen font cut off. You can adjust the zoom percentage from 75 percent to 100 percent in most cases to correct this visually.

Why is my font getting cut off in Powerpoint?

This can happen when you use a font designed by an amateur, or when the line spacing is set below about Multiple 0.75 or when line spacing is set to Exact and the measurement is less that the size of the text. Posting a screen shot of your paragraph settings would also help.


1 Answers

Finally I made a work around for this..It's a font issue and I am not sure it can be fixed by any other way.So what I have done is ,first get the TextView Layout and get the end and start of each line and hence obtain string in each line.Now append space in front of each line .Here is the entire code.May help someone else.

    ArrayList<String> lines = new ArrayList<String>();
    ArrayList<String> newLines = new ArrayList<String>();
    String line="";
    String text = getText().toString();
    Layout layout = getLayout();
    int start=0;
    int end;

    for (int i=0; i<count; i++) {
        end = layout.getLineEnd(i);

        lines.add(text.substring(start,end));
        line = lines.get(i);
        start = end;
        String nwText = "";
        nwText = " "+ line+" ";
        newLines.add(nwText);
    }
    Paint mPaint = getPaint();
    int i = 0;
   // String[] textLines = Results.split("\\n+");
    //float textsize = getTextSize();

    for (String textLine : newLines)
    {
       // mPaint.setTextSize(textsize);
        int baseline = getLineBounds(i, r);
        canvas.drawText(textLine, 0, baseline, mPaint);
       i++;
    }
like image 122
sunil sunny Avatar answered Oct 22 '22 10:10

sunil sunny