You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8" />
<metaname="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title></head><body><canvasid="canvas" width="300px" height="300px"></canvas><script>constcanvas=document.getElementById('canvas');constctx=canvas.getContext('2d');asyncfunctionmain(){ctx.font='36px PingFang SC, Apple Color Emoji';ctx.fillText('Awesome👩👩👧👧!',20,100);}main();</script></body></html>
in nodejs
import{join}from'node:path';import{promises}from'node:fs';import{SKRSContext2D,createCanvas}from'@napi-rs/canvas';constcanvas=createCanvas(300,300);constctx: SKRSContext2D=canvas.getContext('2d');asyncfunctionmain(){ctx.font='36px PingFang SC, Apple Color Emoji';ctx.fillStyle='#03a9f4';ctx.fillText('Awesome👩👩👧👧!',20,100);// export canvas as imageconstpngData=awaitcanvas.encode('png');// encoding in libuv thread pool, non-blockingawaitpromises.writeFile(join(__dirname,'simple.png'),pngData);}main();
voiddraw(SkCanvas*canvas) {
constchar*fontFamily=nullptr; // Default system family, if it exists.SkFontStylefontStyle; // Default is normal weight, normal width, upright slant.sk_sp<SkTypeface>typeface=fontMgr->legacyMakeTypeface(fontFamily, fontStyle);
SkFontfont1(typeface, 32.0f, 1.0f, 0.0f);
font1.setEdging(SkFont::Edging::kAntiAlias);
// Note: MakeFromString may fail to produce expected results if the typeface// does not have glyphs for the characters in the string. The characters// will not be kerned or shaped beyond a simple mapping from one Unicode// code point to one glyph with a default advance.sk_sp<SkTextBlob>blob1=SkTextBlob::MakeFromString("Awesome😀!", font1);
SkPaintpaint1;
paint1.setAntiAlias(true);
paint1.setColor(SkColorSetARGB(0xFF, 0x42, 0x85, 0xF4));
canvas->clear(SK_ColorWHITE);
canvas->drawTextBlob(blob1.get(), 5.0f, 64.0f, paint1);
}
it seems emoji not vertical aligned, and cant make it currect
The text was updated successfully, but these errors were encountered:
In browser 👇
in nodejs
in skia web
https://fiddle.skia.org/c/57e193a61a79d6423da0dde8eb674d26
it seems emoji not vertical aligned, and cant make it currect
The text was updated successfully, but these errors were encountered: