internal virtual float addStyleRun(android.text.TextPaint paint, android.text.style.MetricAffectingSpan [] spans, int len, android.graphics.Paint.FontMetricsInt fm) { android.text.TextPaint workPaint = mWorkPaint; workPaint.set(paint); // XXX paint should not have a baseline shift, but... workPaint.baselineShift = 0; android.text.style.ReplacementSpan replacement = null; { for (int i = 0; i < spans.Length; i++) { android.text.style.MetricAffectingSpan span = spans[i]; if (span is android.text.style.ReplacementSpan) { replacement = (android.text.style.ReplacementSpan)span; } else { span.updateMeasureState(workPaint); } } } float wid; if (replacement == null) { wid = addStyleRun(workPaint, len, fm); } else { // Use original text. Shouldn't matter. wid = replacement.getSize(workPaint, mText, mTextStart + mPos, mTextStart + mPos + len, fm); float[] w = mWidths; w[mPos] = wid; { int i_1 = mPos + 1; int e = mPos + len; for (; i_1 < e; i_1++) { w[i_1] = 0; } } mPos += len; } if (fm != null) { if (workPaint.baselineShift < 0) { fm.ascent += workPaint.baselineShift; fm.top += workPaint.baselineShift; } else { fm.descent += workPaint.baselineShift; fm.bottom += workPaint.baselineShift; } } return(wid); }
internal virtual float addStyleRun(android.text.TextPaint paint, int len, android.graphics.Paint .FontMetricsInt fm) { if (fm != null) { paint.getFontMetricsInt(fm); } int p = mPos; mPos = p + len; if (mEasy) { int flags = mDir == android.text.Layout.DIR_LEFT_TO_RIGHT ? android.graphics.Canvas .DIRECTION_LTR : android.graphics.Canvas.DIRECTION_RTL; return(paint.getTextRunAdvances(mChars, p, len, p, len, flags, mWidths, p)); } float totalAdvance = 0; int level = mLevels[p]; { int q = p; int i = p + 1; int e = p + len; for (; ; ++i) { if (i == e || mLevels[i] != level) { int flags = (level & unchecked ((int)(0x1))) == 0 ? android.graphics.Canvas.DIRECTION_LTR : android.graphics.Canvas.DIRECTION_RTL; totalAdvance += paint.getTextRunAdvances(mChars, q, i - q, q, i - q, flags, mWidths , q); if (i == e) { break; } q = i; level = mLevels[i]; } } } return(totalAdvance); }
public int getSize(android.graphics.Paint arg0, string arg1, int arg2, int arg3, android.graphics.Paint.FontMetricsInt arg4) { return(getSize(arg0, (global::java.lang.CharSequence)(global::java.lang.String) arg1, arg2, arg3, arg4)); }
public override int getSize(android.graphics.Paint arg0, java.lang.CharSequence arg1, int arg2, int arg3, android.graphics.Paint.FontMetricsInt arg4) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(@__env.CallIntMethod(this.JvmHandle, global::android.text.style.DynamicDrawableSpan._getSize8247, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4))); } else { return(@__env.CallNonVirtualIntMethod(this.JvmHandle, global::android.text.style.DynamicDrawableSpan.staticClass, global::android.text.style.DynamicDrawableSpan._getSize8247, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4))); } }
/// <summary> /// Make a layout for the transformed text (password transformation /// being the primary example of a transformation) /// that will be updated as the base text is changed. /// </summary> /// <remarks> /// Make a layout for the transformed text (password transformation /// being the primary example of a transformation) /// that will be updated as the base text is changed. /// If ellipsize is non-null, the Layout will ellipsize the text /// down to ellipsizedWidth. /// * /// *@hide /// </remarks> public DynamicLayout(java.lang.CharSequence @base, java.lang.CharSequence display , android.text.TextPaint paint, int width, android.text.Layout.Alignment?align, android.text.TextDirectionHeuristic textDir, float spacingmult, float spacingadd , bool includepad, android.text.TextUtils.TruncateAt?ellipsize_1, int ellipsizedWidth ) : base((ellipsize_1 == null) ? display : (display is android.text.Spanned) ? new android.text.Layout.SpannedEllipsizer(display) : new android.text.Layout.Ellipsizer (display), paint, width, align, textDir, spacingmult, spacingadd) { mBase = @base; mDisplay = display; if (ellipsize_1 != null) { mInts = new android.text.PackedIntVector(COLUMNS_ELLIPSIZE); mEllipsizedWidth = ellipsizedWidth; mEllipsizeAt = ellipsize_1; } else { mInts = new android.text.PackedIntVector(COLUMNS_NORMAL); mEllipsizedWidth = width; mEllipsizeAt = null; } mObjects = new android.text.PackedObjectVector <android.text.Layout.Directions>(1); mIncludePad = includepad; if (ellipsize_1 != null) { android.text.Layout.Ellipsizer e = (android.text.Layout.Ellipsizer)getText(); e.mLayout = this; e.mWidth = ellipsizedWidth; e.mMethod = ellipsize_1; mEllipsize = true; } // Initial state is a single line with 0 characters (0 to 0), // with top at 0 and bottom at whatever is natural, and // undefined ellipsis. int[] start; if (ellipsize_1 != null) { start = new int[COLUMNS_ELLIPSIZE]; start[ELLIPSIS_START] = ELLIPSIS_UNDEFINED; } else { start = new int[COLUMNS_NORMAL]; } android.text.Layout.Directions[] dirs = new android.text.Layout.Directions[] { DIRS_ALL_LEFT_TO_RIGHT }; android.graphics.Paint.FontMetricsInt fm = paint.getFontMetricsInt(); int asc = fm.ascent; int desc = fm.descent; start[DIR] = DIR_LEFT_TO_RIGHT << DIR_SHIFT; start[TOP] = 0; start[DESCENT] = desc; mInts.insertAt(0, start); start[TOP] = desc - asc; mInts.insertAt(1, start); mObjects.insertAt(0, dirs); // Update from 0 characters to whatever the real text is reflow(@base, 0, 0, @base.Length); if (@base is android.text.Spannable) { if (mWatcher == null) { mWatcher = new android.text.DynamicLayout.ChangeWatcher(this); } // Strip out any watchers for other DynamicLayouts. android.text.Spannable sp = (android.text.Spannable)@base; android.text.DynamicLayout.ChangeWatcher[] spans = sp.getSpans <android.text.DynamicLayout .ChangeWatcher>(0, sp.Length); { for (int i = 0; i < spans.Length; i++) { sp.removeSpan(spans[i]); } } sp.setSpan(mWatcher, 0, @base.Length, android.text.SpannedClass.SPAN_INCLUSIVE_INCLUSIVE | (PRIORITY << android.text.SpannedClass.SPAN_PRIORITY_SHIFT)); } }
public virtual void chooseHeight(java.lang.CharSequence text, int start, int end, int istartv, int v, android.graphics.Paint.FontMetricsInt fm) { throw new System.NotImplementedException(); }
void android.text.style.LineHeightSpan.chooseHeight(java.lang.CharSequence arg0, int arg1, int arg2, int arg3, int arg4, android.graphics.Paint.FontMetricsInt arg5) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.text.style.LineHeightSpan_WithDensity_._chooseHeight8295, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg5)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.text.style.LineHeightSpan_WithDensity_.staticClass, global::android.text.style.LineHeightSpan_WithDensity_._chooseHeight8295, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg5)); } }
public static android.graphics.Paint.FontMetricsInt NativeToManaged(System.IntPtr ptr) { if (ptr == System.IntPtr.Zero) { return null; } FontMetricsInt_Struct obj = (FontMetricsInt_Struct)Marshal.PtrToStructure(ptr, typeof( FontMetricsInt_Struct)); android.graphics.Paint.FontMetricsInt arg = new android.graphics.Paint.FontMetricsInt (); arg.top = obj.top; arg.ascent = obj.ascent; arg.descent = obj.descent; arg.bottom = obj.bottom; arg.leading = obj.leading; return arg; }
public virtual android.graphics.Paint.FontMetricsInt getFontMetricsInt() { android.graphics.Paint.FontMetricsInt fm = new android.graphics.Paint.FontMetricsInt (); getFontMetricsInt(fm); return fm; }
/// <summary>Utility function for handling a unidirectional run.</summary> /// <remarks> /// Utility function for handling a unidirectional run. The run must not /// contain tabs or emoji but can contain styles. /// </remarks> /// <param name="start">the line-relative start of the run</param> /// <param name="measureLimit">the offset to measure to, between start and limit inclusive /// </param> /// <param name="limit">the limit of the run</param> /// <param name="runIsRtl">true if the run is right-to-left</param> /// <param name="c">the canvas, can be null</param> /// <param name="x">the end of the run closest to the leading margin</param> /// <param name="top">the top of the line</param> /// <param name="y">the baseline</param> /// <param name="bottom">the bottom of the line</param> /// <param name="fmi">receives metrics information, can be null</param> /// <param name="needWidth">true if the width is required</param> /// <returns> /// the signed width of the run based on the run direction; only /// valid if needWidth is true /// </returns> private float handleRun(int start, int measureLimit, int limit, bool runIsRtl, android.graphics.Canvas c, float x, int top, int y, int bottom, android.graphics.Paint.FontMetricsInt fmi , bool needWidth) { // Case of an empty line, make sure we update fmi according to mPaint if (start == measureLimit) { android.text.TextPaint wp = mWorkPaint; wp.set(mPaint); if (fmi != null) { expandMetricsFromPaint(fmi, wp); } return(0f); } if (mSpanned == null) { android.text.TextPaint wp = mWorkPaint; wp.set(mPaint); int mlimit = measureLimit; return(handleText(wp, start, mlimit, start, limit, runIsRtl, c, x, top, y, bottom , fmi, needWidth || mlimit < measureLimit)); } android.text.TextLine.SpanSet <android.text.style.MetricAffectingSpan> metricAffectingSpans = new android.text.TextLine.SpanSet <android.text.style.MetricAffectingSpan>(mSpanned , mStart + start, mStart + limit); android.text.TextLine.SpanSet <android.text.style.CharacterStyle> characterStyleSpans = new android.text.TextLine.SpanSet <android.text.style.CharacterStyle>(mSpanned , mStart + start, mStart + limit); // Shaping needs to take into account context up to metric boundaries, // but rendering needs to take into account character style boundaries. // So we iterate through metric runs to get metric bounds, // then within each metric run iterate through character style runs // for the run bounds. float originalX = x; { int i = start; int inext; for (; i < measureLimit; i = inext) { android.text.TextPaint wp = mWorkPaint; wp.set(mPaint); inext = metricAffectingSpans.getNextTransition(mStart + i, mStart + limit) - mStart; int mlimit = System.Math.Min(inext, measureLimit); android.text.style.ReplacementSpan replacement = null; { for (int j = 0; j < metricAffectingSpans.numberOfSpans; j++) { // Both intervals [spanStarts..spanEnds] and [mStart + i..mStart + mlimit] are NOT // empty by construction. This special case in getSpans() explains the >= & <= tests if ((metricAffectingSpans.spanStarts[j] >= mStart + mlimit) || (metricAffectingSpans .spanEnds[j] <= mStart + i)) { continue; } android.text.style.MetricAffectingSpan span = metricAffectingSpans.spans[j]; if (span is android.text.style.ReplacementSpan) { replacement = (android.text.style.ReplacementSpan)span; } else { // We might have a replacement that uses the draw // state, otherwise measure state would suffice. span.updateDrawState(wp); } } } if (replacement != null) { x += handleReplacement(replacement, wp, i, mlimit, runIsRtl, c, x, top, y, bottom , fmi, needWidth || mlimit < measureLimit); continue; } if (c == null) { x += handleText(wp, i, mlimit, i, inext, runIsRtl, c, x, top, y, bottom, fmi, needWidth || mlimit < measureLimit); } else { { int j_1 = i; int jnext; for (; j_1 < mlimit; j_1 = jnext) { jnext = characterStyleSpans.getNextTransition(mStart + j_1, mStart + mlimit) - mStart; wp.set(mPaint); { for (int k = 0; k < characterStyleSpans.numberOfSpans; k++) { // Intentionally using >= and <= as explained above if ((characterStyleSpans.spanStarts[k] >= mStart + jnext) || (characterStyleSpans .spanEnds[k] <= mStart + j_1)) { continue; } android.text.style.CharacterStyle span = characterStyleSpans.spans[k]; span.updateDrawState(wp); } } x += handleText(wp, j_1, jnext, i, inext, runIsRtl, c, x, top, y, bottom, fmi, needWidth || jnext < measureLimit); } } } } } return(x - originalX); }
public abstract int getSize(android.graphics.Paint paint, java.lang.CharSequence text, int start, int end, android.graphics.Paint.FontMetricsInt fm);
public void chooseHeight(string arg0, int arg1, int arg2, int arg3, int arg4, android.graphics.Paint.FontMetricsInt arg5) { chooseHeight((global::java.lang.CharSequence)(global::java.lang.String) arg0, arg1, arg2, arg3, arg4, arg5); }
public abstract int getSize(android.graphics.Paint arg0, java.lang.CharSequence arg1, int arg2, int arg3, android.graphics.Paint.FontMetricsInt arg4);
public override int getSize(android.graphics.Paint paint, java.lang.CharSequence text, int start, int end, android.graphics.Paint.FontMetricsInt fm) { throw new System.NotImplementedException(); }