SkCanvas canvas(bitmap);
canvas.clear(SK_ColorRED);
SkPaint paint;
const char str[] = {0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD, 0x0};//"你好";
paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag | SkPaint::kDevKernText_Flag);
paint.setTextSize(SkIntToScalar(256));
canvas.drawString(str, SkIntToScalar(0), SkIntToScalar(256), paint);
What is wrong with my code? Any suggestion is welcome, Thanks!
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.
sk_sp<SkFontMgr> fm = SkFontMgr::RefDefault();
sk_sp<SkTypeface> defaultTypeface = fm->makeFromFile("path/to/fontfiles/fangzhenghuali_GBK");
paint.setTypeface(defaultTypeface);
const char str[] = "\xe4\xbd\xa0\xe5\xa5\xbd"; //你好
paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag | SkPaint::kDevKernText_Flag);
paint.setTextSize(SkIntToScalar(256));
canvas.drawString(str, SkIntToScalar(0), SkIntToScalar(256), paint);
I guess the problem is libskia Android can't find the proper simplified Chinese font files on startup.
sorry:
sk_sp<SkTypeface> defaultTypeface = fm->makeFromFile("path/to/fontfiles/fangzhenghuali_GBK");
should be
sk_sp<SkTypeface> defaultTypeface = fm->makeFromFile("path/to/fontfiles/fangzhenghuali_GBK.TTF");To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.