Ejemplo n.º 1
0
        private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex)
        {
            android.graphics.Typeface tf = null;
            switch (typefaceIndex)
            {
            case SANS:
            {
                tf = android.graphics.Typeface.SANS_SERIF;
                break;
            }

            case SERIF:
            {
                tf = android.graphics.Typeface.SERIF;
                break;
            }

            case MONOSPACE:
            {
                tf = android.graphics.Typeface.MONOSPACE;
                break;
            }
            }
            setSwitchTypeface(tf, styleIndex);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the typeface and style in which the text should be displayed on the
        /// switch, and turns on the fake bold and italic bits in the Paint if the
        /// Typeface that you provided does not have all the bits in the
        /// style that you specified.
        /// </summary>
        /// <remarks>
        /// Sets the typeface and style in which the text should be displayed on the
        /// switch, and turns on the fake bold and italic bits in the Paint if the
        /// Typeface that you provided does not have all the bits in the
        /// style that you specified.
        /// </remarks>
        public virtual void setSwitchTypeface(android.graphics.Typeface tf, int style)
        {
            if (style > 0)
            {
                if (tf == null)
                {
                    tf = android.graphics.Typeface.defaultFromStyle(style);
                }
                else
                {
                    tf = android.graphics.Typeface.create(tf, style);
                }
                setSwitchTypeface(tf);
                // now compute what (if any) algorithmic styling is needed
                int typefaceStyle = tf != null?tf.getStyle() : 0;

                int need = style & ~typefaceStyle;
                mTextPaint.setFakeBoldText((need & android.graphics.Typeface.BOLD) != 0);
                mTextPaint.setTextSkewX((need & android.graphics.Typeface.ITALIC) != 0 ? -0.25f :
                                        0);
            }
            else
            {
                mTextPaint.setFakeBoldText(false);
                mTextPaint.setTextSkewX(0);
                setSwitchTypeface(tf);
            }
        }
Ejemplo n.º 3
0
 /// <summary>Sets the typeface in which the text should be displayed on the switch.</summary>
 /// <remarks>
 /// Sets the typeface in which the text should be displayed on the switch.
 /// Note that not all Typeface families actually have bold and italic
 /// variants, so you may need to use
 /// <see cref="setSwitchTypeface(android.graphics.Typeface, int)">setSwitchTypeface(android.graphics.Typeface, int)
 ///     </see>
 /// to get the appearance
 /// that you actually want.
 /// </remarks>
 /// <attr>ref android.R.styleable#TextView_typeface</attr>
 /// <attr>ref android.R.styleable#TextView_textStyle</attr>
 public virtual void setSwitchTypeface(android.graphics.Typeface tf)
 {
     if (mTextPaint.getTypeface() != tf)
     {
         mTextPaint.setTypeface(tf);
         requestLayout();
         invalidate();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a typeface object that best matches the specified existing
 /// typeface and the specified Style.
 /// </summary>
 /// <remarks>
 /// Create a typeface object that best matches the specified existing
 /// typeface and the specified Style. Use this call if you want to pick a new
 /// style from the same family of an existing typeface object. If family is
 /// null, this selects from the default font's family.
 /// </remarks>
 /// <param name="family">May be null. The name of the existing type face.</param>
 /// <param name="style">
 /// The style (normal, bold, italic) of the typeface.
 /// e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC
 /// </param>
 /// <returns>The best matching typeface.</returns>
 public static android.graphics.Typeface create(android.graphics.Typeface family,
                                                int style)
 {
     android.graphics.Typeface.NativeTypeface ni = null;
     if (family != null)
     {
         ni = family.native_instance;
     }
     return(new android.graphics.Typeface(nativeCreateFromTypeface(ni, style)));
 }
Ejemplo n.º 5
0
 public CustomTypefaceSpan(Icon icon, Typeface type, float iconSizePx, float iconSizeRatio, int iconColor, bool rotate)
 {
     this.rotate            = rotate;
     this.icon              = icon.character().ToString();
     this.type              = type;
     this.iconSizePx        = iconSizePx;
     this.iconSizeRatio     = iconSizeRatio;
     this.iconColor         = iconColor;
     this.rotationStartTime = DateTimeHelperClass.CurrentUnixTimeMillis();
 }
Ejemplo n.º 6
0
 static Typeface()
 {
     DEFAULT      = create((string)null, 0);
     DEFAULT_BOLD = create((string)null, android.graphics.Typeface.BOLD);
     SANS_SERIF   = create("sans-serif", 0);
     SERIF        = create("serif", 0);
     MONOSPACE    = create("monospace", 0);
     sDefaults    = new android.graphics.Typeface[] { DEFAULT, DEFAULT_BOLD, create((string
                                                                                     )null, android.graphics.Typeface.ITALIC), create((string)null, android.graphics.Typeface
                                                                                                                                      .BOLD_ITALIC) };
 }
 public virtual Typeface getTypeface(Context context)
 {
     if (cachedTypeface != null)
     {
         return cachedTypeface;
     }
     lock (this)
     {
         if (cachedTypeface != null)
         {
             return cachedTypeface;
         }
         cachedTypeface = Typeface.createFromAsset(context.Assets, iconFontDescriptor.ttfFileName());
         return cachedTypeface;
     }
 }
Ejemplo n.º 8
0
 private void applyCustomTypeFace(Paint paint, Typeface tf)
 {
     paint.FakeBoldText = false;
     paint.TextSkewX    = 0f;
     paint.Typeface     = tf;
     if (rotate)
     {
         paint.clearShadowLayer();
     }
     if (iconSizeRatio > 0)
     {
         paint.TextSize = paint.TextSize * iconSizeRatio;
     }
     else if (iconSizePx > 0)
     {
         paint.TextSize = iconSizePx;
     }
     if (iconColor < int.MaxValue)
     {
         paint.Color = iconColor;
     }
 }
Ejemplo n.º 9
0
		static Typeface()
		{
			DEFAULT = create((string)null, 0);
			DEFAULT_BOLD = create((string)null, android.graphics.Typeface.BOLD);
			SANS_SERIF = create("sans-serif", 0);
			SERIF = create("serif", 0);
			MONOSPACE = create("monospace", 0);
			sDefaults = new android.graphics.Typeface[] { DEFAULT, DEFAULT_BOLD, create((string
				)null, android.graphics.Typeface.ITALIC), create((string)null, android.graphics.Typeface
				.BOLD_ITALIC) };
		}
Ejemplo n.º 10
0
 internal AmPm(android.view.View parent, android.graphics.Typeface tf)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 11
0
		/// <summary>
		/// Set all class variables using current values from the given
		/// <see cref="Paint">Paint</see>
		/// .
		/// </summary>
		private void setClassVariablesFrom(android.graphics.Paint paint)
		{
			mColorFilter = paint.mColorFilter;
			mMaskFilter = paint.mMaskFilter;
			mPathEffect = paint.mPathEffect;
			mRasterizer = paint.mRasterizer;
			mShader = paint.mShader;
			mTypeface = paint.mTypeface;
			mXfermode = paint.mXfermode;
			mHasCompatScaling = paint.mHasCompatScaling;
			mCompatScaling = paint.mCompatScaling;
			mInvCompatScaling = paint.mInvCompatScaling;
			hasShadow = paint.hasShadow;
			shadowDx = paint.shadowDx;
			shadowDy = paint.shadowDy;
			shadowRadius = paint.shadowRadius;
			shadowColor = paint.shadowColor;
			mBidiFlags = paint.mBidiFlags;
		}
Ejemplo n.º 12
0
		/// <summary>Set or clear the typeface object.</summary>
		/// <remarks>
		/// Set or clear the typeface object.
		/// <p />
		/// Pass null to clear any previous typeface.
		/// As a convenience, the parameter passed is also returned.
		/// </remarks>
		/// <param name="typeface">May be null. The typeface to be installed in the paint</param>
		/// <returns>typeface</returns>
		public virtual android.graphics.Typeface setTypeface(android.graphics.Typeface typeface
			)
		{
			android.graphics.Typeface.NativeTypeface typefaceNative = null;
			if (typeface != null)
			{
				typefaceNative = typeface.native_instance;
			}
			native_setTypeface(mNativePaint, typefaceNative);
			mTypeface = typeface;
			return typeface;
		}
Ejemplo n.º 13
0
 public static global::android.graphics.Typeface create(android.graphics.Typeface arg0, int arg1)
 {
     global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallStaticObjectMethod(android.graphics.Typeface.staticClass, global::android.graphics.Typeface._create3808, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as android.graphics.Typeface);
 }