public Bitmap buildUpdate(String time) { Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(this.getAssets(),"Clockopia.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(65); paint.setTextAlign(Align.CENTER); myCanvas.drawText(time, 80, 60, paint); return myBitmap; }
public void loadToPaint(Paint paint) { paint.setTextSize(rawTextSize); paint.setFakeBoldText(textFakeBold); paint.setStrikeThruText(textStrikeThru); paint.setColor(textColor); paint.setTypeface(textTypeface); paint.setUnderlineText(textUnderline); paint.setAntiAlias(antialias); paint.setSubpixelText(subpixelText); }
private void setupTextPaint() { mTextPaint.setSubpixelText(true); mTextPaint.setLinearText(true); mTextPaint.setTypeface(Typeface.MONOSPACE); mTextPaint.setColor(mTextColor); mTextPaint.setStyle(Style.FILL); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(mTextSize); if (textTypeface != null) { mTextPaint.setTypeface(textTypeface); } else { mTextPaint.setTypeface(Typeface.MONOSPACE); } }
int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, context.getResources().getDisplayMetrics()); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setStyle(Paint.Style.FILL); paint.setTextSize(textSize); paint.setColor(Color.WHITE); Canvas myCanvas = new Canvas(myBitmap); myCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); myCanvas.drawText(string, x, y, paint);
Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint.setColor(r.getColor(R.color.text_color)); textPaint.setFakeBoldText(true); textPaint.setSubpixelText(true); textPaint.setTextAlign(Align.LEFT);
Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); DisplayMetrics metrics = getResources().getDisplayMetrics(); int width = (int)((float)size.x/metrics.scaledDensity); Paint p = new Paint(); p.setTextSize(60); p.setSubpixelText(true); endChar = p.breakText(fullText, 0, endText, true, width, null);
public Bitmap myDrawText(Context context, String text, Typeface typeface, int textSize, int width, int height) { Bitmap myBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(typeface); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(textSize); paint.setTextAlign(Align.CENTER); myCanvas.drawText(text, (width / 2), 40, paint); return myBitmap; }
public Bitmap buildUpdate(String text) { Bitmap myBitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface mytypeface = Typeface.createFromAsset(this.getAssets(),"fontname.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(65); paint.setTextAlign(Align.CENTER); myCanvas.drawText(text, 80, 60, paint); return myBitmap; }
public ShadowView(Context context, boolean showShadowBar, boolean showBackground) { super(context); this.density = context.getResources().getDisplayMetrics().density; mShadowBarPaint = new Paint(); mShadowBarPaint.setDither(true); mShadowBarPaint.setAntiAlias(true); mShadowBarPaint.setSubpixelText(true); setShowColor(Color.BLACK, showShadowBar, showBackground); }
public Bitmap buildUpdate(String time) { Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(this.getAssets(),"robonto_condunced.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(65); paint.setTextAlign(Align.CENTER); myCanvas.drawText(time, 80, 60, paint); return myBitmap; }
protected Bitmap getWeatherIcon(String text, Context context) { Bitmap myBitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(context.getAssets(), "fonts/weather.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(150); paint.setTextAlign(Paint.Align.CENTER); myCanvas.drawText(text, 128, 180, paint); return myBitmap; }
public static TextLayout layoutText(AndroidGraphics gfx, String text, TextFormat format) { AndroidFont font = gfx.resolveFont(format.font); Paint paint = new Paint(format.antialias ? Paint.ANTI_ALIAS_FLAG : 0); paint.setTypeface(font.typeface); paint.setTextSize(font.size); paint.setSubpixelText(true); Paint.FontMetrics metrics = paint.getFontMetrics(); return new AndroidTextLayout(text, format, font, metrics, paint.measureText(text)); }
public static TextLayout layoutText(String text, TextFormat format) { AndroidFont font = (format.font == null) ? AndroidFont.DEFAULT : (AndroidFont)format.font; Paint paint = new Paint(format.antialias ? Paint.ANTI_ALIAS_FLAG : 0); paint.setTypeface(font.typeface); paint.setTextSize(font.size()); paint.setSubpixelText(true); Paint.FontMetrics metrics = paint.getFontMetrics(); return new AndroidTextLayout(text, format, font, metrics, paint.measureText(text)); }
public static Bitmap createWeatherIcon(Context context, String text) { Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); Typeface weatherFont = Typeface.createFromAsset(context.getAssets(), "fonts/weathericons-regular-webfont.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(weatherFont); paint.setStyle(Paint.Style.FILL); paint.setColor(AppPreference.getTextColor(context)); paint.setTextSize(180); paint.setTextAlign(Paint.Align.CENTER); canvas.drawText(text, 128, 200, paint); return bitmap; }
public static Bitmap createWeatherIcon(Context context, String text) { Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); Typeface weatherFont = Typeface.createFromAsset(context.getAssets(), "fonts/weathericons-regular-webfont.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(weatherFont); paint.setStyle(Paint.Style.FILL); paint.setColor(AppPreference.getTextColor(context)); paint.setTextSize(180); paint.setTextAlign(Paint.Align.CENTER); canvas.drawText(text, 128, 200, paint); return bitmap; }
public static Bitmap createWeatherIcon(Context context, String text) { Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); Typeface weatherFont = Typeface.createFromAsset(context.getAssets(), "fonts/weather-icons-v2.0.10.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(weatherFont); paint.setStyle(Paint.Style.FILL); paint.setColor(ContextCompat.getColor(context , R.color.textColor)); paint.setTextSize(180); paint.setTextAlign(Paint.Align.CENTER); canvas.drawText(text, 128, 200, paint); return bitmap; } }
public AtlasAvatar init(Picasso picasso) { mPicasso = picasso; mPaintInitials.setAntiAlias(true); mPaintInitials.setSubpixelText(true); mPaintBorder.setAntiAlias(true); mPaintBackground.setAntiAlias(true); mPaintBackground.setColor(getResources().getColor(R.color.atlas_avatar_background)); mPaintBorder.setColor(getResources().getColor(R.color.atlas_avatar_border)); mPaintInitials.setColor(getResources().getColor(R.color.atlas_avatar_text)); return this; }
public static TextLayout layoutText(String text, TextFormat format) { AndroidFont font = (format.font == null) ? AndroidFont.DEFAULT : (AndroidFont)format.font; Paint paint = new Paint(format.antialias ? Paint.ANTI_ALIAS_FLAG : 0); paint.setTypeface(font.typeface); paint.setTextSize(font.size()); paint.setSubpixelText(true); Paint.FontMetrics metrics = paint.getFontMetrics(); return new AndroidTextLayout(text, format, font, metrics, paint.measureText(text)); }
public static RemoteViews buildUpdate(Context context) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main); Bitmap myBitmap = Bitmap.createBitmap(100, 50, Bitmap.Config.ARGB_4444); Canvas myCanvas = new Canvas(myBitmap); Paint paint = new Paint(); Typeface clock = Typeface.createFromAsset(context.getAssets(),"Clockopia.ttf"); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setTypeface(clock); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.BLACK); paint.setTextSize(15); myCanvas.drawText("Test", 0, 20, paint); views.setImageViewBitmap(R.id.TimeView, myBitmap); return views; }
void draw(Canvas canvas, float x, float y, Paint paint) { boolean oldAA = paint.isAntiAlias(); paint.setAntiAlias(format.antialias); try { paint.setTypeface(font.typeface); paint.setTextSize(font.size()); paint.setSubpixelText(true); // if we're drawing REALLY BIG TEXT, draw to a path rather than directly drawing text to work // around KitKat bug: https://code.google.com/p/android/issues/detail?id=62800 if (font.size() > 250) { Path path = new Path(); paint.getTextPath(text, 0, text.length(), x, y - metrics.ascent, path); canvas.drawPath(path, paint); } else { canvas.drawText(text, x, y-metrics.ascent, paint); } } finally { paint.setAntiAlias(oldAA); } }