1

我正在通过 MUPDF 加载 PDF 文件,并添加了亮度等功能。我发现增加字体大小并突出显示加载的 pdf 中的一些文本有点困难,任何人都可以建议我在哪个文件上设置了大小和文本颜色。感谢任何帮助,我正在关注https://github.com/bhavyahmehta/Pdf-Reader---Writer/blob/master/Pdf_%20Reader_Writer/README.md。下面是我设置字体大小的代码。

            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);
            }
4

1 回答 1

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()));

    }
}
于 2016-02-19T06:57:56.937 回答