List of usage examples for android.graphics Typeface SERIF
Typeface SERIF
To view the source code for android.graphics Typeface SERIF.
Click Source Link
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static Typeface toTypeface(final Context context, String fontFamily, String weight) { Typeface tf = Typeface.SANS_SERIF; // default if (weight != null) { if (fontFamily == null && weight != "regular") { fontFamily = "sans-serif-" + weight.toLowerCase(); } else {/*from w ww.ja v a 2s .c o m*/ fontFamily += "-" + weight.toLowerCase(); } } if (fontFamily != null) { if ("monospace".equals(fontFamily)) { tf = Typeface.MONOSPACE; } else if ("serif".equals(fontFamily)) { tf = Typeface.SERIF; } else if ("sans-serif".equals(fontFamily)) { tf = Typeface.SANS_SERIF; } else { Typeface loadedTf = null; if (context != null) { try { loadedTf = loadTypeface(context, fontFamily); } catch (Exception e) { loadedTf = null; Log.e(TAG, "Unable to load font " + fontFamily + ": " + e.getMessage()); } } if (loadedTf == null) { Log.w(TAG, "Unsupported font: '" + fontFamily + "' supported fonts are 'monospace', 'serif', 'sans-serif'.", Log.DEBUG_MODE); } else { tf = loadedTf; } } } return tf; }
From source file:com.aujur.ebookreader.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 ww w. ja v a2 s.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; } fontCache.put(fontFace, new FontFamily(fontFace, face)); } } return fontCache.get(fontFace); }
From source file:com.jjoe64.graphview_demos.fragments.CollectData.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 . j a v a 2 s . c om*/ 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: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 .java 2 s . com 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 {/* ww w . ja v a 2 s . co 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 www. ja va 2 s.c om*/ 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 www . j a va 2 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: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 a va 2 s. c om 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;/* www. j av a2s . c o m*/ 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; }