fcconfig.fncs revision 2c393a42
12c393a42Smrg/*
22c393a42Smrg * $Id: fcconfig.fncs,v 1.1.1.1 2008/07/30 01:24:15 mrg Exp $
32c393a42Smrg *
42c393a42Smrg * Copyright © 2003 Keith Packard
52c393a42Smrg *
62c393a42Smrg * Permission to use, copy, modify, distribute, and sell this software and its
72c393a42Smrg * documentation for any purpose is hereby granted without fee, provided that
82c393a42Smrg * the above copyright notice appear in all copies and that both that
92c393a42Smrg * copyright notice and this permission notice appear in supporting
102c393a42Smrg * documentation, and that the name of Keith Packard not be used in
112c393a42Smrg * advertising or publicity pertaining to distribution of the software without
122c393a42Smrg * specific, written prior permission.  Keith Packard makes no
132c393a42Smrg * representations about the suitability of this software for any purpose.  It
142c393a42Smrg * is provided "as is" without express or implied warranty.
152c393a42Smrg *
162c393a42Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
172c393a42Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
182c393a42Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
192c393a42Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
202c393a42Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
212c393a42Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
222c393a42Smrg * PERFORMANCE OF THIS SOFTWARE.
232c393a42Smrg */
242c393a42Smrg@RET@           FcConfig *
252c393a42Smrg@FUNC@          FcConfigCreate
262c393a42Smrg@TYPE1@		void
272c393a42Smrg@PURPOSE@	Create a configuration
282c393a42Smrg@DESC@
292c393a42SmrgCreates an empty configuration.
302c393a42Smrg@@
312c393a42Smrg
322c393a42Smrg@RET@           void
332c393a42Smrg@FUNC@          FcConfigDestroy
342c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
352c393a42Smrg@PURPOSE@	Destroy a configuration
362c393a42Smrg@DESC@
372c393a42SmrgDestroys a configuration and any data associated with it.  Note that calling
382c393a42Smrgthis function with the return from FcConfigGetCurrent will place the library
392c393a42Smrgin an indeterminate state.
402c393a42Smrg@@
412c393a42Smrg
422c393a42Smrg@RET@           FcBool
432c393a42Smrg@FUNC@          FcConfigSetCurrent
442c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
452c393a42Smrg@PURPOSE@	Set configuration as default
462c393a42Smrg@DESC@
472c393a42SmrgSets the current default configuration to <parameter>config</parameter>.  Implicitly calls
482c393a42SmrgFcConfigBuildFonts if necessary, returning FcFalse if that call fails.
492c393a42Smrg@@
502c393a42Smrg
512c393a42Smrg@RET@           FcConfig *
522c393a42Smrg@FUNC@          FcConfigGetCurrent
532c393a42Smrg@TYPE1@		void
542c393a42Smrg@PURPOSE@	Return current configuration
552c393a42Smrg@DESC@
562c393a42SmrgReturns the current default configuration.
572c393a42Smrg@@
582c393a42Smrg
592c393a42Smrg@RET@           FcBool
602c393a42Smrg@FUNC@          FcConfigUptoDate
612c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
622c393a42Smrg@PURPOSE@	Check timestamps on config files
632c393a42Smrg@DESC@
642c393a42SmrgChecks all of the files related to <parameter>config</parameter> and returns
652c393a42Smrgwhether any of them has been modified since the configuration was created.
662c393a42Smrg@@
672c393a42Smrg
682c393a42Smrg@RET@		FcBool
692c393a42Smrg@FUNC@		FcConfigHome
702c393a42Smrg@TYPE1@		void
712c393a42Smrg@PURPOSE@	return the current home directory.
722c393a42Smrg@DESC@
732c393a42SmrgReturn the current user's home directory, if it is available, and if using it
742c393a42Smrgis enabled. See also <function>FcConfigEnableHome</function>).
752c393a42Smrg@@
762c393a42Smrg
772c393a42Smrg@RET@		FcBol
782c393a42Smrg@FUNC@		FcConfigEnableHome
792c393a42Smrg@TYPE1@		FcBool%				@ARG1@		enable
802c393a42Smrg@PURPOSE@	controls use of the home directory.
812c393a42Smrg@DESC@
822c393a42SmrgIf <parameter>enable</parameter> is FcTrue, then Fontconfig will use various
832c393a42Smrgfiles which are specified relative to the user's home directory (using the ~
842c393a42Smrgnotation in the configuration). When <parameter>enable</parameter> is
852c393a42SmrgFcFalse, then all use of the home directory in these contexts will be
862c393a42Smrgdisabled. The previous setting of the value is returned.
872c393a42Smrg@@
882c393a42Smrg
892c393a42Smrg@RET@           FcBool
902c393a42Smrg@FUNC@          FcConfigBuildFonts
912c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
922c393a42Smrg@PURPOSE@	Build font database
932c393a42Smrg@DESC@
942c393a42SmrgBuilds the set of available fonts for the given configuration.  Note that
952c393a42Smrgany changes to the configuration after this call have indeterminate effects.
962c393a42SmrgReturns FcFalse if this operation runs out of memory.
972c393a42Smrg@@
982c393a42Smrg
992c393a42Smrg@RET@           FcStrList *
1002c393a42Smrg@FUNC@          FcConfigGetConfigDirs
1012c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
1022c393a42Smrg@PURPOSE@	Get config directories
1032c393a42Smrg@DESC@
1042c393a42SmrgReturns the list of font directories specified in the configuration files
1052c393a42Smrgfor <parameter>config</parameter>.  Does not include any subdirectories.
1062c393a42Smrg@@
1072c393a42Smrg
1082c393a42Smrg@RET@           FcStrList *
1092c393a42Smrg@FUNC@          FcConfigGetFontDirs
1102c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
1112c393a42Smrg@PURPOSE@	Get font directories
1122c393a42Smrg@DESC@
1132c393a42SmrgReturns the list of font directories in <parameter>config</parameter>. This includes the
1142c393a42Smrgconfigured font directories along with any directories below those in the
1152c393a42Smrgfilesystem.
1162c393a42Smrg@@
1172c393a42Smrg
1182c393a42Smrg@RET@           FcStrList *
1192c393a42Smrg@FUNC@          FcConfigGetConfigFiles
1202c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
1212c393a42Smrg@PURPOSE@	Get config files
1222c393a42Smrg@DESC@
1232c393a42SmrgReturns the list of known configuration files used to generate <parameter>config</parameter>.
1242c393a42Smrg@@
1252c393a42Smrg
1262c393a42Smrg@RET@           FcChar8 *
1272c393a42Smrg@FUNC@          FcConfigGetCache
1282c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
1292c393a42Smrg@PURPOSE@	DEPRECATED used to return per-user cache filename
1302c393a42Smrg@DESC@
1312c393a42SmrgWith fontconfig no longer using per-user cache files, this function now
1322c393a42Smrgsimply returns NULL to indicate that no per-user file exists.
1332c393a42Smrg@@
1342c393a42Smrg
1352c393a42Smrg@RET@		FcStrList *
1362c393a42Smrg@FUNC@		FcConfigGetCacheDirs
1372c393a42Smrg@TYPE1@		FcConfig *			@ARG1@		config
1382c393a42Smrg@PURPOSE@	return the list of directories searched for cache files
1392c393a42Smrg@DESC@
1402c393a42Smrg<function>FcConfigGetCacheDirs</function> returns a string list containing
1412c393a42Smrgall of the directories that fontconfig will search when attempting to load a
1422c393a42Smrgcache file for a font directory.
1432c393a42Smrg@@
1442c393a42Smrg
1452c393a42Smrg@RET@           FcFontSet *
1462c393a42Smrg@FUNC@          FcConfigGetFonts
1472c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
1482c393a42Smrg@TYPE2@		FcSetName%                      @ARG2@          set
1492c393a42Smrg@PURPOSE@	Get config font set
1502c393a42Smrg@DESC@
1512c393a42SmrgReturns one of the two sets of fonts from the configuration as specified
1522c393a42Smrgby <parameter>set</parameter>. This font set is owned by the library and must
1532c393a42Smrgnot be freed.
1542c393a42Smrg@@
1552c393a42Smrg
1562c393a42Smrg@RET@           FcBlanks *
1572c393a42Smrg@FUNC@          FcConfigGetBlanks
1582c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
1592c393a42Smrg@PURPOSE@	Get config blanks
1602c393a42Smrg@DESC@
1612c393a42SmrgReturns the FcBlanks object associated with the given configuration, if no
1622c393a42Smrgblanks were present in the configuration, this function will return 0.
1632c393a42Smrg@@
1642c393a42Smrg
1652c393a42Smrg@RET@           int
1662c393a42Smrg@FUNC@          FcConfigGetRescanInterval
1672c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
1682c393a42Smrg@PURPOSE@	Get config rescan interval
1692c393a42Smrg@DESC@
1702c393a42SmrgReturns the interval between automatic checks of the configuration (in
1712c393a42Smrgseconds) specified in <parameter>config</parameter>.  The configuration is checked during
1722c393a42Smrga call to FcFontList when this interval has passed since the last check.
1732c393a42Smrg@@
1742c393a42Smrg
1752c393a42Smrg@RET@           FcBool
1762c393a42Smrg@FUNC@          FcConfigSetRescanInterval
1772c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
1782c393a42Smrg@TYPE2@		int%                       	@ARG2@          rescanInterval
1792c393a42Smrg@PURPOSE@	Set config rescan interval
1802c393a42Smrg@DESC@
1812c393a42SmrgSets the rescan interval. Returns FcFalse if the interval cannot be set (due
1822c393a42Smrgto allocation failure). Otherwise returns FcTrue.
1832c393a42Smrg@@
1842c393a42Smrg
1852c393a42Smrg@RET@           FcBool
1862c393a42Smrg@FUNC@          FcConfigAppFontAddFile
1872c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
1882c393a42Smrg@TYPE2@		const FcChar8 *			@ARG2@          file
1892c393a42Smrg@PURPOSE@	Add font file to font database
1902c393a42Smrg@DESC@
1912c393a42SmrgAdds an application-specific font to the configuration. Returns FcFalse
1922c393a42Smrgif the fonts cannot be added (due to allocation failure). Otherwise returns FcTrue.
1932c393a42Smrg@@
1942c393a42Smrg
1952c393a42Smrg@RET@           FcBool
1962c393a42Smrg@FUNC@          FcConfigAppFontAddDir
1972c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
1982c393a42Smrg@TYPE2@		const FcChar8 *			@ARG2@          dir
1992c393a42Smrg@PURPOSE@	Add fonts from directory to font database
2002c393a42Smrg@DESC@
2012c393a42SmrgScans the specified directory for fonts, adding each one found to the
2022c393a42Smrgapplication-specific set of fonts. Returns FcFalse
2032c393a42Smrgif the fonts cannot be added (due to allocation failure). Otherwise returns FcTrue.
2042c393a42Smrg@@
2052c393a42Smrg
2062c393a42Smrg@RET@           void
2072c393a42Smrg@FUNC@          FcConfigAppFontClear
2082c393a42Smrg@TYPE1@         FcConfig *                      @ARG1@          config
2092c393a42Smrg@PURPOSE@	Remove all app fonts from font database
2102c393a42Smrg@DESC@
2112c393a42SmrgClears the set of application-specific fonts.
2122c393a42Smrg@@
2132c393a42Smrg
2142c393a42Smrg@RET@           FcBool
2152c393a42Smrg@FUNC@          FcConfigSubstituteWithPat
2162c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
2172c393a42Smrg@TYPE2@		FcPattern *			@ARG2@		p
2182c393a42Smrg@TYPE3@		FcPattern *			@ARG3@		p_pat
2192c393a42Smrg@TYPE4@		FcMatchKind%                     @ARG4@          kind
2202c393a42Smrg@PURPOSE@	Execute substitutions
2212c393a42Smrg@DESC@
2222c393a42SmrgPerforms the sequence of pattern modification operations, if <parameter>kind</parameter> is
2232c393a42SmrgFcMatchPattern, then those tagged as pattern operations are applied, else
2242c393a42Smrgif <parameter>kind</parameter> is FcMatchFont, those tagged as font operations are applied and
2252c393a42Smrgp_pat is used for &lt;test&gt; elements with target=pattern. Returns FcFalse
2262c393a42Smrgif the substitution cannot be performed (due to allocation failure). Otherwise returns FcTrue.
2272c393a42Smrg@@
2282c393a42Smrg
2292c393a42Smrg@RET@           FcBool
2302c393a42Smrg@FUNC@          FcConfigSubstitute
2312c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
2322c393a42Smrg@TYPE2@		FcPattern *			@ARG2@		p
2332c393a42Smrg@TYPE3@		FcMatchKind%                    @ARG3@          kind
2342c393a42Smrg@PURPOSE@	Execute substitutions
2352c393a42Smrg@DESC@
2362c393a42SmrgCalls FcConfigSubstituteWithPat setting p_pat to NULL. Returns FcFalse
2372c393a42Smrgif the substitution cannot be performed (due to allocation failure). Otherwise returns FcTrue.
2382c393a42Smrg@@
2392c393a42Smrg
2402c393a42Smrg@RET@           FcPattern *
2412c393a42Smrg@FUNC@          FcFontMatch
2422c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
2432c393a42Smrg@TYPE2@		FcPattern *			@ARG2@		p
2442c393a42Smrg@TYPE3@		FcResult *                      @ARG3@          result
2452c393a42Smrg@PURPOSE@	Return best font
2462c393a42Smrg@DESC@
2472c393a42SmrgFinds the font in <parameter>sets</parameter> most closely matching
2482c393a42Smrg<parameter>pattern</parameter> and returns the result of
2492c393a42Smrg<function>FcFontRenderPrepare</function> for that font and the provided
2502c393a42Smrgpattern. This function should be called only after
2512c393a42Smrg<function>FcConfigSubstitute</function> and
2522c393a42Smrg<function>FcDefaultSubstitute</function> have been called for
2532c393a42Smrg<parameter>p</parameter>; otherwise the results will not be correct.
2542c393a42Smrg@@
2552c393a42Smrg
2562c393a42Smrg@RET@           FcFontSet *
2572c393a42Smrg@FUNC@          FcFontSort
2582c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
2592c393a42Smrg@TYPE2@		FcPattern *			@ARG2@		p
2602c393a42Smrg@TYPE3@		FcBool%				@ARG3@		trim
2612c393a42Smrg@TYPE4@		FcCharSet **			@ARG4@		csp
2622c393a42Smrg@TYPE5@		FcResult *                      @ARG5@          result
2632c393a42Smrg@PURPOSE@	Return list of matching fonts
2642c393a42Smrg@DESC@
2652c393a42SmrgReturns the list of fonts sorted by closeness to <parameter>p</parameter>.  If <parameter>trim</parameter> is FcTrue,
2662c393a42Smrgelements in the list which don't include Unicode coverage not provided by
2672c393a42Smrgearlier elements in the list are elided.  The union of Unicode coverage of
2682c393a42Smrgall of the fonts is returned in <parameter>csp</parameter>, if <parameter>csp</parameter> is not NULL.  This function
2692c393a42Smrgshould be called only after FcConfigSubstitute and FcDefaultSubstitute have
2702c393a42Smrgbeen called for <parameter>p</parameter>; otherwise the results will not be correct.
2712c393a42Smrg    </para><para>
2722c393a42SmrgThe returned FcFontSet references FcPattern structures which may be shared
2732c393a42Smrgby the return value from multiple FcFontSort calls, applications must not
2742c393a42Smrgmodify these patterns.  Instead, they should be passed, along with <parameter>p</parameter> to
2752c393a42Smrg<function>FcFontRenderPrepare</function> which combines them into a complete pattern.
2762c393a42Smrg    </para><para>
2772c393a42SmrgThe FcFontSet returned by FcFontSort is destroyed by caling FcFontSetDestroy.
2782c393a42Smrg@@
2792c393a42Smrg
2802c393a42Smrg@RET@           FcPattern *
2812c393a42Smrg@FUNC@          FcFontRenderPrepare
2822c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
2832c393a42Smrg@TYPE2@		FcPattern *			@ARG2@		pat
2842c393a42Smrg@TYPE3@		FcPattern *                     @ARG3@          font
2852c393a42Smrg@PURPOSE@	Prepare pattern for loading font file
2862c393a42Smrg@DESC@
2872c393a42SmrgCreates a new pattern consisting of elements of <parameter>font</parameter> not appearing
2882c393a42Smrgin <parameter>pat</parameter>, elements of <parameter>pat</parameter> not appearing in <parameter>font</parameter> and the best matching
2892c393a42Smrgvalue from <parameter>pat</parameter> for elements appearing in both.  The result is passed to
2902c393a42SmrgFcConfigSubstitute with <parameter>kind</parameter> FcMatchFont and then returned.
2912c393a42Smrg@@
2922c393a42Smrg
2932c393a42Smrg@RET@           FcFontSet *
2942c393a42Smrg@FUNC@          FcFontList
2952c393a42Smrg@TYPE1@         FcConfig *			@ARG1@		config
2962c393a42Smrg@TYPE2@		FcPattern *			@ARG2@		p
2972c393a42Smrg@TYPE3@		FcObjectSet *                   @ARG3@          os
2982c393a42Smrg@PURPOSE@	List fonts
2992c393a42Smrg@DESC@
3002c393a42SmrgSelects fonts matching <parameter>p</parameter>, creates patterns from those fonts containing
3012c393a42Smrgonly the objects in <parameter>os</parameter> and returns the set of unique such patterns.
3022c393a42Smrg@@
3032c393a42Smrg
3042c393a42Smrg@RET@           FcChar8 *
3052c393a42Smrg@FUNC@          FcConfigFilename
3062c393a42Smrg@TYPE1@         const FcChar8 *			@ARG1@          name
3072c393a42Smrg@PURPOSE@	Find a config file
3082c393a42Smrg@DESC@
3092c393a42SmrgGiven the specified external entity name, return the associated filename.
3102c393a42SmrgThis provides applications a way to convert various configuration file
3112c393a42Smrgreferences into filename form.
3122c393a42Smrg    </para><para>
3132c393a42SmrgA null or empty <parameter>name</parameter> indicates that the default configuration file should
3142c393a42Smrgbe used; which file this references can be overridden with the
3152c393a42SmrgFC_CONFIG_FILE environment variable.  Next, if the name starts with <parameter>~</parameter>, it
3162c393a42Smrgrefers to a file in the current users home directory.  Otherwise if the name
3172c393a42Smrgdoesn't start with '/', it refers to a file in the default configuration
3182c393a42Smrgdirectory; the built-in default directory can be overridden with the
3192c393a42SmrgFC_CONFIG_DIR environment variable.
3202c393a42Smrg@@
3212c393a42Smrg
3222c393a42Smrg@RET@		FcBool
3232c393a42Smrg@FUNC@		FcConfigParseAndLoad
3242c393a42Smrg@TYPE1@		FcConfig *			@ARG1@		config
3252c393a42Smrg@TYPE2@		const FcChar8 *			@ARG2@		file
3262c393a42Smrg@TYPE3@		FcBool%				@ARG3@		complain
3272c393a42Smrg@PURPOSE@	load a configuration file
3282c393a42Smrg@DESC@
3292c393a42SmrgWalks the configuration in 'file' and constructs the internal representation
3302c393a42Smrgin 'config'.  Any include files referenced from within 'file' will be loaded
3312c393a42Smrgand parsed.  If 'complain' is FcFalse, no warning will be displayed if
3322c393a42Smrg'file' does not exist. Error and warning messages will be output to stderr.
3332c393a42SmrgReturns FcFalse if some error occurred while loading the file, either a
3342c393a42Smrgparse error, semantic error or allocation failure. Otherwise returns FcTrue.
3352c393a42Smrg@@
336