Java Code Examples for android.graphics.Paint.DEV_KERN_TEXT_FLAG

The following are Jave code examples for showing how to use DEV_KERN_TEXT_FLAG of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Quran   File: HighlightingImageView.java   View Source Code Vote up 6 votes
public void setOverlayText(String suraText, String juzText, String pageText, String rub3Text) {
  // Calculate page bounding rect from ayahinfo db
  if (pageBounds == null) {
    return;
  }

  overlayParams = new OverlayParams();
  overlayParams.suraText = suraText;
  overlayParams.juzText = juzText;
  overlayParams.pageText = pageText;
  overlayParams.rub3Text = rub3Text;
  overlayParams.paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
  overlayParams.paint.setTextSize(fontSize);

  if (!didDraw) {
    invalidate();
  }
}
 
Example 2
Project: stynico   File: FileUtil.java   View Source Code Vote up 5 votes
private   boolean saveMyBitmap(Bitmap bitmap,String name ,String... str) {
        int destWidth = bitmap.getWidth();   //此处的bitmap已经限定好宽高
        int destHeight = bitmap.getHeight();
       // Log.v("addWatermarkBitmap","width = " + destWidth+" height = "+destHeight);
        Bitmap icon = Bitmap.createBitmap(destWidth, destHeight, Bitmap.Config.ARGB_8888); //定好宽高的全彩bitmap
        Canvas canvas = new Canvas(icon);//初始化画布绘制的图像到icon上

        Paint photoPaint = new Paint(); //建立画笔
        photoPaint.setDither(true); //获取跟清晰的图像采样
        photoPaint.setFilterBitmap(true);//过滤一些

        Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());//创建一个指定的新矩形的坐标
        Rect dst = new Rect(0, 0, destWidth, destHeight);//创建一个指定的新矩形的坐标
        canvas.drawBitmap(bitmap, src, dst, photoPaint);//将photo 缩放或则扩大到 dst使用的填充区photoPaint

        Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);//设置画笔
        textPaint.setTextSize(destWidth/30);//字体大小
        textPaint.setTextAlign(Paint.Align.CENTER);
        textPaint.setTypeface(Typeface.DEFAULT_BOLD);//采用默认的宽度
        textPaint.setAntiAlias(true);  //抗锯齿
        textPaint.setStrokeWidth(1);
        textPaint.setAlpha(115);
        textPaint.setStyle(Paint.Style.STROKE); //空心
        textPaint.setColor(Color.WHITE);//采用的颜色
        textPaint.setShadowLayer(1f, 0f, 1f, Color.LTGRAY);
        int i = 0;
        for (String s : str) {
            if(!TextUtils.isEmpty(s)) {
                i++;
                canvas.drawText(s, destWidth / 2, destHeight - 45 * i, textPaint);//绘制上去字,开始未知x,y采用那只笔绘制
            }
        }
        canvas.save(Canvas.ALL_SAVE_FLAG);
        canvas.restore();
        bitmap.recycle();
        return saveMyBitmap(icon,name); //保存至文件
//        return true;
    }