#include "SkBitmap.h"
#include "SkPaint.h"
#include "SkRect.h"
#include "SkImageEncoder.h"
#include "SkImageInfo.h"
#include "SkImage.h"
#include "SkCanvas.h"
#include "SkEncodedImageFormat.h"
#include "SkTypeface.h"
int main() {
SkBitmap bitmap;
SkImageInfo info = SkImageInfo::Make(1000, 1000, kN32_SkColorType,
kPremul_SkAlphaType);
bitmap.setInfo(info);
bitmap.allocPixels();
SkCanvas canvas(bitmap);
SkPaint paint;
// SkIRect holds four 32 bit integer coordinates for a rectangle.
SkRect r;
paint.setTextSize(64.0f);
//paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
paint.setTypeface(SkTypeface::MakeFromFile("/home/lei/Downloads/NotoColorEmoji.ttf"));
//paint.setTypeface(SkTypeface::MakeFromName("Noto Color Emoji",SkFontStyle::Normal()));
paint.setEmbeddedBitmapText(true);
//paint.setFlags(SkPaint::kEmbeddedBitmapText_Flag);
const char text[] = "Skia😌😀😬😁😂😃";
canvas.drawText(text, strlen(text), 20.0f, 64.0f, paint);
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
sk_sp<SkData> skdata = image.get()->encodeToData(SkEncodedImageFormat::kPNG,
100);
size_t size = skdata.get()->size();
SkFILEWStream skFILEWStream("/home/lei/test.png");
skFILEWStream.write(skdata.get()->data(), size);
skFILEWStream.flush();
// SkImageEncoder is the base class for encoding compressed images
// from a specific SkBitmap.
// SkImageEncoder::EncodeFile("snapshot.png", bitmap, SkImageEncoder::kPNG_Type,/* Quality ranges from 0..100 */ 100);
return 0;
}
I want to draw color emojis on a image with NotoColorEmoji font , but when I run this script I got the "test.png" is blank. What should I do? It is possible to render color emoji on ubuntu 16.04?