Opened 5 months ago

Closed 4 months ago

Last modified 3 months ago

#69045 closed defect (fixed)

php83-gd: imagefontwidth and imagefontheight fail on valid GDFont

Reported by: jonaskohl (Jonas Kohl) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: Cc: jonaskohl (Jonas Kohl)
Port: php83-gd

Description

When using imagefontwidth($font); with a font loaded using imageloadfont(...), the call fails with the following exception:

Uncaught TypeError: imagefontwidth(): Argument #1 ($font) must be of type GdFont|int, GdFont given

This is not reproducible on non macOS systems, so it seems to be a problem with this port.

I have attached a simple MVP that reproduces this problem (at least on my Mac). Just run sample.php via php-cli.

Attachments (1)

ImageFontWith_Sample.zip (10.9 KB) - added by jonaskohl (Jonas Kohl) 5 months ago.
Archive of MVP

Download all attachments as: .zip

Change History (11)

Changed 5 months ago by jonaskohl (Jonas Kohl)

Attachment: ImageFontWith_Sample.zip added

Archive of MVP

comment:1 Changed 5 months ago by jonaskohl (Jonas Kohl)

Cc: jonaskohl added

comment:2 Changed 5 months ago by jmroot (Joshua Root)

Owner: set to ryandesign
Status: newassigned
Summary: imagefontwidth and imagefontheight fail on valid GDFontphp83-gd: imagefontwidth and imagefontheight fail on valid GDFont

comment:3 in reply to:  description Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to jonaskohl:

Just run sample.php via php-cli.

I get:

% php83 sample.php
9
15
12
20
% port installed php83{,-gd}
The following ports are currently installed:
  php83 @8.3.1_0+libedit (active)
  php83-gd @8.3.1_0 (active)
%

comment:4 Changed 5 months ago by jonaskohl (Jonas Kohl)

I get the following output:

% php83 sample.php
9
15
PHP Fatal error:  Uncaught TypeError: imagefontwidth(): Argument #1 ($font) must be of type GdFont|int, GdFont given in /Users/jonas/Desktop/sample.php:12
Stack trace:
#0 /Users/jonas/Desktop/sample.php(12): imagefontwidth(Object(GdFont))
#1 {main}
  thrown in /Users/jonas/Desktop/sample.php on line 12

Fatal error: Uncaught TypeError: imagefontwidth(): Argument #1 ($font) must be of type GdFont|int, GdFont given in /Users/jonas/Desktop/sample.php:12
Stack trace:
#0 /Users/jonas/Desktop/sample.php(12): imagefontwidth(Object(GdFont))
#1 {main}
  thrown in /Users/jonas/Desktop/sample.php on line 12

% port installed php83{,-gd}
The following ports are currently installed:
  php83 @8.3.1_0+libedit (active)
  php83-gd @8.3.1_0 (active)

comment:5 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

I can't explain it. The error message seems to be saying that you must supply imagefontwidth with either a GdFont or an int and that you have supplied a GdFont so I don't know what the problem is.

What we do at MacPorts is make other people's software easy to install on a Mac, but we are not experts in that software or how to fix its code if it doesn't work correctly, so I think you should report it to the developers of PHP.

comment:6 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

One thing you could try is check if you have any other active php83 modules:

port installed active and name:^php83-

If so, try deactivating them and see if the problem disappears. If it does, isolate which of the other modules is causing the problem.

comment:7 Changed 5 months ago by jonaskohl (Jonas Kohl)

I've now deactivated every php83 module except GD (and the core PHP port itself of course), but the problem still occurs. I will now report this bug over at php-src. But as I said, I could not reproduce this on non-mac systems. For example, it worked just fine inside an Ubuntu Docker container.

comment:8 in reply to:  7 Changed 4 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to jonaskohl:

I will now report this bug over at php-src.

Thanks, I see you reported it here: https://github.com/php/php-src/issues/13082

comment:9 Changed 4 months ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

In 12a20924e81fa09d7cd2c32ece0f856f6ee8454c/macports-ports (master):

php-gd: Fix imagefontwidth/imagefontheight problem

Closes: #69045

comment:10 Changed 3 months ago by ryandesign (Ryan Carsten Schmidt)

In 000f105e5d5761fb540eef8b44d727819890dae6/macports-ports (master):

php81-gd: Fix the imagefontwidth/imagefontheight fix

See: #69045

Note: See TracTickets for help on using tickets.