2013-06-26 15 views
1

我通過MUPDF加載PDF文件,並添加了亮度等功能。我發現有點難以增加字體大小,並突出顯示一些文本在加載的PDF可以有人建議我在哪個文件中設置大小和文本顏色。任何幫助表示讚賞我關注https://github.com/bhavyahmehta/Pdf-Reader---Writer/blob/master/Pdf_%20Reader_Writer/README.md。以下是我設置字體大小的代碼。在Android庫中設置PDF庫中的字體大小和HighLight文本MUPDF在Android中

  protected void onDraw(Canvas canvas) { 
       super.onDraw(canvas); 
       System.out.println("canvas"); 
       float scale = mSourceScale*(float)getWidth()/(float)mSize.x; 
       //Typeface tf = Typeface.create("Helvetica",Typeface.BOLD); 
       Paint paint = new Paint(); 
       //paint.setStyle((Style) PDFPaint.Style); 
       //paint.setTypeface(tf); 
        //canvas.drawText(scale,0,0,paint); 
       paint.setStrokeWidth(1); 
       paint.setAntiAlias(true); 
       paint.setTextSize(100); 
      } 

回答

1

試圖改變在下面的方法,你可以在ReaderView類找到

private void measureView(View v) { 
    // See what size the view wants to be 
    v.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); 

    if (!mReflow) { 
     // Work out a scale that will fit it to this view 
     float scale = Math.min((float) getWidth()/(float) v.getMeasuredWidth(),(float) getHeight()/(float) v.getMeasuredHeight()); 
     // Use the fitting values scaled by our current scale factor 
     v.measure(MeasureSpec.AT_MOST | (int) (v.getMeasuredWidth() * scale * mScale), MeasureSpec.AT_MOST | (int) (v.getMeasuredHeight() * (scale+0.6f) * mScale)); 
    } else { 
     v.measure(View.MeasureSpec.EXACTLY | (int) (v.getMeasuredWidth()), 
       View.MeasureSpec.EXACTLY | (int) (v.getMeasuredHeight())); 

    } 
} 
相關問題