Is there a way I could find where fonts are stored on either Windows, OSX, or Linux? If not, is there a way I can guarantee certain paths (such as X:/Windows/Fonts/) for all
That's assuming the target OS has a font folder. For example, it's quite feasible for a Linux installation to be console-only and not have a font directory at all.
Anyways, my best guess is that there is no platform independent way. You can write your own platform independent function, but within it will have to check the current OS (via some IFDEF's, I cannot say what) and then call the right function. But again - I wouldn't be so sure you can obtain it under Linux at all.
This is going to be one of those 'simple' problems could have an over-the-top solution depending on what you need this information for.
I will have to apologize for the vaguer Linux answers, as font management across Linux distributions are not consistent and can be very configurable, can be influenced by desktop environment, can be remotely served, etc.
Checking for environment
You can check various platforms via the use of macros defined for specific environments.
#if defined(_WIN32)
_WIN32
is defined for both 32-bit and 64-bit Windows.#if defined(_APPLE_) && defined(_MACH_)
_APPLE_
is defined for all Apple computers, and _MACH_
is defined if the system supports Mach system calls, a la Mac OSX#if defined(linux) || defined(__linux)
Font directory locations
%WINDIR%\fonts
. /System/Library/Fonts
- Fonts necessary for the system. Do not touch these./Library/Fonts
- Additional fonts that can be used by all users. This is generally where fonts go if they are to be used by other applications.~/Library/Fonts
- Fonts specific to each user./Network/Library/Fonts
- Fonts shared for users on a network./usr/share/fonts
, /usr/local/share/fonts
, and user-specific ~/.fonts
/etc/fonts/fonts.conf
or /etc/fonts/local.conf
.Resources: