Skip to content

Commit

Permalink
fix: fix issue with measureText in lynx env
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Jan 9, 2025
1 parent 672210a commit be52f12
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/vrender-kits/src/canvas/contributions/lynx/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ export class LynxContext2d extends BrowserContext2d implements IContext2d {
method: 'native' | 'simple' | 'quick' = application.global.measureTextMethod
): { width: number } {
this.setTransform(1, 0, 0, 1, 0, 0, true, application.global.devicePixelRatio);
const data = super.measureText(text, method);
return data;
const data: any = super.measureText(text, method);
// lynx环境中的fontBoundingBoxDescent和fontBoundingBoxAscent有严重偏移,暂时规避
return {
width: data.width,
fontBoundingBoxDescent: undefined,
fontBoundingBoxAscent: undefined,
actualBoundingBoxAscent: undefined,
actualBoundingBoxDescent: undefined
} as any;
}

createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern {
Expand Down

0 comments on commit be52f12

Please sign in to comment.