public static void MapFontProperty(IViewHandler viewHandler, Text virtualView) { var nativeView = (TextView)viewHandler.NativeView; var font = virtualView.GetFont(DefaultFont); // note: default values (fonts) should be discussed at a more abstract level first if (font == DefaultFont) { return; } TypefaceStyle typefaceStyle = TypefaceStyle.Normal; switch (font.Weight) { case Weight.Bold: typefaceStyle = font.Italic ? TypefaceStyle.BoldItalic : TypefaceStyle.Bold; break; case Weight.Regular: typefaceStyle = font.Italic ? TypefaceStyle.Italic : TypefaceStyle.Normal; break; } nativeView.SetTypeface(nativeView.Typeface, typefaceStyle); nativeView.TextSize = font.Size; virtualView.InvalidateMeasurement(); }
private static void applyCustomTypeFace(Paint paint, Typeface tf) { TypefaceStyle oldStyle; Typeface old = paint.Typeface; if (old == null) { oldStyle = 0; } else { oldStyle = old.Style; } TypefaceStyle fake = oldStyle & ~tf.Style; if ((fake & TypefaceStyle.Bold) != 0) { paint.FakeBoldText = true; } if ((fake & TypefaceStyle.Italic) != 0) { paint.TextSkewX = -0.25f; } paint.SetTypeface(tf); }
public Entry(string?fontFamily, FontWeight fontWeight, TypefaceStyle style) { FontFamily = fontFamily; FontWeight = fontWeight; Style = style; _hashCode = (FontFamily?.GetHashCode() ?? 0) ^ FontWeight.GetHashCode() ^ Style.GetHashCode(); }
public bool SetTypeface(Typeface typeface, TypefaceStyle style = TypefaceStyle.Normal) { if (m_viewX is Button) { ((Button)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is TextView) { ((TextView)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is EditText) { ((EditText)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is Switch) { ((Switch)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is Spinner) { Spinner spinner = (Spinner)m_viewX; TextImageAdapter adapter = spinner.Adapter as TextImageAdapter; if (adapter != null) { adapter.Typeface = typeface; adapter.TypefaceStyle = style; } } else { return(false); } return(true); }
public SpannableString ConvertToSpannable(StateNode state, DisplayMetrics displayMetrics) { var nodes = Flatten(state).TrimNewLines(); var s = new SpannableString(string.Concat(nodes as IEnumerable<TextEx>)); int start = 0; foreach (var n in nodes) { if (string.IsNullOrEmpty(n.Text)) { if (n is StringAnchor a) { //s.SetSpan(new ClickableSpan(a.Owner), start, start + a.Length, SpanTypes.InclusiveExclusive); //s.SetSpan(new UnderlineSpan(), start, start + a.Length, SpanTypes.InclusiveExclusive); } continue; } if (n.Bold != null || n.Italic != null || n.FontSize != null || n.Foreground != null) { TypefaceStyle style = 0; if (n.Bold == true && n.Italic == true) style = TypefaceStyle.BoldItalic; else if (n.Bold == true) style = TypefaceStyle.Bold; else if (n.Italic == true) style = TypefaceStyle.Italic; else style = TypefaceStyle.Normal; ColorStateList color = null; if (n.Foreground != null) color = ColorStateList.ValueOf(new AColor( (byte)(n.Foreground.Value.R * 255), (byte)(n.Foreground.Value.G * 255), (byte)(n.Foreground.Value.B * 255), (byte)(n.Foreground.Value.A * 255) )); int fontSize = -1; if (n.FontSize != null) fontSize = (int) Math.Round(TypedValue.ApplyDimension(ComplexUnitType.Sp, (float) n.FontSize.Value, displayMetrics), MidpointRounding.AwayFromZero); s.SetSpan(new TextAppearanceSpan(null, style, fontSize, color, null), start, start + n.Text.Length, SpanTypes.InclusiveExclusive); } if (n.Sub == true) s.SetSpan(new SubscriptSpan(), start, start + n.Text.Length, SpanTypes.InclusiveExclusive); if (n.Super == true) s.SetSpan(new SuperscriptSpan(), start, start + n.Text.Length, SpanTypes.InclusiveExclusive); if (n.Strike == true) s.SetSpan(new StrikethroughSpan(), start, start + n.Text.Length, SpanTypes.InclusiveExclusive); if (n.Underline == true) s.SetSpan(new UnderlineSpan(), start, start + n.Text.Length, SpanTypes.InclusiveExclusive); start += n.Text.Length; } return s; }
public static void SetTextFont(this TextView textView, TypefaceStyle style) { var assetManager = Application.Context.ApplicationContext.Assets; var typeface = Typeface.CreateFromAsset(assetManager, Java.Lang.String.Format(Locale.Us, "fonts/%s", "IckyTicketMono.ttf")); textView.SetTypeface(typeface, style); }
public void SetCustomFont(string assetPath) { try { this.CustomFontPath = assetPath; if (!string.IsNullOrEmpty(assetPath)) { Typeface face = FontLoader.GetFont(Context.Assets, assetPath); if (face != null) { TypefaceStyle style = TypefaceStyle.Normal; //Not all custom fonts have compatible text sytle, so we ignore it /* * if (this.Typeface != null) //Takes care of android:textStyle="" * { * style = Typeface.Style; * } */ this.SetTypeface(face, style); } } } catch (Exception ex) { Container.Track.LogWarning(ex.Message, "CoreTextView"); } }
private void CreateStyleSpanForMatches(IEditable e, Pattern pattern, TypefaceStyle style) { Func <IParcelableSpan> creator = () => new StyleSpan(style); CreateSpanForMatches(e, pattern, creator); }
private TypefaceStyle?ResolveTypefaceStyle(string styleName) { if (string.IsNullOrWhiteSpace(styleName)) { return(null); } TypefaceStyle style = TypefaceStyle.Normal; if (!string.IsNullOrWhiteSpace(styleName)) { // try to split style name (as may have bold, normal and italic in it). Ignore invalid names. Deafult to Normal. var styleNames = styleName.Split("|"); if (styleNames.Contains("bold") && styleNames.Contains("italic")) { style = TypefaceStyle.BoldItalic; } else if (styleNames.Contains("bold")) { style = TypefaceStyle.Bold; } else if (styleNames.Contains("italic")) { style = TypefaceStyle.Italic; } } return(style); }
public void SetTypeface(Typeface tf, TypefaceStyle style) { if (style > 0) { if (tf == null) { tf = Typeface.DefaultFromStyle(style); } else { tf = Typeface.Create(tf, style); } this.Typeface = tf; // now compute what (if any) algorithmic styling is needed TypefaceStyle typefaceStyle = tf != null ? tf.Style : TypefaceStyle.Normal; TypefaceStyle need = style & ~typefaceStyle; _textPaint.FakeBoldText = ((need & TypefaceStyle.Bold) != 0); _textPaint.TextSkewX = ((need & TypefaceStyle.Italic) != 0 ? -0.25f : 0); } else { _textPaint.FakeBoldText = false; _textPaint.TextSkewX = 0; this.Typeface = tf; } }
public override void SetTypeface(Typeface tf, TypefaceStyle style) { base.SetTypeface (tf, style); RefitText(Text, tf); SetWillNotDraw(false); PostInvalidate(); }
public CustomTypefaceSpan(string family, Typeface type, TypefaceStyle style, int size) : base(family) { newType = type; this.style = style; this.size = size; }
public void SetCountTypeface(Typeface typeface, TypefaceStyle style) { Count.SetTypeface(typeface, style); if (_initialized) { Count.Invalidate(); } }
public void SetLabelTypeface(Typeface typeface, TypefaceStyle style) { Label.SetTypeface(typeface, style); if (_initialized) { Label.Invalidate(); } }
public InstalledTypeface GetInstalledTypeface(string fontName, TypefaceStyle wellknownSubFam) { //not auto resolve InstalledTypefaceGroup selectedFontGroup; InstalledTypeface _found; switch (wellknownSubFam) { default: return(null); case TypefaceStyle.Regular: selectedFontGroup = _regular; break; case TypefaceStyle.Bold: selectedFontGroup = _bold; break; case TypefaceStyle.Italic: selectedFontGroup = _italic; break; case (TypefaceStyle.Bold | TypefaceStyle.Italic): selectedFontGroup = _bold_italic; break; } if (selectedFontGroup.TryGetValue(fontName.ToUpper(), out _found)) { return(_found); } //------------------------------------------- //not found then ... //retry .... //if (wellknownSubFam == TypefaceStyle.Bold) //{ // //try get from Gras? // //eg. tahoma // if (_subFamToFontGroup.TryGetValue("GRAS", out selectedFontGroup)) // { // if (selectedFontGroup.TryGetValue(fontName.ToUpper(), out _found)) // { // return _found; // } // } //} //else if (wellknownSubFam == TypefaceStyle.Italic) //{ // //TODO: simulate oblique (italic) font??? // selectedFontGroup = _normal; // if (selectedFontGroup.TryGetValue(fontName.ToUpper(), out _found)) // { // return _found; // } //} if (_found == null && _fontNotFoundHandler != null) { return(_fontNotFoundHandler(this, fontName, GetSubFam(wellknownSubFam))); } return(_found); }
bool AddFontPreview(PreviewFontInfo previewFont, string srcPath) { _onlyFontNames[previewFont.Name] = true; TypefaceStyle typefaceStyle = TypefaceStyle.Regular; switch (previewFont.OS2TranslatedStyle) { case OpenFont.Extensions.TranslatedOS2FontStyle.BOLD: typefaceStyle = TypefaceStyle.Bold; break; case OpenFont.Extensions.TranslatedOS2FontStyle.ITALIC: case OpenFont.Extensions.TranslatedOS2FontStyle.OBLIQUE: typefaceStyle = TypefaceStyle.Italic; break; case OpenFont.Extensions.TranslatedOS2FontStyle.REGULAR: typefaceStyle = TypefaceStyle.Regular; break; case (OpenFont.Extensions.TranslatedOS2FontStyle.BOLD | OpenFont.Extensions.TranslatedOS2FontStyle.ITALIC): typefaceStyle = TypefaceStyle.Bold | TypefaceStyle.Italic; break; } //--------------- //some font subfam="Bold Italic" but OS2TranslatedStyle is only Italic //so we should check the subfam name too! string[] fontSubFamUpperCaseName_split = previewFont.SubFamilyName.ToUpper().Split(' '); if (fontSubFamUpperCaseName_split.Length > 1) { if (typefaceStyle != (TypefaceStyle.Bold | TypefaceStyle.Italic)) { //translate more if ((fontSubFamUpperCaseName_split[0] == "BOLD" && fontSubFamUpperCaseName_split[1] == "ITALIC") || (fontSubFamUpperCaseName_split[0] == "ITALIC" && fontSubFamUpperCaseName_split[1] == "BOLD")) { typefaceStyle = TypefaceStyle.Bold | TypefaceStyle.Italic; } } } else { //=1 switch (fontSubFamUpperCaseName_split[0]) { case "BOLD": typefaceStyle = TypefaceStyle.Bold; break; case "ITALIC": typefaceStyle = TypefaceStyle.Italic; break; } } return(Register(new InstalledTypeface(previewFont.Name, previewFont.SubFamilyName, srcPath, typefaceStyle, previewFont.Weight) { ActualStreamOffset = previewFont.ActualStreamOffset })); }
internal InstalledTypeface(string fontName, string fontSubFamily, string fontPath, TypefaceStyle typefaceStyle) { FontName = fontName; FontSubFamily = fontSubFamily; FontPath = fontPath; TypefaceStyle = typefaceStyle; }
public Typeface GetTypeface(string name, TypefaceStyle installedFontStyle) { InstalledTypeface inst = _installedTypefaceCollection.GetInstalledTypeface(name, InstalledTypefaceCollection.GetSubFam(installedFontStyle)); if (inst != null) { return(typefaceStore.GetTypeface(inst)); } return(null); }
private static void ApplyCustomTypeface(Paint paint, Typeface tf, TypefaceStyle style, int size) { if (style == TypefaceStyle.Italic) paint.TextSkewX = -0.25f; if(size > 0) paint.TextSize = size; paint.SetTypeface (tf); }
/// <summary> /// get typeface from wellknown style /// </summary> /// <param name="fontname"></param> /// <param name="style"></param> /// <returns></returns> public Typeface GetTypeface(string fontname, TypefaceStyle style) { InstalledTypeface installedFont = FontCollection.GetInstalledTypeface(fontname, style); if (installedFont == null) { return(null); } return(GetTypefaceOrCreateNew(installedFont)); }
public TextAppearance(int textSizePx, ColorStateList textColor, Typeface typeface, float shadowRadius, float shadowDx, float shadowDy, Color shadowColor) { TextSizePx = textSizePx; TextColor = textColor; Typeface = typeface; Style = TypefaceStyle.Normal; ShadowRadius = shadowRadius; ShadowDx = shadowDx; ShadowDy = shadowDy; ShadowColor = shadowColor; }
public TextAppearance(int textSizePx, ColorStateList textColor, Typeface typeface, TypefaceStyle style, float shadowRadius, float shadowDx, float shadowDy) { TextSizePx = textSizePx; TextColor = textColor; Typeface = typeface; Style = style; ShadowRadius = shadowRadius; ShadowDx = shadowDx; ShadowDy = shadowDy; ShadowColor = Color.Gray; }
public void SetTextStyle(string texts, TypefaceStyle style) { try { DecoratedContent.SetSpan(new StyleSpan(style), Content.IndexOf(texts, StringComparison.Ordinal), Content.IndexOf(texts, StringComparison.Ordinal) + (texts.Length), SpanTypes.ExclusiveExclusive); } catch (Exception e) { Console.WriteLine(e); } }
TextView CreateTextViewEx(string text, Color clr, int textSize, TypefaceStyle ts, Context context) { TextView tv = new TextView(context); tv.Text = text; tv.SetTextColor(clr); tv.SetTypeface(null, ts); tv.SetTextSize(ComplexUnitType.Sp, textSize); return(tv); }
public TextAppearance(int textSizePx, ColorStateList textColor, float shadowRadius, float shadowDx, float shadowDy) { TextSizePx = textSizePx; TextColor = textColor; Typeface = null; Style = TypefaceStyle.Normal; ShadowRadius = shadowRadius; ShadowDx = shadowDx; ShadowDy = shadowDy; ShadowColor = Color.Gray; }
public TextAppearance() { TextSizePx = -1; TextColor = null; Typeface = null; Style = TypefaceStyle.Normal; ShadowRadius = -1f; ShadowDx = float.MinValue; ShadowDy = float.MinValue; ShadowColor = Color.Transparent; }
public void SetTextStyle(string texts, TypefaceStyle style) { try { DecoratedContent.SetSpan(new StyleSpan(style), Content.IndexOf(texts, StringComparison.Ordinal), Content.IndexOf(texts, StringComparison.Ordinal) + texts.Length, SpanTypes.ExclusiveExclusive); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public TextAppearance(int textSizePx, ColorStateList textColor) { TextSizePx = textSizePx; TextColor = textColor; Typeface = null; Style = TypefaceStyle.Normal; ShadowRadius = 0f; ShadowDx = 0f; ShadowDy = 0f; ShadowColor = Color.Transparent; }
public TextAppearance(int textSizePx, ColorStateList textColor, Typeface typeface, TypefaceStyle style) { TextSizePx = textSizePx; TextColor = textColor; Typeface = typeface; Style = style; ShadowRadius = 0f; ShadowDx = 0f; ShadowDy = 0f; ShadowColor = Color.Transparent; }
internal InstalledTypeface(string fontName, string fontSubFamily, string fontPath, TypefaceStyle typefaceStyle, ushort weight) { FontName = fontName; FontSubFamily = fontSubFamily; FontPath = fontPath; TypefaceStyle = typefaceStyle; Weight = weight; }
public void ApplyTypedArray(TypedArray arr) { Gravity = (GravityFlags)arr.GetInt(Resource.Styleable.odometer_android_gravity, (int)Gravity); ShadowColor = arr.GetColor(Resource.Styleable.odometer_android_shadowColor, ShadowColor); ShadowDx = arr.GetFloat(Resource.Styleable.odometer_android_shadowDx, ShadowDx); ShadowDy = arr.GetFloat(Resource.Styleable.odometer_android_shadowDy, ShadowDy); ShadowRadius = arr.GetFloat(Resource.Styleable.odometer_android_shadowRadius, ShadowRadius); Text = arr.GetString(Resource.Styleable.odometer_android_text); TextColor = arr.GetColor(Resource.Styleable.odometer_android_textColor, TextColor); TextSize = arr.GetDimension(Resource.Styleable.odometer_android_textSize, TextSize); TextStyle = (TypefaceStyle)arr.GetInt(Resource.Styleable.odometer_android_textStyle, (int)TextStyle); }
public SnackbarConfig() { ActionButtonTextColor = SnackbarConfigDefaults.ActionButtonTextColor; ActionButtonTypeface = SnackbarConfigDefaults.ActionButtonTypeface; ActionButtonTypefaceStyle = SnackbarConfigDefaults.ActionButtonTypefaceStyle; AnimationMode = SnackbarConfigDefaults.AnimationMode; BackgroundColor = SnackbarConfigDefaults.BackgroundColor; Duration = SnackbarConfigDefaults.Duration; MessageTextColor = SnackbarConfigDefaults.MessageTextColor; MessageTypeface = SnackbarConfigDefaults.MessageTypeface; MessageTypefaceStyle = SnackbarConfigDefaults.MessageTypefaceStyle; }
private static void SetTextStyle(SpannableString spendable, string texts, TypefaceStyle style) { try { string content = spendable.ToString(); spendable.SetSpan(new StyleSpan(style), content.IndexOf(texts, StringComparison.Ordinal), content.IndexOf(texts, StringComparison.Ordinal) + texts.Length, SpanTypes.ExclusiveExclusive); } catch (Exception e) { Console.WriteLine(e); } }
public PagerSlidingTabStrip (Context context, IAttributeSet attrs, int defStyle) : base (context, attrs, defStyle) { MyOnGlobalLayoutListner = new MyOnGlobalLayoutListener (this); adapterObserver = new PagerAdapterObserver (this); FillViewport = true; this.VerticalScrollBarEnabled = false; this.HorizontalScrollBarEnabled = false; SetWillNotDraw(false); tabsContainer = new LinearLayout (context); tabsContainer.Orientation = Android.Widget.Orientation.Horizontal; tabsContainer.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); AddView(tabsContainer); var dm = Resources.DisplayMetrics; scrollOffset = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, scrollOffset, dm); indicatorHeight = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, indicatorHeight, dm); underlineHeight = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, underlineHeight, dm); dividerPadding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dividerPadding, dm); tabPadding = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, tabPadding, dm); dividerWidth = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dividerWidth, dm); tabTextSize = (int)TypedValue.ApplyDimension(ComplexUnitType.Sp, tabTextSize, dm); //get system attrs (android:textSize and android:textColor) var a = context.ObtainStyledAttributes(attrs, Attrs); tabTextSize = a.GetDimensionPixelSize(TextSizeIndex, tabTextSize); var colorStateList = a.GetColorStateList(TextColorIndex); var textPrimaryColor = a.GetColor(TextColorPrimaryIndex, Android.Resource.Color.White); underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; int padding = a.GetDimensionPixelSize(PaddingIndex, 0); paddingLeft = padding > 0 ? padding : a.GetDimensionPixelSize(PaddingLeftIndex, 0); paddingRight = padding > 0 ? padding : a.GetDimensionPixelSize(PaddingRightIndex, 0); a = context.ObtainStyledAttributes(attrs, Resource.Styleable.PagerSlidingTabStrip); indicatorColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); dividerWidth = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.GetResourceId(Resource.Styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); isPaddingMiddle = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle); tabTypefaceStyle = (TypefaceStyle)a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextStyle, (int)TypefaceStyle.Bold); tabTypefaceSelectedStyle = (TypefaceStyle)a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, (int)TypefaceStyle.Bold); tabTextColorSelected = a.GetColorStateList(Resource.Styleable.PagerSlidingTabStrip_pstsTextColorSelected); textAlpha = a.GetInt(Resource.Styleable.PagerSlidingTabStrip_pstsTextAlpha, textAlpha); a.Recycle(); tabTextColor = colorStateList == null ? GetColorStateList(Color.Argb(textAlpha, Color.GetRedComponent(textPrimaryColor), Color.GetGreenComponent(textPrimaryColor), Color.GetBlueComponent(textPrimaryColor))) : colorStateList; tabTextColorSelected = tabTextColorSelected == null ? GetColorStateList(textPrimaryColor) : tabTextColorSelected; SetMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.AntiAlias = true; rectPaint.SetStyle(Paint.Style.Fill); dividerPaint = new Paint(); dividerPaint.AntiAlias = true; dividerPaint.StrokeWidth = dividerWidth; defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 1.0f); }
TextView GetHeaderItem(TypefaceStyle style) { TextView view = new TextView(context); var parameters = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent, 0.33f); parameters.LeftMargin = Padding; view.LayoutParameters = parameters; view.Typeface = Typeface.Create("Helvetica Neue", style); view.Gravity = Android.Views.GravityFlags.CenterVertical; view.SetTextColor(Color.White); view.SetPadding(0, 20, 0, 20); return view; }
/// <summary> /// Sets the typeface and style used to draw the tab text. /// /// Please note - if the current adapter is an <see cref="IIconTabProvider"/> this will /// have no effect. /// </summary> /// <param name="typeface">The typeface.</param> /// <param name="style">The style.</param> public void SetTypeface(Typeface typeface, TypefaceStyle style) { this._tabTypeface = typeface; this._tabTypefaceStyle = style; UpdateTabStyles(); }
public void SetTypeface(Typeface typeFace, TypefaceStyle style) { this.tabTypeface = typeFace; this.typefaceStyle = style; }
private Typeface CreateTypeface(Context context, int typefaceValue) { try { Typeface typeface; switch (typefaceValue) { case ArialNormal: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/arial.ttf"); break; case ArialBold: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/arialbold.ttf"); m_Style = TypefaceStyle.Bold; break; case ArialItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/arialitalic.ttf"); m_Style = TypefaceStyle.Italic; break; case ArialBoldItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/arial_bold_italic.ttf"); m_Style = TypefaceStyle.BoldItalic; break; default: throw new ArgumentException("Unknown typeface attribute value " + typefaceValue); } return typeface; } catch (Exception) { } return null; }
public ForwardNavigationMenu(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { _mainContainer = new LinearLayout (context); _mainContainer.Orientation = Android.Widget.Orientation.Vertical; _mainContainer.LayoutParameters = new LayoutParams (LayoutParams.MatchParent, LayoutParams.MatchParent); _context = context; var dm = Resources.DisplayMetrics; textSize = (int)TypedValue.ApplyDimension (ComplexUnitType.Sp, textSize, dm); var a = context.ObtainStyledAttributes (attrs, Attrs); a = context.ObtainStyledAttributes (attrs, Resource.Styleable.ForwardNavigationMenu); contentPadding = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmContentPadding, contentPadding); padding = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmPadding, padding); paddingLeft = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmPaddingLeft, paddingLeft); paddingBottom = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmPaddingBottom, paddingBottom); paddingRight = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmPaddingRight, paddingRight); paddingTop = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmPaddingTop, paddingTop); margin = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmMargin, margin); marginRight = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmMarginRight, marginRight); marginLeft = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmMarginLeft, marginLeft); marginBottom = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmMarginBottom, marginBottom); marginTop = a.GetDimensionPixelSize (Resource.Styleable.ForwardNavigationMenu_fnmMarginTop, marginTop); typefaceStyle = (TypefaceStyle)a.GetInt (Resource.Styleable.ForwardNavigationMenu_fnmTextStyle, (int)TypefaceStyle.Normal); textAlpha = a.GetInt (Resource.Styleable.ForwardNavigationMenu_fnmTextAlpha, textAlpha); a.Recycle (); _mainContainer.SetPadding (contentPadding, contentPadding, contentPadding, contentPadding); AddView (_mainContainer); }
private Typeface CreateTypeface(Context context, int typefaceValue) { try { Typeface typeface; switch (typefaceValue) { case RobotoThin: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Thin.ttf"); break; case RobotoThinItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-ThinItalic.ttf"); style = TypefaceStyle.Italic; break; case RobotoLight: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Light.ttf"); break; case RobotoLightItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-LightItalic.ttf"); style = TypefaceStyle.Italic; break; case RobotoRegular: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Regular.ttf"); break; case RobotoItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Italic.ttf"); style = TypefaceStyle.Italic; break; case RobotoMedium: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Medium.ttf"); break; case RobotoMediumItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-MediumItalic.ttf"); style = TypefaceStyle.Italic; break; case RobotoBold: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Bold.ttf"); style = TypefaceStyle.Bold; break; case RobotoBoldItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BoldItalic.ttf"); style = TypefaceStyle.BoldItalic; break; case RobotoBlack: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Black.ttf"); break; case RobotoBlackItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BlackItalic.ttf"); style = TypefaceStyle.Italic; break; case RobotoCondensed: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-Condensed.ttf"); break; case RobotoCondensedItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-CondensedItalic.ttf"); style = TypefaceStyle.Italic; break; case RobotoCondensedBold: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BoldCondensed.ttf"); style = TypefaceStyle.Bold; break; case RobotoCondensedBoldItalic: typeface = Typeface.CreateFromAsset(context.Assets, "fonts/Roboto-BoldCondensedItalic.ttf"); style = TypefaceStyle.BoldItalic; break; default: throw new ArgumentException("Unknown typeface attribute value " + typefaceValue); } return typeface; } catch (Exception) { } return null; }
public override void SetTypeface(Typeface tf, TypefaceStyle style) { base.SetTypeface(tf, style); }
public HintSpan(string family, TypefaceStyle style, int size, ColorStateList color, ColorStateList linkColor) : base(family, style, size, color, linkColor) { }
private Font (string path, TypefaceStyle style) { this.path = path; this.style = style; }