List of usage examples for android.graphics Paint setAntiAlias
public void setAntiAlias(boolean aa)
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
/** * @param r//from ww w .j a v a 2 s.co m * @param canvas * @param p */ private void drawBgColors(Rect r, Canvas canvas, Paint p) { int todayIndex = mTodayJulianDay - mFirstJulianDay; // Draw the hours background color r.top = mDestRect.top; r.bottom = mDestRect.bottom; r.left = 0; r.right = mHoursWidth; p.setColor(mBgColor); p.setStyle(Style.FILL); p.setAntiAlias(false); canvas.drawRect(r, p); // Draw background for grid area if (mNumDays == 1 && todayIndex == 0) { // Draw a white background for the time later than current time int lineY = mCurrentTime.hour * (mCellHeight + HOUR_GAP) + ((mCurrentTime.minute * mCellHeight) / 60) + 1; if (lineY < mViewStartY + mViewHeight) { lineY = Math.max(lineY, mViewStartY); r.left = mHoursWidth; r.right = mViewWidth; r.top = lineY; r.bottom = mViewStartY + mViewHeight; p.setColor(mFutureBgColor); canvas.drawRect(r, p); } } else if (todayIndex >= 0 && todayIndex < mNumDays) { // Draw today with a white background for the time later than current time int lineY = mCurrentTime.hour * (mCellHeight + HOUR_GAP) + ((mCurrentTime.minute * mCellHeight) / 60) + 1; if (lineY < mViewStartY + mViewHeight) { lineY = Math.max(lineY, mViewStartY); r.left = computeDayLeftPosition(todayIndex) + 1; r.right = computeDayLeftPosition(todayIndex + 1); r.top = lineY; r.bottom = mViewStartY + mViewHeight; p.setColor(mFutureBgColor); canvas.drawRect(r, p); } // Paint Tomorrow and later days with future color if (todayIndex + 1 < mNumDays) { r.left = computeDayLeftPosition(todayIndex + 1) + 1; r.right = computeDayLeftPosition(mNumDays); r.top = mDestRect.top; r.bottom = mDestRect.bottom; p.setColor(mFutureBgColor); canvas.drawRect(r, p); } } else if (todayIndex < 0) { // Future r.left = computeDayLeftPosition(0) + 1; r.right = computeDayLeftPosition(mNumDays); r.top = mDestRect.top; r.bottom = mDestRect.bottom; p.setColor(mFutureBgColor); canvas.drawRect(r, p); } p.setAntiAlias(true); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void drawDayHeaderLoop(Rect r, Canvas canvas, Paint p) { p.setTypeface(mBold);/*ww w. jav a 2 s.co m*/ p.setTextAlign(Align.RIGHT); int cell = mFirstJulianDay; String[] dayNames; if (mDateStrWidthLong < mCellWidth && mNumDays == 1) { dayNames = mDayStrsLong; } else if (mDateStrWidth < mCellWidth) { dayNames = mDayStrs; } else { dayNames = mDayStrs2Letter; } p.setAntiAlias(true); for (int day = 0; day < mNumDays; day++, cell++) { int dayOfWeek = day + mFirstVisibleDayOfWeek; if (dayOfWeek >= 14) { dayOfWeek -= 14; } int color = mCalendarDateBannerTextColor; if (mNumDays == 1) { if (dayOfWeek == Time.SATURDAY) { color = mWeek_saturdayColor; } else if (dayOfWeek == Time.SUNDAY) { color = mWeek_sundayColor; } } else { final int column = day % 7; if (DayUtils.isSaturday(column, mFirstDayOfWeek)) { color = mWeek_saturdayColor; } else if (DayUtils.isSunday(column, mFirstDayOfWeek)) { color = mWeek_sundayColor; } } p.setColor(color); if (mNumDays == 1) { Time time = new Time(); time.setJulianDay(mFirstJulianDay); String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false))); drawDayHeader(dayNames[dayOfWeek], day, s, canvas, p); } else { int dateNum = mFirstVisibleDate + day; if (dateNum > mMonthLength) { dateNum -= mMonthLength; } drawDayHeader(dayNames[dayOfWeek], day, String.valueOf(dateNum), canvas, p); } } p.setTypeface(null); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void drawGridBackground(Rect r, Canvas canvas, Paint p) { Style savedStyle = p.getStyle(); final float stopX = computeDayLeftPosition(mNumDays); float y = 0;//from w w w .j a v a 2 s. co m final float deltaY = mCellHeight + HOUR_GAP; int linesIndex = 0; final float startY = 0; final float stopY = HOUR_GAP + 24 * (mCellHeight + HOUR_GAP); float x = mHoursWidth; // Draw the inner horizontal grid lines p.setColor(mCalendarGridLineInnerHorizontalColor); p.setStrokeWidth(GRID_LINE_INNER_WIDTH); p.setAntiAlias(false); y = 0; linesIndex = 0; for (int hour = 0; hour <= 24; hour++) { mLines[linesIndex++] = GRID_LINE_LEFT_MARGIN; mLines[linesIndex++] = y; mLines[linesIndex++] = stopX; mLines[linesIndex++] = y; y += deltaY; } if (mCalendarGridLineInnerVerticalColor != mCalendarGridLineInnerHorizontalColor) { canvas.drawLines(mLines, 0, linesIndex, p); linesIndex = 0; p.setColor(mCalendarGridLineInnerVerticalColor); } // Draw the inner vertical grid lines for (int day = 0; day <= mNumDays; day++) { x = computeDayLeftPosition(day); mLines[linesIndex++] = x; mLines[linesIndex++] = startY; mLines[linesIndex++] = x; mLines[linesIndex++] = stopY; } canvas.drawLines(mLines, 0, linesIndex, p); // Restore the saved style. p.setStyle(savedStyle); p.setAntiAlias(true); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private Rect drawEventRect(Event event, Canvas canvas, Paint p, Paint eventTextPaint, int visibleTop, int visibleBot) { // Draw the Event Rect Rect r = mRect;//ww w . j a v a 2s. c o m r.top = Math.max((int) event.top + EVENT_RECT_TOP_MARGIN, visibleTop); r.bottom = Math.min((int) event.bottom - EVENT_RECT_BOTTOM_MARGIN, visibleBot); r.left = (int) event.left + EVENT_RECT_LEFT_MARGIN; r.right = (int) event.right; int color; if (event == mClickedEvent) { color = mClickedColor; } else { color = event.color; } p.setStyle(Style.FILL_AND_STROKE); p.setAntiAlias(false); int floorHalfStroke = (int) Math.floor(EVENT_RECT_STROKE_WIDTH / 2.0f); int ceilHalfStroke = (int) Math.ceil(EVENT_RECT_STROKE_WIDTH / 2.0f); r.top = Math.max((int) event.top + EVENT_RECT_TOP_MARGIN + floorHalfStroke, visibleTop); r.bottom = Math.min((int) event.bottom - EVENT_RECT_BOTTOM_MARGIN - ceilHalfStroke, visibleBot); r.left += floorHalfStroke; r.right -= ceilHalfStroke; p.setStrokeWidth(EVENT_RECT_STROKE_WIDTH); p.setColor(color); int alpha = p.getAlpha(); p.setAlpha(mEventsAlpha); canvas.drawRect(r, p); p.setAlpha(alpha); p.setStyle(Style.FILL); // If this event is selected, then use the selection color if (mSelectedEvent == event && mClickedEvent != null) { boolean paintIt = false; color = 0; if (paintIt) { p.setColor(color); canvas.drawRect(r, p); } p.setAntiAlias(true); } // Setup rect for drawEventText which follows r.top = (int) event.top + EVENT_RECT_TOP_MARGIN; r.bottom = (int) event.bottom - EVENT_RECT_BOTTOM_MARGIN; r.left = (int) event.left + EVENT_RECT_LEFT_MARGIN; r.right = (int) event.right - EVENT_RECT_RIGHT_MARGIN; return r; }
From source file:com.cssweb.android.view.KlineView.java
public void drawQuoteWin(Canvas canvas, JSONObject quoteData, int idx) throws JSONException { Paint mPaint = new Paint(); mPaint.setTextAlign(Paint.Align.LEFT); mPaint.setStyle(Paint.Style.STROKE); mPaint.setTypeface(Typeface.DEFAULT_BOLD); mPaint.setAntiAlias(true); mPaint.setColor(GlobalColor.colorKlinePopub); mPaint.setTextSize(sTextSize);/* w w w. j a va2 s . c o m*/ canvas.drawText(":", 0, axisLabelHeight, mPaint); canvas.drawText(":", 0, axisLabelHeight * 3, mPaint); canvas.drawText(":", 0, axisLabelHeight * 5, mPaint); canvas.drawText(":", 0, axisLabelHeight * 7, mPaint); canvas.drawText(":", 0, axisLabelHeight * 9, mPaint); canvas.drawText(":", 0, axisLabelHeight * 11, mPaint); canvas.drawText("??:", 0, axisLabelHeight * 13, mPaint); canvas.drawText("??:", 0, axisLabelHeight * 15, mPaint); mPaint.setTextAlign(Paint.Align.RIGHT); String qt = quoteData.getJSONArray("K").getJSONArray(idx).getString(0); double jrkp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(1); double zg = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(2); double zd = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(3); double sp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4); double preclose; if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) { switch (idx) { case 0: preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(7); break; default: preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(7); break; } if (quoteData.getJSONArray("K").length() == 1) { preclose = quoteData.getJSONArray("K").getJSONArray(0).getDouble(7); } } else { switch (idx) { case 0: preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4); break; default: preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(4); break; } if (quoteData.getJSONArray("K").length() == 1) { preclose = quoteData.getDouble("zrsp");//quoteData.getJSONArray("K").getJSONArray(0).getDouble(4); } } mPaint.setColor(getcolor(jrkp, preclose)); canvas.drawText(Utils.dataFormation(jrkp, stockdigit), klineX, axisLabelHeight * 2, mPaint); mPaint.setColor(getcolor(zg, preclose)); canvas.drawText(Utils.dataFormation(zg, stockdigit), klineX, axisLabelHeight * 4, mPaint); mPaint.setColor(getcolor(zd, preclose)); canvas.drawText(Utils.dataFormation(zd, stockdigit), klineX, axisLabelHeight * 6, mPaint); mPaint.setColor(getcolor(sp, preclose)); canvas.drawText(Utils.dataFormation(sp, stockdigit), klineX, axisLabelHeight * 8, mPaint); double zhangdie = sp - preclose; if (zhangdie > 0) mPaint.setColor(GlobalColor.colorpriceUp); else if (zhangdie < 0) mPaint.setColor(GlobalColor.colorPriceDown); else mPaint.setColor(GlobalColor.colorPriceEqual); canvas.drawText(Utils.dataFormation(zhangdie, stockdigit), klineX, axisLabelHeight * 10, mPaint); // if(quoteData.getString("period").equals("min5") || // quoteData.getString("period").equals("min15") || // quoteData.getString("period").equals("min30") || // quoteData.getString("period").equals("min60")){ // qt = qt.substring(4,6)+'/'+qt.substring(6,8)+' '+qt.substring(8); // }else{ // qt = qt.substring(2,4)+qt.substring(4,6)+qt.substring(6,8); // } qt = qt.substring(2, 4) + qt.substring(4, 6) + qt.substring(6, 8); mPaint.setColor(GlobalColor.colorLabelName); canvas.drawText(qt, klineX, axisLabelHeight * 12, mPaint); mPaint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(quoteData.getJSONArray("K").getJSONArray(idx).getDouble(5), false), klineX, axisLabelHeight * 14, mPaint); mPaint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(quoteData.getJSONArray("K").getJSONArray(idx).getDouble(6), false), klineX, axisLabelHeight * 16, mPaint); }
From source file:g7.bluesky.launcher3.Launcher.java
public void loadIconPack(List<ShortcutInfo> shortcuts) { //theming vars----------------------------------------------- PackageManager pm = getPackageManager(); final int ICONSIZE = Tools.numtodp(128, Launcher.this); Resources themeRes = null;/* w w w. ja v a 2 s . c o m*/ String resPacName = defaultSharedPref.getString(SettingConstants.ICON_THEME_PREF_KEY, ""); String iconResource = null; int intres = 0; int intresiconback = 0; int intresiconfront = 0; int intresiconmask = 0; float scaleFactor = 1.0f; Paint p = new Paint(Paint.FILTER_BITMAP_FLAG); p.setAntiAlias(true); Paint origP = new Paint(Paint.FILTER_BITMAP_FLAG); origP.setAntiAlias(true); Paint maskp = new Paint(Paint.FILTER_BITMAP_FLAG); maskp.setAntiAlias(true); maskp.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); if (resPacName.compareTo("") != 0) { try { themeRes = pm.getResourcesForApplication(resPacName); } catch (Exception e) { } ; if (themeRes != null) { String[] backAndMaskAndFront = ThemeTools.getIconBackAndMaskResourceName(themeRes, resPacName); if (backAndMaskAndFront[0] != null) intresiconback = themeRes.getIdentifier(backAndMaskAndFront[0], "drawable", resPacName); if (backAndMaskAndFront[1] != null) intresiconmask = themeRes.getIdentifier(backAndMaskAndFront[1], "drawable", resPacName); if (backAndMaskAndFront[2] != null) intresiconfront = themeRes.getIdentifier(backAndMaskAndFront[2], "drawable", resPacName); } } BitmapFactory.Options uniformOptions = new BitmapFactory.Options(); uniformOptions.inScaled = false; uniformOptions.inDither = false; uniformOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; Canvas origCanv; Canvas canvas; scaleFactor = ThemeTools.getScaleFactor(themeRes, resPacName); Bitmap back = null; Bitmap mask = null; Bitmap front = null; Bitmap scaledBitmap = null; Bitmap scaledOrig = null; Bitmap orig = null; if (resPacName.compareTo("") != 0 && themeRes != null) { try { if (intresiconback != 0) back = BitmapFactory.decodeResource(themeRes, intresiconback, uniformOptions); } catch (Exception e) { } try { if (intresiconmask != 0) mask = BitmapFactory.decodeResource(themeRes, intresiconmask, uniformOptions); } catch (Exception e) { } try { if (intresiconfront != 0) front = BitmapFactory.decodeResource(themeRes, intresiconfront, uniformOptions); } catch (Exception e) { } } //theming vars----------------------------------------------- BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = false; options.inPreferredConfig = Bitmap.Config.RGB_565; options.inDither = true; for (int i = 0; i < shortcuts.size(); i++) { if (themeRes != null) { iconResource = null; intres = 0; iconResource = ThemeTools.getResourceName(themeRes, resPacName, shortcuts.get(i).getTargetComponent().toString()); if (iconResource != null) { intres = themeRes.getIdentifier(iconResource, "drawable", resPacName); } if (intres != 0) {//has single drawable for app shortcuts.get(i).setIcon(BitmapFactory.decodeResource(themeRes, intres, uniformOptions)); } else { Drawable drawable = Utilities.createIconDrawable(shortcuts.get(i).getIcon(mIconCache)); orig = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(new Canvas(orig)); scaledOrig = Bitmap.createBitmap(ICONSIZE, ICONSIZE, Bitmap.Config.ARGB_8888); scaledBitmap = Bitmap.createBitmap(ICONSIZE, ICONSIZE, Bitmap.Config.ARGB_8888); canvas = new Canvas(scaledBitmap); if (back != null) { canvas.drawBitmap(back, Tools.getResizedMatrix(back, ICONSIZE, ICONSIZE), p); } origCanv = new Canvas(scaledOrig); orig = Tools.getResizedBitmap(orig, ((int) (ICONSIZE * scaleFactor)), ((int) (ICONSIZE * scaleFactor))); origCanv.drawBitmap(orig, scaledOrig.getWidth() - (orig.getWidth() / 2) - scaledOrig.getWidth() / 2, scaledOrig.getWidth() - (orig.getWidth() / 2) - scaledOrig.getWidth() / 2, origP); if (mask != null) { origCanv.drawBitmap(mask, Tools.getResizedMatrix(mask, ICONSIZE, ICONSIZE), maskp); } if (back != null) { canvas.drawBitmap(Tools.getResizedBitmap(scaledOrig, ICONSIZE, ICONSIZE), 0, 0, p); } else canvas.drawBitmap(Tools.getResizedBitmap(scaledOrig, ICONSIZE, ICONSIZE), 0, 0, p); if (front != null) canvas.drawBitmap(front, Tools.getResizedMatrix(front, ICONSIZE, ICONSIZE), p); shortcuts.get(i).setIcon(scaledBitmap); } } } }
From source file:g7.bluesky.launcher3.Launcher.java
public void loadIconPack() { //theming vars----------------------------------------------- PackageManager pm = getPackageManager(); final int ICONSIZE = Tools.numtodp(64, Launcher.this); Resources themeRes = null;// ww w . j ava 2 s .c o m String resPacName = defaultSharedPref.getString(SettingConstants.ICON_THEME_PREF_KEY, ""); String iconResource = null; int intres = 0; int intresiconback = 0; int intresiconfront = 0; int intresiconmask = 0; float scaleFactor = 1.0f; Paint p = new Paint(Paint.FILTER_BITMAP_FLAG); p.setAntiAlias(true); Paint origP = new Paint(Paint.FILTER_BITMAP_FLAG); origP.setAntiAlias(true); Paint maskp = new Paint(Paint.FILTER_BITMAP_FLAG); maskp.setAntiAlias(true); maskp.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); if (resPacName.compareTo("") != 0) { try { themeRes = pm.getResourcesForApplication(resPacName); } catch (Exception e) { } ; if (themeRes != null) { String[] backAndMaskAndFront = ThemeTools.getIconBackAndMaskResourceName(themeRes, resPacName); if (backAndMaskAndFront[0] != null) intresiconback = themeRes.getIdentifier(backAndMaskAndFront[0], "drawable", resPacName); if (backAndMaskAndFront[1] != null) intresiconmask = themeRes.getIdentifier(backAndMaskAndFront[1], "drawable", resPacName); if (backAndMaskAndFront[2] != null) intresiconfront = themeRes.getIdentifier(backAndMaskAndFront[2], "drawable", resPacName); } } BitmapFactory.Options uniformOptions = new BitmapFactory.Options(); uniformOptions.inScaled = false; uniformOptions.inDither = false; uniformOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; Canvas origCanv; Canvas canvas; scaleFactor = ThemeTools.getScaleFactor(themeRes, resPacName); Bitmap back = null; Bitmap mask = null; Bitmap front = null; Bitmap scaledBitmap = null; Bitmap scaledOrig = null; Bitmap orig = null; if (resPacName.compareTo("") != 0 && themeRes != null) { try { if (intresiconback != 0) back = BitmapFactory.decodeResource(themeRes, intresiconback, uniformOptions); } catch (Exception e) { } try { if (intresiconmask != 0) mask = BitmapFactory.decodeResource(themeRes, intresiconmask, uniformOptions); } catch (Exception e) { } try { if (intresiconfront != 0) front = BitmapFactory.decodeResource(themeRes, intresiconfront, uniformOptions); } catch (Exception e) { } } //theming vars----------------------------------------------- BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = false; options.inPreferredConfig = Bitmap.Config.RGB_565; options.inDither = true; for (int i = 0; i < listApps.size(); i++) { if (themeRes != null) { iconResource = null; intres = 0; iconResource = ThemeTools.getResourceName(themeRes, resPacName, listApps.get(i).getComponentName().toString()); if (iconResource != null) { intres = themeRes.getIdentifier(iconResource, "drawable", resPacName); } if (intres != 0) {//has single drawable for app listApps.get(i).setIconBitmap(BitmapFactory.decodeResource(themeRes, intres, uniformOptions)); } else { Drawable drawable = listApps.get(i).getIconDrawable(); if (drawable == null) { drawable = Utilities.createIconDrawable(listApps.get(i).getIconBitmap()); } orig = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(new Canvas(orig)); scaledOrig = Bitmap.createBitmap(ICONSIZE, ICONSIZE, Bitmap.Config.ARGB_8888); scaledBitmap = Bitmap.createBitmap(ICONSIZE, ICONSIZE, Bitmap.Config.ARGB_8888); canvas = new Canvas(scaledBitmap); if (back != null) { canvas.drawBitmap(back, Tools.getResizedMatrix(back, ICONSIZE, ICONSIZE), p); } origCanv = new Canvas(scaledOrig); orig = Tools.getResizedBitmap(orig, ((int) (ICONSIZE * scaleFactor)), ((int) (ICONSIZE * scaleFactor))); origCanv.drawBitmap(orig, scaledOrig.getWidth() - (orig.getWidth() / 2) - scaledOrig.getWidth() / 2, scaledOrig.getWidth() - (orig.getWidth() / 2) - scaledOrig.getWidth() / 2, origP); if (mask != null) { origCanv.drawBitmap(mask, Tools.getResizedMatrix(mask, ICONSIZE, ICONSIZE), maskp); } if (back != null) { canvas.drawBitmap(Tools.getResizedBitmap(scaledOrig, ICONSIZE, ICONSIZE), 0, 0, p); } else canvas.drawBitmap(Tools.getResizedBitmap(scaledOrig, ICONSIZE, ICONSIZE), 0, 0, p); if (front != null) canvas.drawBitmap(front, Tools.getResizedMatrix(front, ICONSIZE, ICONSIZE), p); listApps.get(i).setIconBitmap(scaledBitmap); } } } }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * Loads a native font based on a lookup for a font name and attributes. * Font lookup values can be separated by commas and thus allow fallback if * the primary font isn't supported by the platform. * * @param lookup string describing the font * @return the native font object//from ww w. j a va 2 s . co m */ public Object loadNativeFont(String lookup) { try { lookup = lookup.split(";")[0]; int typeface = Typeface.NORMAL; String familyName = lookup.substring(0, lookup.indexOf("-")); String style = lookup.substring(lookup.indexOf("-") + 1, lookup.lastIndexOf("-")); String size = lookup.substring(lookup.lastIndexOf("-") + 1, lookup.length()); if (style.equals("bolditalic")) { typeface = Typeface.BOLD_ITALIC; } else if (style.equals("italic")) { typeface = Typeface.ITALIC; } else if (style.equals("bold")) { typeface = Typeface.BOLD; } Paint font = new CodenameOneTextPaint(Typeface.create(familyName, typeface)); font.setAntiAlias(true); font.setTextSize(Integer.parseInt(size)); return new NativeFont(0, 0, 0, font); } catch (Exception err) { return null; } }
From source file:com.codename1.impl.android.AndroidImplementation.java
@Override public Object createFont(int face, int style, int size) { Typeface typeface = null;//w w w. j av a 2 s . c om switch (face) { case Font.FACE_MONOSPACE: typeface = Typeface.MONOSPACE; break; default: typeface = Typeface.DEFAULT; break; } int fontstyle = Typeface.NORMAL; if ((style & Font.STYLE_BOLD) != 0) { fontstyle |= Typeface.BOLD; } if ((style & Font.STYLE_ITALIC) != 0) { fontstyle |= Typeface.ITALIC; } int height = this.defaultFontHeight; int diff = height / 3; switch (size) { case Font.SIZE_SMALL: height -= diff; break; case Font.SIZE_LARGE: height += diff; break; } Paint font = new CodenameOneTextPaint(Typeface.create(typeface, fontstyle)); font.setAntiAlias(true); font.setUnderlineText((style & Font.STYLE_UNDERLINED) != 0); font.setTextSize(height); return new NativeFont(face, style, size, font); }