Files
odfstudio/external/fontconfig/StaticLibrary_fontconfig.mk
Tor Lillqvist 80f8fe8479 Make also fonts installed from the Microsoft Store show up in CODA-W
This was much more complicated than expected. Most of that thanks to
the inscrutability of fontconfig.

Fonts from the Microsoft Store get installed in a separate folder per
product, under the WindowsApps folder. Each such font product folder
contains one or several TrueType font files, and metadata files, and
preview images, etc.

Add a C++ source file to fontconfig that uses DirectWrite to enumerate
the available fonts. Take only those with a source type of
DWRITE_FONT_SOURCE_TYPE_APPX_PACKAGE into account. Other fonts are
found as before, looking in the system fonts folder (typically
C:\Windows\Fonts) and in the per-user fonts folder (typically
C:\Users\username\AppData\Local\Microsoft\Windows\Fonts).

This C++ code requires headers from the winrt tree in the Windows SDK,
so add that to SOLARINC.

Sadly, thanks to the way fontconfig works (scanning directories for
font files), I need to let it scan the folders of font products from
the Microsoft Store to find the font files, even if the DirectWrite
API would already give us the font file names directly. But I didn't
want to modify fontconfig too much, so oh well.

There was something weird in how fontconfig calculates the hash for
directory names to be used in its cache files. It ended up creating
more and more cache files for the same directories each time CODA-W
was run. I could not understand what was going on, but in any case,
just making sure that FcConfigMapFontPath() and FcConfigMapSalt()
don't do anything on Windows seems to help.

Also change the way freetype is built so that only the special
FT_Done_MM_Var is exported, not all public functions. This was
necessary because for some unknown reason, when linking the vcl DLL I
started getting errors for the freetype symbols that happen to be
linked into also the cairo DLL. If we eventually can switch to
building all of core statically for CODA-W this problem will go away.

Also stop defining FT_DEBUG_LOGGING, such logging will not show up
anywhere for end-users, and fixing problems in freetype on Windows
will have to be done by reproducing and debugging in the VS debugger
anyway.

There is still much to do to make fontconfig (and probably freetype
and cairo) work really correctly on Windows. The most obvious thing is
that the file name handling is broken. This is perhaps understandable
as the port of that code to Windows is from over 20 years ago, I
think.

It works for file and folder names in ASCII, but most likely not for
others. At least the user profile directory, under which per-user font
files are stored, will definitely have non-ASCII in many cases. We
should modify the code to use <tools/UnixWrappers.h>, so that all file
system access is done using proper wide character (UTF-16)
APIs. Pathnames that these libraries handle will then be in UTF-8. The
opendir() etc emulation in fontconfig should also be replaced by
adding such to UnixWrappers.h instead.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I4bc6e32dcc32ff74b79679edacee1aecebd774c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196336
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Tor Lillqvist <tml@iki.fi>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197507
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@iki.fi>
2026-01-17 21:49:57 +01:00

76 lines
1.7 KiB
Makefile

# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This is de facto just for Windows for now
$(eval $(call gb_StaticLibrary_StaticLibrary,fontconfig))
$(eval $(call gb_StaticLibrary_use_unpacked,fontconfig,fontconfig))
$(eval $(call gb_StaticLibrary_set_include,fontconfig,\
-I$(gb_UnpackedTarball_workdir)/fontconfig \
-I$(gb_UnpackedTarball_workdir)/fontconfig/fc-lang \
-I$(gb_UnpackedTarball_workdir)/freetype/include \
-I$(gb_UnpackedTarball_workdir)/expat/lib \
$$(INCLUDE) \
))
# Ignore warnings, warnings in this code is not our problem, or is it?
$(eval $(call gb_StaticLibrary_set_warnings_disabled,fontconfig))
$(eval $(call gb_StaticLibrary_add_defs,fontconfig,\
-DHAVE_CONFIG_H \
-DFC_CACHEDIR='"C:/Windows/Temp"' \
-DCONFIGDIR='"Whatever"' \
-DFONTCONFIG_PATH='"Whatever"' \
-DFC_TEMPLATEDIR='"Whatever"' \
))
$(eval $(call gb_StaticLibrary_add_generated_cobjects,fontconfig,\
$(addprefix UnpackedTarball/fontconfig/src/, \
fcatomic \
fccache \
fccfg \
fccharset \
fccompat \
fcdbg \
fcdefault \
fcdir \
fcformat \
fcfreetype \
fcfs \
fcptrlist \
fchash \
fcinit \
fclang \
fclist \
fcmatch \
fcmatrix \
fcname \
fcobjs \
fcpat \
fcrange \
fcserialize \
fcstat \
fcstr \
fcweight \
fcxml \
ftglue \
) \
))
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,fontconfig,\
$(addprefix UnpackedTarball/fontconfig/src/, \
fcdwrite \
) \
))
# vim: set noet sw=4 ts=4: