Example usage for android.graphics Typeface MONOSPACE

List of usage examples for android.graphics Typeface MONOSPACE

Introduction

In this page you can find the example usage for android.graphics Typeface MONOSPACE.

Prototype

Typeface MONOSPACE

To view the source code for android.graphics Typeface MONOSPACE.

Click Source Link

Document

The NORMAL style of the default monospace typeface.

Usage

From source file:org.eurekapp.pageturner.Configuration.java

private FontFamily getFontFamily(String fontKey, String defaultVal) {

    String fontFace = settings.getString(fontKey, defaultVal);

    if (!fontCache.containsKey(fontFace)) {

        if ("gen_book_bas".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "GentiumBookBasic"));
        } else if ("gen_bas".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "GentiumBasic"));
        } else if ("frankruehl".equalsIgnoreCase(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "FrankRuehl"));
        } else {//from w  w  w.jav  a 2  s .  c  om

            Typeface face = Typeface.SANS_SERIF;
            if ("sans".equals(fontFace)) {
                face = Typeface.SANS_SERIF;
            } else if ("serif".equals(fontFace)) {
                face = Typeface.SERIF;
            } else if ("mono".equals(fontFace)) {
                face = Typeface.MONOSPACE;
            } else if ("default".equals(fontFace)) {
                face = Typeface.DEFAULT;
            }

            fontCache.put(fontFace, new FontFamily(fontFace, face));
        }
    }

    return fontCache.get(fontFace);
}

From source file:net.zorgblub.typhon.Configuration.java

private FontFamily getFontFamily(String fontKey, String defaultVal) {

    String fontFace = settings.getString(fontKey, defaultVal);

    if (!fontCache.containsKey(fontFace)) {

        if ("mamelon".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "Mamelon", true));
        } else if ("boku2r".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "Boku2", true));
        } else if ("kokoro".equalsIgnoreCase(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "Kokoro", true));
        } else if ("gen_book_bas".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "GentiumBookBasic", false));
        } else if ("gen_bas".equals(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "GentiumBasic", false));
        } else if ("frankruehl".equalsIgnoreCase(fontFace)) {
            fontCache.put(fontFace, loadFamilyFromAssets(fontFace, "FrankRuehl", false));
        } else {//  w ww.j a  va2s . c  o m

            Typeface face = Typeface.SANS_SERIF;
            if ("sans".equals(fontFace)) {
                face = Typeface.SANS_SERIF;
            } else if ("serif".equals(fontFace)) {
                face = Typeface.SERIF;
            } else if ("mono".equals(fontFace)) {
                face = Typeface.MONOSPACE;
            } else if ("default".equals(fontFace)) {
                face = Typeface.DEFAULT;
            }

            fontCache.put(fontFace, new FontFamily(fontFace, face));
        }
    }

    return fontCache.get(fontFace);
}

From source file:com.jjoe64.graphview_demos.fragments.StartSensors.java

void loadDefaultSettingValues() {
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
        mDisplayType = Integer.valueOf(res);

        res = pref.getString("fontsize_list", Integer.toString(12));
        mTextFontSize = Integer.valueOf(res);

        res = pref.getString("typeface_list", Integer.toString(3));
        switch (Integer.valueOf(res)) {
        case 0://from   w ww  .ja v  a2s  . c o  m
            mTextTypeface = Typeface.DEFAULT;
            break;
        case 1:
            mTextTypeface = Typeface.SANS_SERIF;
            break;
        case 2:
            mTextTypeface = Typeface.SERIF;
            break;
        case 3:
            mTextTypeface = Typeface.MONOSPACE;
            break;
        }
        //mTvSerial.setTypeface(mTextTypeface);
        //etWrite.setTypeface(mTextTypeface);

        res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mReadLinefeedCode = Integer.valueOf(res);

        res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
        mWriteLinefeedCode = Integer.valueOf(res);

        res = pref.getString("email_edittext", "@gmail.com");
        mEmailAddress = res;

        res = pref.getString("baudrate_list", Integer.toString(57600));
        mBaudrate = Integer.valueOf(res);

        res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
        mDataBits = Integer.valueOf(res);

        res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
        mParity = Integer.valueOf(res);

        res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
        mStopBits = Integer.valueOf(res);

        res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
        mFlowControl = Integer.valueOf(res);
    }

From source file:jp.ksksue.app.terminal.AndroidUSBSerialMonitorLite.java

void loadDefaultSettingValues() {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    String res = pref.getString("display_list", Integer.toString(DISP_CHAR));
    mDisplayType = Integer.valueOf(res);

    res = pref.getString("fontsize_list", Integer.toString(12));
    mTextFontSize = Integer.valueOf(res);

    res = pref.getString("typeface_list", Integer.toString(3));
    switch (Integer.valueOf(res)) {
    case 0:/*from w ww.j  a v a2 s .c  o  m*/
        mTextTypeface = Typeface.DEFAULT;
        break;
    case 1:
        mTextTypeface = Typeface.SANS_SERIF;
        break;
    case 2:
        mTextTypeface = Typeface.SERIF;
        break;
    case 3:
        mTextTypeface = Typeface.MONOSPACE;
        break;
    }
    mTvSerial.setTypeface(mTextTypeface);
    etWrite.setTypeface(mTextTypeface);

    res = pref.getString("readlinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
    mReadLinefeedCode = Integer.valueOf(res);

    res = pref.getString("writelinefeedcode_list", Integer.toString(LINEFEED_CODE_CRLF));
    mWriteLinefeedCode = Integer.valueOf(res);

    res = pref.getString("email_edittext", "@gmail.com");
    mEmailAddress = res;

    res = pref.getString("baudrate_list", Integer.toString(9600));
    mBaudrate = Integer.valueOf(res);

    res = pref.getString("databits_list", Integer.toString(UartConfig.DATA_BITS8));
    mDataBits = Integer.valueOf(res);

    res = pref.getString("parity_list", Integer.toString(UartConfig.PARITY_NONE));
    mParity = Integer.valueOf(res);

    res = pref.getString("stopbits_list", Integer.toString(UartConfig.STOP_BITS1));
    mStopBits = Integer.valueOf(res);

    res = pref.getString("flowcontrol_list", Integer.toString(UartConfig.FLOW_CONTROL_OFF));
    mFlowControl = Integer.valueOf(res);

    res = pref.getString("play_interval", "3");
    mPlayIntervalSeconds = Integer.valueOf(res);
}

From source file:sharedcode.turboeditor.activity.MainActivity.java

public void onEvent(EventBusEvents.APreferenceValueWasChanged event) {

    if (event.hasType(EventBusEvents.APreferenceValueWasChanged.Type.THEME_CHANGE)) {
        ThemeUtils.setWindowsBackground(this);
    }//from w  w  w . j  ava 2s. c  om

    if (event.hasType(WRAP_CONTENT)) {
        if (PreferenceHelper.getWrapContent(this)) {
            horizontalScroll.removeView(mEditor);
            verticalScroll.removeView(horizontalScroll);
            verticalScroll.addView(mEditor);
        } else {
            verticalScroll.removeView(mEditor);
            verticalScroll.addView(horizontalScroll);
            horizontalScroll.addView(mEditor);
        }
    } else if (event.hasType(LINE_NUMERS)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null, true);
        mEditor.enableTextChangedListener();
        if (PreferenceHelper.getLineNumbers(this)) {
            mEditor.setPadding(
                    EditTextPadding.getPaddingWithLineNumbers(this, PreferenceHelper.getFontSize(this)),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        } else {
            mEditor.setPadding(EditTextPadding.getPaddingWithoutLineNumbers(this),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        }
    } else if (event.hasType(SYNTAX)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null, true);
        mEditor.enableTextChangedListener();
    } else if (event.hasType(MONOSPACE)) {
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (event.hasType(THEME_CHANGE)) {
        if (PreferenceHelper.getLightTheme(this)) {
            mEditor.setTextColor(getResources().getColor(R.color.textColorInverted));
        } else {
            mEditor.setTextColor(getResources().getColor(R.color.textColor));
        }
    } else if (event.hasType(TEXT_SUGGESTIONS) || event.hasType(READ_ONLY)) {
        if (PreferenceHelper.getReadOnly(this)) {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            mEditor.setReadOnly(true);
        } else {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
            mEditor.setReadOnly(false);
            if (PreferenceHelper.getSuggestionActive(this)) {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            } else {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                        | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            }
        }
        // sometimes it becomes monospace after setting the input type
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (event.hasType(FONT_SIZE)) {
        if (PreferenceHelper.getLineNumbers(this)) {
            mEditor.setPadding(
                    EditTextPadding.getPaddingWithLineNumbers(this, PreferenceHelper.getFontSize(this)),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        } else {
            mEditor.setPadding(EditTextPadding.getPaddingWithoutLineNumbers(this),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        }
        mEditor.setTextSize(PreferenceHelper.getFontSize(this));
    } else if (event.hasType(ENCODING)) {
        String oldEncoding, newEncoding;
        oldEncoding = currentEncoding;
        newEncoding = PreferenceHelper.getEncoding(this);
        try {
            final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
            mEditor.disableTextChangedListener();
            mEditor.replaceTextKeepCursor(new String(oldText, newEncoding), true);
            mEditor.enableTextChangedListener();
            currentEncoding = newEncoding;
        } catch (UnsupportedEncodingException ignored) {
            try {
                final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
                mEditor.disableTextChangedListener();
                mEditor.replaceTextKeepCursor(new String(oldText, "UTF-8"), true);
                mEditor.enableTextChangedListener();
            } catch (UnsupportedEncodingException ignored2) {
            }
        }
    }
}

From source file:com.maskyn.fileeditorpro.activity.MainActivity.java

void aPreferenceValueWasChanged(List<PreferenceChangeType> types) {

    if (types.contains(PreferenceChangeType.THEME_CHANGE)) {
        ThemeUtils.setWindowsBackground(this);
        AccessoryView accessoryView = (AccessoryView) findViewById(R.id.accessoryView);
        accessoryView.updateTextColors();
    }/*from  ww  w. j ava 2  s  . c  om*/

    if (types.contains(PreferenceChangeType.WRAP_CONTENT)) {
        if (PreferenceHelper.getWrapContent(this)) {
            horizontalScroll.removeView(mEditor);
            verticalScroll.removeView(horizontalScroll);
            verticalScroll.addView(mEditor);
        } else {
            verticalScroll.removeView(mEditor);
            verticalScroll.addView(horizontalScroll);
            horizontalScroll.addView(mEditor);
        }
    } else if (types.contains(PreferenceChangeType.LINE_NUMERS)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null);
        mEditor.enableTextChangedListener();
        mEditor.updatePadding();
    } else if (types.contains(PreferenceChangeType.SYNTAX)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(mEditor.getText().toString());
        mEditor.enableTextChangedListener();
    } else if (types.contains(PreferenceChangeType.MONOSPACE)) {
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (types.contains(PreferenceChangeType.THEME_CHANGE)) {
        if (PreferenceHelper.getLightTheme(this)) {
            mEditor.setTextColor(getResources().getColor(R.color.textColorInverted));
        } else {
            mEditor.setTextColor(getResources().getColor(R.color.textColor));
        }
    } else if (types.contains(PreferenceChangeType.TEXT_SUGGESTIONS)
            || types.contains(PreferenceChangeType.READ_ONLY)) {
        if (PreferenceHelper.getReadOnly(this)) {
            mEditor.setReadOnly(true);
        } else {
            mEditor.setReadOnly(false);
            if (PreferenceHelper.getSuggestionActive(this)) {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            } else {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                        | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            }
        }
        // sometimes it becomes monospace after setting the input type
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (types.contains(PreferenceChangeType.FONT_SIZE)) {
        mEditor.updatePadding();
        mEditor.setTextSize(PreferenceHelper.getFontSize(this));
    } else if (types.contains(PreferenceChangeType.ACCESSORY_VIEW)) {
        HorizontalScrollView parentAccessoryView = (HorizontalScrollView) findViewById(
                R.id.parent_accessory_view);
        ViewUtils.setVisible(parentAccessoryView, PreferenceHelper.getUseAccessoryView(this));
        mEditor.updatePadding();
    } else if (types.contains(PreferenceChangeType.ENCODING)) {
        String oldEncoding, newEncoding;
        oldEncoding = currentEncoding;
        newEncoding = PreferenceHelper.getEncoding(this);
        try {
            final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
            mEditor.disableTextChangedListener();
            mEditor.replaceTextKeepCursor(new String(oldText, newEncoding));
            mEditor.enableTextChangedListener();
            currentEncoding = newEncoding;
        } catch (UnsupportedEncodingException ignored) {
            try {
                final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
                mEditor.disableTextChangedListener();
                mEditor.replaceTextKeepCursor(new String(oldText, "UTF-16"));
                mEditor.enableTextChangedListener();
            } catch (UnsupportedEncodingException ignored2) {
            }
        }
    }
}

From source file:org.openintents.notepad.NoteEditor.java

private boolean setRemoteStyle(String styleName, int size) {
    if (TextUtils.isEmpty(styleName)) {
        if (DEBUG) {
            Log.e(TAG, "Empty style name: " + styleName);
        }/*from  w  w w. j av  a  2s . co  m*/
        return false;
    }

    PackageManager pm = getPackageManager();

    String packageName = ThemeUtils.getPackageNameFromStyle(styleName);

    if (packageName == null) {
        Log.e(TAG, "Invalid style name: " + styleName);
        return false;
    }

    Context c = null;
    try {
        c = createPackageContext(packageName, 0);
    } catch (NameNotFoundException e) {
        Log.e(TAG, "Package for style not found: " + packageName + ", " + styleName);
        return false;
    }

    Resources res = c.getResources();

    int themeid = res.getIdentifier(styleName, null, null);
    if (DEBUG) {
        Log.d(TAG, "Retrieving theme: " + styleName + ", " + themeid);
    }

    if (themeid == 0) {
        Log.e(TAG, "Theme name not found: " + styleName);
        return false;
    }

    try {
        ThemeAttributes ta = new ThemeAttributes(c, packageName, themeid);

        mTextTypeface = ta.getString(ThemeNotepad.TEXT_TYPEFACE);
        if (DEBUG) {
            Log.d(TAG, "textTypeface: " + mTextTypeface);
        }

        mCurrentTypeface = null;

        // Look for special cases:
        if ("monospace".equals(mTextTypeface)) {
            mCurrentTypeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL);
        } else if ("sans".equals(mTextTypeface)) {
            mCurrentTypeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
        } else if ("serif".equals(mTextTypeface)) {
            mCurrentTypeface = Typeface.create(Typeface.SERIF, Typeface.NORMAL);
        } else if (!TextUtils.isEmpty(mTextTypeface)) {

            try {
                if (DEBUG) {
                    Log.d(TAG, "Reading typeface: package: " + packageName + ", typeface: " + mTextTypeface);
                }
                Resources remoteRes = pm.getResourcesForApplication(packageName);
                mCurrentTypeface = Typeface.createFromAsset(remoteRes.getAssets(), mTextTypeface);
                if (DEBUG) {
                    Log.d(TAG, "Result: " + mCurrentTypeface);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Package not found for Typeface", e);
            }
        }

        mTextUpperCaseFont = ta.getBoolean(ThemeNotepad.TEXT_UPPER_CASE_FONT, false);

        mTextColor = ta.getColor(ThemeNotepad.TEXT_COLOR, android.R.color.white);

        if (DEBUG) {
            Log.d(TAG, "textColor: " + mTextColor);
        }

        if (size == 0) {
            mTextSize = getTextSizeTiny(ta);
        } else if (size == 1) {
            mTextSize = getTextSizeSmall(ta);
        } else if (size == 2) {
            mTextSize = getTextSizeMedium(ta);
        } else {
            mTextSize = getTextSizeLarge(ta);
        }
        if (DEBUG) {
            Log.d(TAG, "textSize: " + mTextSize);
        }

        if (mText != null) {
            mBackgroundPadding = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING, -1);
            int backgroundPaddingLeft = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_LEFT,
                    mBackgroundPadding);
            int backgroundPaddingTop = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_TOP,
                    mBackgroundPadding);
            int backgroundPaddingRight = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_RIGHT,
                    mBackgroundPadding);
            int backgroundPaddingBottom = ta.getDimensionPixelOffset(ThemeNotepad.BACKGROUND_PADDING_BOTTOM,
                    mBackgroundPadding);

            if (DEBUG) {
                Log.d(TAG,
                        "Padding: " + mBackgroundPadding + "; " + backgroundPaddingLeft + "; "
                                + backgroundPaddingTop + "; " + backgroundPaddingRight + "; "
                                + backgroundPaddingBottom + "; ");
            }

            try {
                Resources remoteRes = pm.getResourcesForApplication(packageName);
                int resid = ta.getResourceId(ThemeNotepad.BACKGROUND, 0);
                if (resid != 0) {
                    Drawable d = remoteRes.getDrawable(resid);
                    mText.setBackgroundDrawable(d);
                } else {
                    // remove background
                    mText.setBackgroundResource(0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Package not found for Theme background.", e);
            } catch (Resources.NotFoundException e) {
                Log.e(TAG, "Resource not found for Theme background.", e);
            }

            // Apply padding
            if (mBackgroundPadding >= 0 || backgroundPaddingLeft >= 0 || backgroundPaddingTop >= 0
                    || backgroundPaddingRight >= 0 || backgroundPaddingBottom >= 0) {
                mText.setPadding(backgroundPaddingLeft, backgroundPaddingTop, backgroundPaddingRight,
                        backgroundPaddingBottom);
            } else {
                // 9-patches do the padding automatically
                // todo clear padding
            }
        }

        mLinesMode = ta.getInteger(ThemeNotepad.LINE_MODE, 2);
        mLinesColor = ta.getColor(ThemeNotepad.LINE_COLOR, 0xFF000080);

        if (DEBUG) {
            Log.d(TAG, "line color: " + mLinesColor);
        }

        return true;

    } catch (UnsupportedOperationException e) {
        // This exception is thrown e.g. if one attempts
        // to read an integer attribute as dimension.
        Log.e(TAG, "UnsupportedOperationException", e);
        return false;
    } catch (NumberFormatException e) {
        // This exception is thrown e.g. if one attempts
        // to read a string as integer.
        Log.e(TAG, "NumberFormatException", e);
        return false;
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

public Typeface getTypeface(String fontName, int fontStyle) {
    Typeface tf = null;/* w  w w . java 2  s.  c om*/
    if (fontName.toLowerCase().contains("book")) {
        tf = Typeface.create(Typeface.DEFAULT, fontStyle);
    } else if (fontName.toLowerCase().contains("default")) {
        tf = Typeface.create(Typeface.DEFAULT, fontStyle);
    } else if (fontName.toLowerCase().contains("mono")) {
        tf = Typeface.create(Typeface.MONOSPACE, fontStyle);
    } else if ((fontName.toLowerCase().contains("sans"))) {
        tf = Typeface.create(Typeface.SANS_SERIF, fontStyle);
    } else if ((fontName.toLowerCase().contains("serif"))) {
        tf = Typeface.create(Typeface.SERIF, fontStyle);
    }
    return tf;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public Object createFont(int face, int style, int size) {
    Typeface typeface = null;//from w  w w  . j  a v  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);

}