Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows10 node-canvas cannot register existing type 'PangoCairoFontMap #3736

Closed
DannyWin opened this issue Jul 21, 2023 · 4 comments
Closed
Labels

Comments

@DannyWin
Copy link

Possible bug

Are you using the latest version of sharp?

yes, sharp 0.32.3

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System:
OS: Windows 10 10.0.19045
CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
Memory: 6.62 GB / 15.36 GB
Binaries:
Node: 14.21.3 - C:\Program Files\nodejs\node.EXE
npm: 6.14.18 - C:\Program Files\nodejs\npm.CMD
pnpm: 7.17.0 - ~\AppData\Roaming\npm\pnpm.CMD
npmPackages:
sharp: ^0.32.1 => 0.32.3

What are the steps to reproduce?

install sharp 0.32.3
install canvas 2.11.2

What is the expected behaviour?

Overlay text and canvas images on a basemap

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

import { createCanvas} from 'canvas';
import sharp from 'sharp';

const basePicture='./test.png'
const textArray = [
    {
      input: {
        text: {
          font: 'OPPOSans',
          fontfile: './assets/font/OPPOSans-R.ttf',
          align: 'right',
          text: `<span foreground='#333999' size='150'>text words</span>`,
          rgba: true,
          width: 600,
          height: 60,
        },
      },
      top: 462,
      left: 220,
    },
  ],
const textBuffer=sharp(basePicture).composite(textArray).withMetadata().toBuffer();

const canvas = createCanvas(100, 100);
const context = canvas.getContext('2d');
const width = canvas.width / 2;
const height = canvas.height / 2;
const borderWidth = 3;
context.lineWidth = borderWidth;
context.strokeStyle = SEAL_COLOR;
context.beginPath();
context.arc(width, height, width - borderWidth, 0, Math.PI * 2);
context.shadowColor = SEAL_COLOR;
context.shadowBlur = 1.3;
context.stroke();
context.rotate(0);
context.globalCompositeOperation = 'destination-out';
const canvasBuffer=canvas.toBuffer()

const  imageArray = [
    {
      input:textBuffer,
      top: 200,
      left: 72,
    },
   {
      input:canvasBuffer,
      top: 300,
      left: 72,
    },
  ],

sharp(basePicture).composite(imageArray).withMetadata().toBuffer()

Please provide sample image(s) that help explain this problem

verion 0.32.3 0.32.2 0.32.1 0.32.0 have this problem
If I only overlay text on the basemap, there is no problem.

const  imageArray = [
    {
      input:textBuffer,
      top: 200,
      left: 72,
    },
  ],

If I only overlay canvas on the basemap, there is no problem.

const  imageArray = [
   {
      input:canvasBuffer,
      top: 300,
      left: 72,
    },
  ],

If I overlay both text and canvas on the basemap, it shows error below.

const  imageArray = [
    {
      input:textBuffer,
      top: 200,
      left: 72,
    },
   {
      input:canvasBuffer,
      top: 300,
      left: 72,
    },
  ],

Looks like text overlay and image overlay repeated register PangoFontMap

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.016: **cannot register existing type 'PangoFontMap'**

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.017: cannot add private field to invalid (non-instant

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.017: cannot register existing type 'GListModel'

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.017: g_type_interface_add_prerequisite: assertion 'G_

(process:19072): GLib-CRITICAL **: 14:41:14.017: g_once_init_leave: assertion 'result != 0' failed

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.018: g_type_add_interface_static: assertion 'G_TYPE_I

(process:19072): GLib-CRITICAL **: 14:41:14.018: g_once_init_leave: assertion 'result != 0' failed

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.018: g_type_register_static: assertion 'parent_type >

(process:19072): GLib-CRITICAL **: 14:41:14.018: g_once_init_leave: assertion 'result != 0' failed

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.019: g_type_register_static: assertion 'parent_type >

(process:19072): GLib-GObject-CRITICAL **: 14:41:14.019: cannot register existing type 'PangoCairoFontMap
@lovell lovell added question and removed triage labels Jul 21, 2023
@lovell
Copy link
Owner

lovell commented Jul 21, 2023

This has come up before, please see #2531

I'm unsure there's any solution for Windows users based on the way canvas currently provides prebuilt DLLs. It's possible Automattic/node-canvas#813 might help solve this.

@lovell
Copy link
Owner

lovell commented Sep 26, 2023

See my comment on a similar issue - #3766 (comment) - not a lot we can do here, good luck.

@lovell lovell closed this as completed Sep 26, 2023
@mrchoke
Copy link

mrchoke commented Mar 1, 2024

I have come across a recurring issue on a Docker container using Debian image.
Screenshot 2024-03-01 at 11 32 47

@lovell
Copy link
Owner

lovell commented Mar 1, 2024

@mrchoke If you're still having problems, please open a new question and provide a complete, minimal (i.e. as few other dependencies as possible) code sample and list of dependencies (must all be the latest available) that allows someone else to reproduce, ideally as a standalone repo.

Repository owner locked and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants