use of android.icu.text.BreakIterator in project android_frameworks_base by ResurrectionRemix.
the class StaticLayout_Delegate method nComputeLineBreaks.
@LayoutlibDelegate
static /*package*/
int nComputeLineBreaks(long nativeBuilder, LineBreaks recycle, int[] recycleBreaks, float[] recycleWidths, int[] recycleFlags, int recycleLength) {
Builder builder = sBuilderManager.getDelegate(nativeBuilder);
if (builder == null) {
return 0;
}
// compute all possible breakpoints.
int length = builder.mWidths.length;
BreakIterator it = BreakIterator.getLineInstance(new ULocale(builder.mLocale));
it.setText(new Segment(builder.mText, 0, length));
// average word length in english is 5. So, initialize the possible breaks with a guess.
List<Integer> breaks = new ArrayList<Integer>((int) Math.ceil(length / 5d));
int loc;
it.first();
while ((loc = it.next()) != BreakIterator.DONE) {
breaks.add(loc);
}
List<Primitive> primitives = computePrimitives(builder.mText, builder.mWidths, length, breaks);
switch(builder.mBreakStrategy) {
case Layout.BREAK_STRATEGY_SIMPLE:
builder.mLineBreaker = new GreedyLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
case Layout.BREAK_STRATEGY_HIGH_QUALITY:
// break;
case Layout.BREAK_STRATEGY_BALANCED:
builder.mLineBreaker = new OptimizingLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
default:
throw new AssertionError("Unknown break strategy: " + builder.mBreakStrategy);
}
builder.mLineBreaker.computeBreaks(recycle);
return recycle.breaks.length;
}
use of android.icu.text.BreakIterator in project android_frameworks_base by DirtyUnicorns.
the class StaticLayout_Delegate method nComputeLineBreaks.
@LayoutlibDelegate
static /*package*/
int nComputeLineBreaks(long nativeBuilder, LineBreaks recycle, int[] recycleBreaks, float[] recycleWidths, int[] recycleFlags, int recycleLength) {
Builder builder = sBuilderManager.getDelegate(nativeBuilder);
if (builder == null) {
return 0;
}
// compute all possible breakpoints.
int length = builder.mWidths.length;
BreakIterator it = BreakIterator.getLineInstance(new ULocale(builder.mLocale));
it.setText(new Segment(builder.mText, 0, length));
// average word length in english is 5. So, initialize the possible breaks with a guess.
List<Integer> breaks = new ArrayList<Integer>((int) Math.ceil(length / 5d));
int loc;
it.first();
while ((loc = it.next()) != BreakIterator.DONE) {
breaks.add(loc);
}
List<Primitive> primitives = computePrimitives(builder.mText, builder.mWidths, length, breaks);
switch(builder.mBreakStrategy) {
case Layout.BREAK_STRATEGY_SIMPLE:
builder.mLineBreaker = new GreedyLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
case Layout.BREAK_STRATEGY_HIGH_QUALITY:
// break;
case Layout.BREAK_STRATEGY_BALANCED:
builder.mLineBreaker = new OptimizingLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
default:
throw new AssertionError("Unknown break strategy: " + builder.mBreakStrategy);
}
builder.mLineBreaker.computeBreaks(recycle);
return recycle.breaks.length;
}
use of android.icu.text.BreakIterator in project android_frameworks_base by crdroidandroid.
the class StaticLayout_Delegate method nComputeLineBreaks.
@LayoutlibDelegate
static /*package*/
int nComputeLineBreaks(long nativeBuilder, LineBreaks recycle, int[] recycleBreaks, float[] recycleWidths, int[] recycleFlags, int recycleLength) {
Builder builder = sBuilderManager.getDelegate(nativeBuilder);
if (builder == null) {
return 0;
}
// compute all possible breakpoints.
int length = builder.mWidths.length;
BreakIterator it = BreakIterator.getLineInstance(new ULocale(builder.mLocale));
it.setText(new Segment(builder.mText, 0, length));
// average word length in english is 5. So, initialize the possible breaks with a guess.
List<Integer> breaks = new ArrayList<Integer>((int) Math.ceil(length / 5d));
int loc;
it.first();
while ((loc = it.next()) != BreakIterator.DONE) {
breaks.add(loc);
}
List<Primitive> primitives = computePrimitives(builder.mText, builder.mWidths, length, breaks);
switch(builder.mBreakStrategy) {
case Layout.BREAK_STRATEGY_SIMPLE:
builder.mLineBreaker = new GreedyLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
case Layout.BREAK_STRATEGY_HIGH_QUALITY:
// break;
case Layout.BREAK_STRATEGY_BALANCED:
builder.mLineBreaker = new OptimizingLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
default:
throw new AssertionError("Unknown break strategy: " + builder.mBreakStrategy);
}
builder.mLineBreaker.computeBreaks(recycle);
return recycle.breaks.length;
}
use of android.icu.text.BreakIterator in project platform_frameworks_base by android.
the class StaticLayout_Delegate method nComputeLineBreaks.
@LayoutlibDelegate
static /*package*/
int nComputeLineBreaks(long nativeBuilder, LineBreaks recycle, int[] recycleBreaks, float[] recycleWidths, int[] recycleFlags, int recycleLength) {
Builder builder = sBuilderManager.getDelegate(nativeBuilder);
if (builder == null) {
return 0;
}
// compute all possible breakpoints.
int length = builder.mWidths.length;
BreakIterator it = BreakIterator.getLineInstance(new ULocale(builder.mLocale));
it.setText(new Segment(builder.mText, 0, length));
// average word length in english is 5. So, initialize the possible breaks with a guess.
List<Integer> breaks = new ArrayList<Integer>((int) Math.ceil(length / 5d));
int loc;
it.first();
while ((loc = it.next()) != BreakIterator.DONE) {
breaks.add(loc);
}
List<Primitive> primitives = computePrimitives(builder.mText, builder.mWidths, length, breaks);
switch(builder.mBreakStrategy) {
case Layout.BREAK_STRATEGY_SIMPLE:
builder.mLineBreaker = new GreedyLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
case Layout.BREAK_STRATEGY_HIGH_QUALITY:
// break;
case Layout.BREAK_STRATEGY_BALANCED:
builder.mLineBreaker = new OptimizingLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
default:
throw new AssertionError("Unknown break strategy: " + builder.mBreakStrategy);
}
builder.mLineBreaker.computeBreaks(recycle);
return recycle.breaks.length;
}
use of android.icu.text.BreakIterator in project android_frameworks_base by AOSPA.
the class StaticLayout_Delegate method nComputeLineBreaks.
@LayoutlibDelegate
static /*package*/
int nComputeLineBreaks(long nativeBuilder, LineBreaks recycle, int[] recycleBreaks, float[] recycleWidths, int[] recycleFlags, int recycleLength) {
Builder builder = sBuilderManager.getDelegate(nativeBuilder);
if (builder == null) {
return 0;
}
// compute all possible breakpoints.
int length = builder.mWidths.length;
BreakIterator it = BreakIterator.getLineInstance(new ULocale(builder.mLocale));
it.setText(new Segment(builder.mText, 0, length));
// average word length in english is 5. So, initialize the possible breaks with a guess.
List<Integer> breaks = new ArrayList<Integer>((int) Math.ceil(length / 5d));
int loc;
it.first();
while ((loc = it.next()) != BreakIterator.DONE) {
breaks.add(loc);
}
List<Primitive> primitives = computePrimitives(builder.mText, builder.mWidths, length, breaks);
switch(builder.mBreakStrategy) {
case Layout.BREAK_STRATEGY_SIMPLE:
builder.mLineBreaker = new GreedyLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
case Layout.BREAK_STRATEGY_HIGH_QUALITY:
// break;
case Layout.BREAK_STRATEGY_BALANCED:
builder.mLineBreaker = new OptimizingLineBreaker(primitives, builder.mLineWidth, builder.mTabStopCalculator);
break;
default:
throw new AssertionError("Unknown break strategy: " + builder.mBreakStrategy);
}
builder.mLineBreaker.computeBreaks(recycle);
return recycle.breaks.length;
}
Aggregations