Opened 10 years ago
Closed 11 months ago
#44148 closed enhancement (wontfix)
using Bohoomil's Infinality-Ultimate patches
Reported by: | RJVB (René Bertin) | Owned by: | ryandesign (Ryan Carsten Schmidt) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | haspatch | Cc: | |
Port: | freetype fontconfig cairo |
Description
As already discussed on MacPorts-Users and XQuartz-dev, I have spent some time trying to use Bohoomil's ultimate version of the Infinality patches for freetype and fontconfig. These are aimed at optimal font rendering, through patches to the freetype code (i.e. the remaining ones which have not yet been incorporated into freetype in recent years) and a mechanism to tweak the rendering on a per-font basis via XML files (a library of which is included). There are also a few patches to cairo. Quoting bohoomil:
There's actually at least one important cairo patch, cairo-respect-fontconfig.patch that's sole purpose is to make applications supporting cairo use fontconfig settings properly. Stock cairo doesn't do this: that's why Gtk+ applications and Firefox don't honor global fontconfig settings.
Other than that, I add a few Ubuntu patches from which most handy might be
pdf-output-avoid-transparency.patch pdf-output-mime-data-embedding.patch server_side_gradients.patch
We've been using them all for ~2 years now successfully, no problems have been reported.
The project's repository is here, bohoomil's site has examples and (lots of) discussion.
I've managed to modify the freetype, fontconfig and cairo Portfiles to add +infinality variants that do the patching and other stuff required, from patchfiles and additional source in the port files directories. I haven't (yet) been able to figure out how to download things (or clone from git) in a variant, and the patchfiles are not directly compatible with MacPorts' patching mechanism, so for now the extra files are to be kept in the local repository. A solution should also be found for the single user-configuration file, infinality-settings.sh (or infinality-settings.csh for [t]csh users).
From what I can tell, the port variants install cleanly (also using clang-3.4) after installing the attached port files in the local repository. The only caveat I have concerns the screen density: on my system I have had to set the X11 density to 75dpi instead of the default 96dpi in order for X11 fonts to render at the same effective size as under OS X (echo Xft.dpi: 75 | xrdb -merge
and a line Xft.dpi: 75
in ~/.Xresources because KDE will use that information (sic!!)).
Note that freetype is used in non-X11 applications too, so it's not impossible that the improved rendering quality will extend to those applications too.
I'd be interested in feedback about the gains in perceived rendering quality - or lack thereof.
Attachments (18)
Change History (35)
Changed 10 years ago by RJVB (René Bertin)
Attachment: | freetype-infinality.zip added |
---|
Changed 10 years ago by RJVB (René Bertin)
Attachment: | fontconfig-ultimate.zip added |
---|
fontconfig with a variant for bohoomil's "infinality-ultimate" patches
Changed 10 years ago by RJVB (René Bertin)
Attachment: | cairo-infinality.zip added |
---|
cairo with a variant that heeds the infinality freetype & fontconfig variants
comment:1 Changed 10 years ago by mf2k (Frank Schima)
Keywords: | haspatch added; font rendering quality removed |
---|---|
Port: | freetype, fontconfig, cairo → freetype fontconfig cairo |
Version: | 2.3.0 |
comment:2 Changed 10 years ago by mf2k (Frank Schima)
Owner: | changed from macports-tickets@… to ryandesign@… |
---|
In the future, please Cc the port maintainers (port info --maintainers freetype fontconfig cairo
).
comment:3 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)
Can you attach diffs, instead of zip files? I would want to see the diffs of the Portfiles, plus any new or changed patchfiles that are needed. You seem to have included the infinality patches in your archives; I thought we had discussed that they were going to be downloaded from the upstream web site where they're provided.
You appear to have added tab characters to some portfiles. Spaces should be used instead. See the modeline.
If you're going to modify cairo, you should make the same modifications to cairo-devel.
What is the relationship between the variants in the three ports? Must all three be used together? If so, the active_variants 1.1 portgroup may need to be used to ensure that dependencies have the variant selected.
comment:4 Changed 10 years ago by RJVB (René Bertin)
Honestly, I'd like to see some feedback on the perceived interest of it all before I start to spend more time making lots of diffs. Also, Jeremy indicated he's not against including the patches in XQuartz (which would just leave a cairo variant I guess), so the files I uploaded are in a way intended to give a means for easy evaluation of that perceived interest, at least for now.
I've explained why I included the infinality patches: I couldn't figure out in a reasonable time how to grab them from the server (i.e. from 2 different branches of a github archive) when the variant is selected AND they'd have to be edited (unless there's a way to have them applied with -p1).
Tabs were added by vim; apparently the modeline isn't explicit enough to avoid it from doing so (and I haven't touched these vi settings for too long to see what's missing or even remember how to set vim to using spaces :-/ ). Aesthetic, minor issue that will be corrected if ever these make it to a proposal-to-add.
cairo-devel: what's that? The port info is identical as is the version.
The actual font rendering improvements are in freetype+infinality. Fontconfig+infinality hooks into that to provide global and per-font rendering configuration options whereas the cairo patch just makes cairo respect those settings. Using either of the last 2 without freetype+infinality probably doesn't make any sense, but I don't think there are hard dependencies.
Changed 10 years ago by RJVB (René Bertin)
Attachment: | JumpFox-Gedit.png added |
---|
collage of 6 font samples made in MacPort's gedit
Changed 10 years ago by RJVB (René Bertin)
Attachment: | JumpFox-KDE.png added |
---|
same 6 font samples made in CalligraWords built against MacPort's KDE
Changed 10 years ago by RJVB (René Bertin)
Attachment: | JumpFox-TextEdit.png added |
---|
ditto, made with TextEdit.app (OS X 10.6.8)
comment:5 Changed 10 years ago by RJVB (René Bertin)
I've attached a couple of samples : Oxygen-Sans 11pt, Novarese Bk Bt 11pt and Segoe UI 11pt, all in their regular/normal weight and in bold (semi-bold for Segoe UI). I actually prefer the rendering under X11 with these patches even though at this size things look just a tad fuzzy. Rendering size is not really identical though (despite setting Xft.dpi to 72 instead of the default 96 dpi), which may explain my preference. NB: I observe the same difference in rendering size without the Infinality patches, so they're not to blame for that.
Tweaking the fontconfig+infinality settings has effect on rendering in gedit but not in KDE nor in Qt4-Mac, so it seems they either don't use freetype at all for font rendering, or ignore the fontfonfig settings just as stock cairo does.
comment:6 Changed 10 years ago by RJVB (René Bertin)
As requested, I've just uploaded a diff for the cairo-devel portfile, adding an infinality variant. Cairo and cairo-devel are otherwise identical ports, so the Infinality patchfiles are shared among them.
comment:7 Changed 10 years ago by RJVB (René Bertin)
Sync with upstream changes, including "official" patches to Freetype 2.5.3 . Again, these patches come from a Linux packaging repository and thus require adaptation to MacPorts procedure, which makes it unfeasible to download them directly from GitHub instead of including them here.
Changes to the fontconfig patches are purely cosmetic (hence I didn't change the Portfile revision) but included to simplify syncing with future changes.
comment:8 Changed 10 years ago by RJVB (René Bertin)
Sync with upstream 2014.08.08 changes, including "official" patches to Freetype 2.5.3 .
Changed 10 years ago by RJVB (René Bertin)
Attachment: | cairo-devel+infinality.diff added |
---|
diff for the cairo-devel portfile
comment:9 Changed 10 years ago by RJVB (René Bertin)
New upstream patches, and a new build helper script for fontconfig+infinality, which collects the various font config/settings files from git.
I'm using a release number that represents the upstream commit date; if ever these variants are accepted that can of course change.
comment:10 Changed 10 years ago by RJVB (René Bertin)
Below are some packaging instructions bohoomil sent me recently. I've updated the Portfile and patches as well as fontconfig's post-destroot install script accordingly.
Here is the list of steps you may want to perform manually to make use of fontconfig-iu: in the future, they won't be necessary since everything will be done automatically during compilation. I am going to use Ubuntu directory layout in which * /etc/fonts/conf.avail -- is where stock fontconfig templates are installed * /etc/fonts/conf.d -- is the location of active fontconfig configuration files. The process of building Ubuntu fontconfig may actually differ: since you're using ppa, reproduce the steps following ppa's package building logic. 1. Download fontconfig source packages from here: http://packages.ubuntu.com/utopic/fontconfig (You should use fontconfig v.2.11.1, the default one for Utopic Unicorn.) 2. Download the latest fontconfig-ultimate archive you can download from here: https://github.com/bohoomil/fontconfig-ultimate/releases 3. Copy the entire conf.d.infinality from the fontconfig-ultimate archive to the stock fontconfig root directory: $ ls fontconfig-2.11.1/ conf.d conf.d.infinality doc fc-cache ... 4. Replace the patches in debian/patches with patches [01-05]-foo.patch and fc-cache.c.patch from fontconfig_patches and update the series file accordingly. You should also update the build script(s) so that the new ones are properly applied during compilation. The new patches will modify the stock fontconfig library in the following way: a. A new template directory, /etc/fonts/conf.avail.infinality, will be created. This is where fontconfig Infinality templates will be located and these will be used instead of stock ones from /etc/fonts/conf.avail. You can change or confirm the default location by specifying it during source code configuration, i.e. --with-templateinfdir=/etc/fonts/conf.avail.infinality b. /etc/fonts/conf.avail won't be removed: this directory is still needed for compatibility with the rest of Ubuntu applications, font packages and new fonts settings foo.conf files you'll get from fonts-settings directory. Once this is done, the C compiler can do its part of the job. Next few steps are basically instructions for Ubuntu package manager, so I guess the files you're going to modify now are respective pre/post{inst,rm} scripts. What you should do then: 5. Copy combi, free and ms directories with their content from fontconfig_patches to /etc/fonts/conf.avail.infinality. These three are crucial for fontconfig-infinality to work correctly! 6. Copy *conf files from fonts-settings to /etc/fonts/conf.avail (i.e. the stock template directory). 7. Copy fc-presets from fontconfig_patches to /usr/bin. And that's it. In the future, the only necessary steps will be 1) patching (which will create new files automatically) and 2) defining default Infinality template directory with --with-templateinfdir= variable. So actually just a bit more effort than building the stock fontconfig. Now a few notes on how to use the newly built fontconfig-infinality{-ultimate}. 1. Default presets and default font collection. Default font collection is the one you use to define default aliases: sans-serif, serif, monospace, etc. for Latin and non-Latin scripts. There are three predefined options available for the user by default: a. free -- only free fonts will be used, as stated in 60-latin-free.conf and 65-non-latin-free.conf. The preset is the default one for the infinality-bundle and Arch Linux users, and all fonts can be installed from binary packages available in my infinality-bundle-fonts repository. The main difference between my font packages and stock ones is the presence of fontconfig configuration files in the former which were tailored for the ultimate settings set in infinality-settings{.sh} file. Besides, when necessary I fix buggy font files, so although the content of stock and my font packages may be identical, a few font files may actually differ. Further, I pack each font family to reside in its own subdirectory in /usr/share/fonts, which makes it easier to maintain them and optically determine which one you have or haven't got. The preset offers replacement options for non-free families: all of them are defined in 30-metric-aliases-free.conf and 37-repl-global-free.conf. b. ms -- only default Microsoft font families will be used, as stated in 60-latin-ms.conf and 65-non-latin-ms.conf. This presets assumes you're using Microsoft Window 8+ fonts and they are installed. The preset mostly doesn't replace existing font families: the only substitutions occur for corrective or compatibility reasons (see 37-repl-global-ms.conf for details). c. combi -- this is a DIY presets for users who want to heavily customize their font collection. It's basically meant to be used when you're either using a pretty non-standard font families, you're going to mix different font collections (for instance, you want to use all ms and free fonts as is, without replacing non-free families with the free ones: this is quite a popular user case with Arch users and the pre-defined combi templates for this you can find in doc/fontconfig-infinality-ultimate/fontconfig-global/combi-minimal; replace the content of /etc/fonts/conf.avail.infinality/combi with them and set the combi preset to activate it), etc. Note that these three presets have nothing to do with rendering styles known from the original fontconfig-infinality: their sole purpose is font families management, not making your fonts look like Window, Mac, Ubuntu or the like. For two presets, free and ms, there is a an additional useful config file available in /etc/fonts/conf.avail.infinality: it's 35-repl-custom.conf. For example, if you are using the free font collection, but instead of Noto Sans you want to set Liberation Sans for your default sans-serif alias, you do so by copying the content of 60-latin-free.conf to 35-repl-custom.conf and re-arranging the names of the families accordingly. Another example: let's say you want to use the entire Microsoft font collection but instead of Arial, you'd rather set Nimbus Sans L as a replacement for Helvetica. Again, 35-repl-custom.conf is where you place the necessary replacement rule. 2. fc-presets: this is a little application which lets you set your default fontconfig-infinality preset (i.e. combi, free, ms). Run 'fc-presets help' to learn how to use it. Once again: I'm very sorry for all the documentation part for taking so much time to be completed. It's not my laziness, but a combination of technical and personal, health related problems. I hope that the above will help you understand the way fontconfig-iu operates which once completed properly, will involve roughly two steps: 1. applying the patches that will take care of all the configuration nuances & rebuilding the library. 2. running 'fc-presets help' to set correct fontconfig configuration files. Right now, unfortunately, a bit more manual work is still needed.
Changed 10 years ago by RJVB (René Bertin)
Attachment: | freetype+infinality.diff added |
---|
freetype Portfile diff
Changed 10 years ago by RJVB (René Bertin)
Attachment: | freetype+infinality-20141223.diff added |
---|
Changed 10 years ago by RJVB (René Bertin)
comment:11 Changed 10 years ago by RJVB (René Bertin)
Update to the Infinality patches from December 23rd, 2014.
I've tried not to hijack the Revision variable in the new Portfile to store the Infinality version. Instead, I'm trying a different approach that adds the Inf. version to the Freetype version:
name freetype set ftversion 2.5.4 revision 2 if {[variant_isset infinality]} { version ${ftversion}.20141223 worksrcdir ${name}-${ftversion} distname ${name}-${ftversion} } else { version ${ftversion} }
This gives expected behaviour:
> port info freetype +infinality freetype @2.5.4.20141223_2 (print, graphics) Variants: +infinality, universal
but I have seen some inexplicable behaviour where port would try to grab a file (archivefetch) with the Infinality version in its name after doing a completely normal port patch freetype +infinality
. It would also do the full run, i.e. port configure
behaved like port install
, and then complained about not being able to upgrade harfbuzz because it didn't have the permissions to install.
I can no longer reproduce this when the new version is installed but after rolling back to the previous version:
> port patch freetype +infinality+universal # completes fine > port -v -k configure freetype +infinality+universal Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'. ---> Computing dependencies for freetype. ---> Fetching archive for freetype ---> freetype-2.5.4.20141223_2+infinality+universal.darwin_13.i386-x86_64.tbz2 doesn't seem to exist in /opt/local/var/macports/incoming/verified ---> Attempting to fetch freetype-2.5.4.20141223_2+infinality+universal.darwin_13.i386-x86_64.tbz2 from http://lil.fr.packages.macports.org/freetype % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 ---> Attempting to fetch freetype-2.5.4.20141223_2+infinality+universal.darwin_13.i386-x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/freetype % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 323 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 ---> Attempting to fetch freetype-2.5.4.20141223_2+infinality+universal.darwin_13.i386-x86_64.tbz2 from http://packages.macports.org/freetype % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 ---> Configuring freetype ---> Configuring freetype for architecture x86_64 FreeType build system -- automatic system detection ... configure: creating ./config.status config.status: creating unix-cc.mk config.status: creating unix-def.mk config.status: creating ftconfig.h config.status: executing libtool commands configure: Library configuration: external zlib: yes (pkg-config) bzip2: yes (autoconf test) libpng: yes (pkg-config) harfbuzz: yes (pkg-config) make: Nothing to be done for 'unix'. ---> Building freetype ---> Building freetype for architecture x86_64 ... ---> Staging freetype into destroot . changed user expected 0 found 505 not modified: Operation not permitted gid expected 0 found 505 not modified: Operation not permitted permissions expected 0775 found 0755 modified ./usr missing (created) ./usr: user & group not modified: Operation not permitted ... ---> Compressing man pages for freetype man1/freetype-config.1: 56.9% -- replaced with man1/freetype-config.1.gz man1/freetype-config.1.gz: changing permissions from 00644 to 00444 ---> Installing freetype @2.5.4.20141223_2+infinality+universal sh: /Volumes/Debian/MP9/var/macports/software/freetype/freetype-2.5.4.20141223_2+infinality+universal.darwin_13.i386-x86_64.tbz2: Permission denied a . a ./+COMMENT a ./+CONTENTStar: Write error Command failed: cd "/Volumes/Debian/MP9/var/macports/build/_Volumes_Debian_MP9_site-ports_print_freetype/freetype/work/destroot" && /usr/bin/tar -cvf - . | /usr/bin/bzip2 -c9 > /Volumes/Debian/MP9/var/macports/software/freetype/freetype-2.5.4.20141223_2+infinality+universal.darwin_13.i386-x86_64.tbz2 Exit code: 1 Error: org.macports.install for port freetype returned: command execution failed Warning: targets not executed for freetype: org.macports.install Please see the log file for port freetype for details: /opt/local/var/macports/logs/_Volumes_Debian_MP9_site-ports_print_freetype/freetype/main.log Error: Unable to upgrade port: 1 Error: Unable to execute port: upgrade harfbuzz failed
I'll attach the log file.
comment:12 Changed 10 years ago by RJVB (René Bertin)
This brings freetype up to date w.r.t. the current port:freetype (2.5.4) and updates the Infinality patches to the 2014.12.23 version.
This installment also introduces a new approach. There is now a subport, freetype-infinality
which carries the Infinality version, and installs the settings ([ba]sh, csh) files in ${prefix}/share/fonts/fontconfig-ultimate . The patches are expected in ${filespath}, as before, and applied by selection the +infinality variant. That variant is added to the default_variants if the a settings file is detected in ${prefix}/share/fonts/fontconfig-ultimate .
Changed 10 years ago by RJVB (René Bertin)
Attachment: | fontconfig+infinality-patches.zip added |
---|
comment:13 Changed 10 years ago by RJVB (René Bertin)
fontconfig is brought up to date with Bohoomil's ultimate patches version 2015.01.01 . As with port:freetype, there is now a subport,
fontconfig-ultimate
which installs the customised fontconfig files into ${prefix}/share/fonts/fontconfig-ultimate/${version} (2015.01.01). The actual patches are still applied through the fontconfig +infinality variant, which also installs the appropriate symlinks to ${prefix}/share/fonts/fontconfig-ultimate/${version} into ${prefix}/etc/fonts .
Changed 10 years ago by RJVB (René Bertin)
Attachment: | fontconfig+infinality.diff added |
---|
fontconfig portfile diff
Changed 10 years ago by RJVB (René Bertin)
Attachment: | cairo+infinality.diff added |
---|
cairo portfile diff
Changed 10 years ago by RJVB (René Bertin)
Attachment: | cairo+infinality-patches.zip added |
---|
comment:14 Changed 10 years ago by RJVB (René Bertin)
Cairo is brought up to date w.r.t. the current port:cairo (1.14.0), and includes the 2015.01.01 Infinality patches.
There are no sensible infinality/ultimate files to install (other than a changelog), so for this port I opted append the infinality version to ${version} when the +infinality variant is selected. Thus, cairo@1.14.0_0
becomes cairo@1.14.0.20150101_0+infinality
. This appears to pose no problems with port outdated
or port livecheck
.
Changed 10 years ago by RJVB (René Bertin)
Attachment: | freetype+infinality-20150123.diff added |
---|
comment:15 Changed 10 years ago by RJVB (René Bertin)
Todays addition restores rendering control to freetype+infinality in applications leveraging pango, by setting PANGOCAIRO_BACKEND="fontconfig"
.
I've also added a little script that copies all defined Infinality environment variables to the launchctl environment (i.e. they become visible to applications started through LaunchServices, like the Finder or the Dock).
Changed 10 years ago by RJVB (René Bertin)
Attachment: | freetype+infinality-20150131.diff added |
---|
Changed 10 years ago by RJVB (René Bertin)
Attachment: | freetype+infinality-patches.zip added |
---|
comment:16 Changed 10 years ago by RJVB (René Bertin)
Bohoomil released version 2015.01.31, which updates the Freetype patches. Since port:freetype standard has been updated to v2.5.5, the +infinality variant can now also be completely up to date.
comment:17 Changed 11 months ago by ryandesign (Ryan Carsten Schmidt)
Resolution: | → wontfix |
---|---|
Status: | new → closed |
freetype with a variant for bohoomil's infinality patches