php / php/php-src

Implement font lookup in ext/gd

Ouverte
#17,852 4 commentaires 3 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Extension: gd Feature Status: Needs Triage
Langage dominant
C
Étoiles
40.4k
Forks
8.2k
Merge moyen
2 j 13 h
PR mergées (30 j)
96

Description

Description

As is, libgd supports a somewhat complex font lookup for gdImageStringFT() (and friends). You can actually pass a semicolon delimeted list of fonts, and each font can be an absolute or relative path to a font file, or a suffix to any of the default font paths, which are hard-coded for different platforms, but which also can be overridden via the environment variable GDFONTPATH. As is, we pass the $font_file argument of imagettftext() and friends directly to gdImageStringFT(), so libgd does all the heavy work to actually find the desired font.

However, this does not (necessarily) work for ZTS builds when relative paths are given, since external libgd is not aware of the VCWD (while bundled libgd is) (see #17366). In addition, changing a global enviroment variable doesn't fit well to our ZTS model (see https://github.com/php/php-src/pull/16565#issuecomment-2665494265). And there are also some minor issues with the libgd implementation (e.g. https://github.com/libgd/libgd/issues/952).

In my opinion, the font lookup in libgd should have better been split from the actual drawing functions, what would have allowed us to implement our own font lookup in the first place, properly catering to VCWD and what not (e.g. fontconfig support, which is implemented in libgd, but not supported from ext/gd). Now this is moot, but I still suggest to implement our own font lookup in ext/gd (basically re-implementing what libgd does), and then to pass only a single absolute font path to gdImageStringFT(). This would allow to compensate the current incompatibilites between external and bundled font lookup (partially paving the way to unbundle libgd), and would also allow us to make further improvements (especially fontconfig comes to mind), with having to deal with the somewhat messy way that is implemented in external libgd (see gdImageStringFTEx()) (bundled libgd doesn't even support that).

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par les points d’entrée liés aux polices dans ext/gd, en particulier imagettftext() et les fonctions associées, et comparez leur transmission actuelle à gdImageStringFT() avec le comportement de recherche de gdImageStringFTEx() dans libgd. Le travail est considéré comme terminé lorsque la recherche de police est implémentée dans ext/gd, gère les cas de chemins et d’environnement indiqués en tenant compte de VCWD, et transmet un seul chemin absolu de police à gdImageStringFT().

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
c, php
Domaine
computer-graphics
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.