public LayoutCacheKey(FontCollection collection, MinikinPaint paint, FontStyle style, UInt16 chars, int start, int count, int nchars, bool dir) { this.mChars = chars; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mNchars = nchars; this.mNchars.CopyFrom(nchars); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mStart = start; this.mStart.CopyFrom(start); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mCount = count; this.mCount.CopyFrom(count); this.mId = collection.getId(); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mStyle = style; this.mStyle.CopyFrom(style); this.mSize = paint.size; this.mScaleX = paint.scaleX; this.mSkewX = paint.skewX; this.mLetterSpacing = paint.letterSpacing; this.mPaintFlags = paint.paintFlags; this.mHyphenEdit = paint.hyphenEdit; this.mIsRtl = dir; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mHash = computeHash(); this.mHash.CopyFrom(computeHash()); }
public void doLayout(UInt16 buf, int start, int count, int bufSize, bool isRtl, FontStyle style, MinikinPaint paint, FontCollection collection) { std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock); LayoutContext ctx = new LayoutContext(); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: ctx.style = style; ctx.style.CopyFrom(style); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: ctx.paint = paint; ctx.paint.CopyFrom(paint); reset(); mAdvances.resize(count, 0); doLayoutRunCached(buf, start, count, bufSize, isRtl, ctx, start, collection, this, null); ctx.clearHbFonts(); }
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: virtual void GetBounds(MinikinRect* bounds, uint glyph_id, const MinikinPaint& paint) const = 0; public abstract void GetBounds(MinikinRect bounds, uint glyph_id, MinikinPaint paint);
// TODO: this class is actually fairly close to being general and not tied to // using Minikin to do the shaping of the strings. The main thing that would // need to be changed is having some kind of callback (or virtual class, or // maybe even template), which could easily be instantiated with Minikin's // Layout. Future work for when needed. public float addStyleRun(MinikinPaint paint, FontCollection typeface, FontStyle style, int start, int end, bool isRtl) { float width = 0.0f; int bidiFlags = isRtl ? kBidi_Force_RTL : kBidi_Force_LTR; float hyphenPenalty = 0.0F; if (paint != null) { width = Layout.measureText(mTextBuf.data(), start, end - start, mTextBuf.size(), bidiFlags, style, paint, typeface, mCharWidths.data() + start); // a heuristic that seems to perform well hyphenPenalty = 0.5 * paint.size * paint.scaleX * mLineWidths.getLineWidth(0); if (mHyphenationFrequency == kHyphenationFrequency_Normal) { hyphenPenalty *= 4.0; // TODO: Replace with a better value after some testing } if (mJustified) { // Make hyphenation more aggressive for fully justified text (so that // "normal" in justified mode is the same as "full" in ragged-right). hyphenPenalty *= 0.25; } else { // Line penalty is zero for justified text. mLinePenalty = Math.Max(mLinePenalty, hyphenPenalty * LINE_PENALTY_MULTIPLIER); } } int current = (int)mWordBreaker.current(); int afterWord = start; int lastBreak = start; ParaWidth lastBreakWidth = mWidth; ParaWidth postBreak = mWidth; int postSpaceCount = mSpaceCount; for (int i = start; i < end; i++) { UInt16 c = mTextBuf[i]; if (c == CHAR_TAB) { mWidth = mPreBreak + mTabStops.nextTab(mWidth - mPreBreak); if (mFirstTabIndex == INT_MAX) { mFirstTabIndex = (int)i; } // fall back to greedy; other modes don't know how to deal with tabs mStrategy = kBreakStrategy_Greedy; } else { if (isWordSpace(new UInt16(c))) { mSpaceCount += 1; } mWidth += mCharWidths[i]; if (!isLineEndSpace(new UInt16(c))) { postBreak = mWidth; postSpaceCount = mSpaceCount; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: afterWord = i + 1; afterWord.CopyFrom(i + 1); } } if (i + 1 == current != null) { int wordStart = mWordBreaker.wordStart(); int wordEnd = mWordBreaker.wordEnd(); if (paint != null && mHyphenator != null && mHyphenationFrequency != kHyphenationFrequency_None && wordStart >= start != null && wordEnd > wordStart && wordEnd - wordStart <= LONGEST_HYPHENATED_WORD) { mHyphenator.hyphenate(mHyphBuf, mTextBuf[wordStart], wordEnd - wordStart, mLocale); #if VERBOSE_DEBUG string hyphenatedString; for (int j = wordStart; j < wordEnd; j++) { if (mHyphBuf[j - wordStart] == HyphenationType.BREAK_AND_INSERT_HYPHEN) { hyphenatedString.push_back('-'); } // Note: only works with ASCII, should do UTF-8 conversion here hyphenatedString.push_back(buffer()[j]); } ALOGD("hyphenated string: %s", hyphenatedString); #endif // measure hyphenated substrings for (int j = wordStart; j < wordEnd; j++) { HyphenationType hyph = mHyphBuf[j - wordStart]; if (hyph != HyphenationType.DONT_BREAK) { paint.hyphenEdit = HyphenEdit.editForThisLine(hyph); float firstPartWidth = Layout.measureText(mTextBuf.data(), lastBreak, j - lastBreak, mTextBuf.size(), bidiFlags, style, paint, typeface, null); ParaWidth hyphPostBreak = lastBreakWidth + firstPartWidth; paint.hyphenEdit = HyphenEdit.editForNextLine(hyph); float secondPartWidth = Layout.measureText(mTextBuf.data(), j, afterWord - j, mTextBuf.size(), bidiFlags, style, paint, typeface, null); ParaWidth hyphPreBreak = postBreak - secondPartWidth; addWordBreak(j, hyphPreBreak, hyphPostBreak, postSpaceCount, postSpaceCount, hyphenPenalty, hyph); paint.hyphenEdit = HyphenEdit.NO_EDIT; } } } // Skip break for zero-width characters inside replacement span if (paint != null || current == end || mCharWidths[current] > 0) { float penalty = hyphenPenalty * mWordBreaker.breakBadness(); addWordBreak(current, mWidth, postBreak, mSpaceCount, postSpaceCount, penalty, HyphenationType.DONT_BREAK); } //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: lastBreak = current; lastBreak.CopyFrom(current); lastBreakWidth = mWidth; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: current = (int)mWordBreaker.next(); current.CopyFrom((int)mWordBreaker.next()); } } return(width); }
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: virtual float GetHorizontalAdvance(uint glyph_id, const MinikinPaint& paint) const = 0; public abstract float GetHorizontalAdvance(uint glyph_id, MinikinPaint paint);