#define LOG_TAG "Minikin"
#include <cutils/log.h>
+#include <string>
#include "SkPaint.h"
#include "minikin/Layout.h"
return off + n;
}
-void MinikinUtils::SetLayoutProperties(Layout* layout, const SkPaint* paint, int flags,
- TypefaceImpl* typeface) {
+std::string MinikinUtils::setLayoutProperties(Layout* layout, const SkPaint* paint, int bidiFlags,
+ TypefaceImpl* typeface) {
TypefaceImpl* resolvedFace = TypefaceImpl_resolveDefault(typeface);
layout->setFontCollection(resolvedFace->fFontCollection);
FontStyle style = resolvedFace->fStyle;
MinikinFontSkia::packPaintFlags(paint),
style.getWeight() * 100,
style.getItalic() ? "italic" : "normal",
- flags);
+ bidiFlags);
SkString langString = paint->getPaintOptionsAndroid().getLanguage().getTag();
off = snprintfcat(css, off, sizeof(css), " lang: %s;", langString.c_str());
SkPaintOptionsAndroid::FontVariant var = paint->getPaintOptionsAndroid().getFontVariant();
const char* varstr = var == SkPaintOptionsAndroid::kElegant_Variant ? "elegant" : "compact";
off = snprintfcat(css, off, sizeof(css), " -minikin-variant: %s;", varstr);
layout->setProperties(css);
+ return std::string(css);
}
float MinikinUtils::xOffsetForTextAlign(SkPaint* paint, const Layout& layout) {
#ifdef USE_MINIKIN
Layout layout;
TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(textArray + index, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(textArray, index, count, textLength, css);
result = layout.getAdvance();
#else
TextLayout::getTextRunAdvances(paint, textArray, index, count, textLength,
#ifdef USE_MINIKIN
Layout layout;
TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(textArray + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(textArray, start, count, textLength, css);
width = layout.getAdvance();
#else
TextLayout::getTextRunAdvances(paint, textArray, start, count, textLength,
#ifdef USE_MINIKIN
Layout layout;
TypefaceImpl* typeface = GraphicsJNI::getNativeTypeface(env, jpaint);
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(textArray, textLength);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(textArray, 0, textLength, textLength, css);
width = layout.getAdvance();
#else
TextLayout::getTextRunAdvances(paint, textArray, 0, textLength, textLength,
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(text, 0, count, count, css);
layout.getAdvances(widthsArray);
#else
TextLayout::getTextRunAdvances(paint, text, 0, count, count,
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(text + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(text, start, count, contextCount, css);
layout.getAdvances(advancesArray);
totalAdvance = layout.getAdvance();
#else
jint count, jint bidiFlags, jfloat x, jfloat y, SkPath* path) {
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, bidiFlags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, bidiFlags, typeface);
+ layout.doLayout(text, 0, count, count, css);
size_t nGlyphs = layout.nGlyphs();
uint16_t* glyphs = new uint16_t[nGlyphs];
SkPoint* pos = new SkPoint[nGlyphs];
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, &paint, bidiFlags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, &paint, bidiFlags, typeface);
+ layout.doLayout(text, 0, count, count, css);
MinikinRect rect;
layout.getBounds(&rect);
r.fLeft = rect.mLeft;
jfloat x, jfloat y, int flags, SkPaint* paint, TypefaceImpl* typeface) {
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(text, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(text, 0, count, count, css);
x += xOffsetForTextAlign(paint, layout.getAdvance());
renderTextLayout(renderer, &layout, x, y, paint);
#else
int flags, SkPaint* paint, TypefaceImpl* typeface) {
#ifdef USE_MINIKIN
Layout layout;
- MinikinUtils::SetLayoutProperties(&layout, paint, flags, typeface);
- layout.doLayout(text + start, count);
+ std::string css = MinikinUtils::setLayoutProperties(&layout, paint, flags, typeface);
+ layout.doLayout(text, start, count, contextCount, css);
x += xOffsetForTextAlign(paint, layout.getAdvance());
renderTextLayout(renderer, &layout, x, y, paint);
#else