void _drawTextDrawMeshCallback(uiPaint p, uiMeshMesh fillMesh, uiMeshMesh strokeMesh, bool convex, float alpha, float strokeMult, Texture tex, uiRect textBlobBounds, TextBlobMesh textMesh, bool notEmoji) { if (!this._applyClip(textBlobBounds)) { ObjectPool <TextBlobMesh> .release(textMesh); return; } var layer = this._currentLayer; if (notEmoji) { layer.draws.Add(CanvasShader.texAlpha(layer, p, textMesh, tex)); } else { uiPaint paintWithWhite = new uiPaint(p); paintWithWhite.color = uiColor.white; if (EmojiUtils.image == null) { ObjectPool <TextBlobMesh> .release(textMesh); return; } var raw_mesh = textMesh.resolveMesh(); var meshmesh = raw_mesh.duplicate(); ObjectPool <TextBlobMesh> .release(textMesh); layer.draws.Add(CanvasShader.tex(layer, paintWithWhite, meshmesh, EmojiUtils.image)); } }
void _drawTextBlob(TextBlob textBlob, Offset offset, Paint paint) { D.assert(textBlob != null); D.assert(offset != null); D.assert(paint != null); var state = this._currentLayer.currentState; var scale = state.scale * this._devicePixelRatio; var matrix = new Matrix3(state.matrix); matrix.preTranslate(offset.dx, offset.dy); var mesh = new TextBlobMesh(textBlob, scale, matrix); // request font texture so text mesh could be generated correctly var font = FontManager.instance.getOrCreate(textBlob.style.fontFamily).font; var style = textBlob.style; var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * scale); var subText = textBlob.text.Substring(textBlob.textOffset, textBlob.textSize); font.RequestCharactersInTexture(subText, fontSizeToLoad, style.UnityFontStyle); var tex = font.material.mainTexture; Action <Paint> drawMesh = (Paint p) => { if (!this._applyClip(textBlob.bounds)) { return; } var layer = this._currentLayer; layer.draws.Add(CanvasShader.texAlpha(layer, p, mesh, tex)); }; if (paint.maskFilter != null && paint.maskFilter.sigma != 0) { this._drawWithMaskFilter(textBlob.bounds, drawMesh, paint, paint.maskFilter); return; } drawMesh(paint); }
void _drawTextBlob(TextBlob textBlob, Offset offset, Paint paint) { D.assert(textBlob != null); D.assert(offset != null); D.assert(paint != null); var state = this._currentLayer.currentState; var scale = state.scale * this._devicePixelRatio; var matrix = new Matrix3(state.matrix); matrix.preTranslate(offset.dx, offset.dy); var mesh = MeshGenerator.generateMesh(textBlob, scale)?.transform(matrix); if (mesh == null) { return; } var font = FontManager.instance.getOrCreate(textBlob.style.fontFamily).font; var tex = font.material.mainTexture; Action <Paint> drawMesh = (Paint p) => { if (!this._applyClip(mesh.bounds)) { return; } var layer = this._currentLayer; layer.draws.Add(CanvasShader.texAlpha(layer, p, mesh, tex)); }; if (paint.maskFilter != null && paint.maskFilter.sigma != 0) { this._drawWithMaskFilter(mesh.bounds, drawMesh, paint, paint.maskFilter); return; } drawMesh(paint); }