annotate libass/ass_fontconfig.c @ 28900:b2d3d9408a99

Use ScaledBorderAndShadow: yes by default.
author greg
date Wed, 11 Mar 2009 22:55:23 +0000
parents 5e03bb996d31
children a038ab949e7e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19902
diff changeset
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19902
diff changeset
2 // vim:ts=8:sw=8:noet:ai:
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19902
diff changeset
3 /*
26723
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
4 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
5 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
6 * This file is part of libass.
26723
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
7 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
8 * libass is free software; you can redistribute it and/or modify
26723
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
9 * it under the terms of the GNU General Public License as published by
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
11 * (at your option) any later version.
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
12 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
13 * libass is distributed in the hope that it will be useful,
26723
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
16 * GNU General Public License for more details.
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
17 *
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
18 * You should have received a copy of the GNU General Public License along
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
19 * with libass; if not, write to the Free Software Foundation, Inc.,
26723
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0f892cd714b2 Use standard license header.
diego
parents: 26710
diff changeset
21 */
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19902
diff changeset
22
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
23 #include "config.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
24
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
25 #include <stdlib.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
26 #include <stdio.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
27 #include <assert.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
28 #include <string.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
29 #include <sys/types.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
30 #include <sys/stat.h>
22292
2f3f27a014ef Add some missing includes.
eugeni
parents: 21630
diff changeset
31 #include <inttypes.h>
2f3f27a014ef Add some missing includes.
eugeni
parents: 21630
diff changeset
32 #include <ft2build.h>
2f3f27a014ef Add some missing includes.
eugeni
parents: 21630
diff changeset
33 #include FT_FREETYPE_H
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
34
21026
d138463e820b Collect all includes of mplayer headers in libass in a single file (mputils.h).
eugeni
parents: 20629
diff changeset
35 #include "mputils.h"
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
36 #include "ass.h"
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
37 #include "ass_library.h"
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
38 #include "ass_fontconfig.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
39
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27096
diff changeset
40 #ifdef CONFIG_FONTCONFIG
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
41 #include <fontconfig/fontconfig.h>
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
42 #include <fontconfig/fcfreetype.h>
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
43 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
44
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
45 struct fc_instance_s {
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27096
diff changeset
46 #ifdef CONFIG_FONTCONFIG
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
47 FcConfig* config;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
48 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
49 char* family_default;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
50 char* path_default;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
51 int index_default;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
52 };
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
53
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27096
diff changeset
54 #ifdef CONFIG_FONTCONFIG
26660
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
55
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
56 // 4yo fontconfig does not have these.
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
57 // They are only needed for debug output, anyway.
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
58 #ifndef FC_FULLNAME
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
59 #define FC_FULLNAME "fullname"
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
60 #endif
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
61 #ifndef FC_EMBOLDEN
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
62 #define FC_EMBOLDEN "embolden"
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
63 #endif
ab5729095d68 Define FC_FULLNAME and FC_EMBOLDEN to fix compilation with ancient fontconfig.
eugeni
parents: 26659
diff changeset
64
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
65 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
66 * \brief Low-level font selection.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
67 * \param priv private data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
68 * \param family font family
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
69 * \param treat_family_as_pattern treat family as fontconfig pattern
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
70 * \param bold font weight value
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
71 * \param italic font slant value
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
72 * \param index out: font index inside a file
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
73 * \param code: the character that should be present in the font, can be 0
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
74 * \return font file path
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
75 */
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
76 static char* _select_font(fc_instance_t* priv, const char* family, int treat_family_as_pattern,
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
77 unsigned bold, unsigned italic, int* index, uint32_t code)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
78 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
79 FcBool rc;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
80 FcResult result;
27842
c03685299634 Consistently use NULL for pointers instead of 0.
reimar
parents: 27841
diff changeset
81 FcPattern *pat = NULL, *rpat = NULL;
26616
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
82 int r_index, r_slant, r_weight;
26615
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
83 FcChar8 *r_family, *r_style, *r_file, *r_fullname;
26616
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
84 FcBool r_outline, r_embolden;
26613
92939846ff49 Cosmetics: rename local variables to better reflect their contents.
eugeni
parents: 26592
diff changeset
85 FcCharSet* r_charset;
27842
c03685299634 Consistently use NULL for pointers instead of 0.
reimar
parents: 27841
diff changeset
86 FcFontSet* fset = NULL;
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
87 int curf;
27842
c03685299634 Consistently use NULL for pointers instead of 0.
reimar
parents: 27841
diff changeset
88 char* retval = NULL;
26658
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
89 int family_cnt;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
90
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
91 *index = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
92
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
93 if (treat_family_as_pattern)
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
94 pat = FcNameParse((const FcChar8*)family);
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
95 else
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
96 pat = FcPatternCreate();
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
97
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
98 if (!pat)
23215
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
99 goto error;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
100
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
101 if (!treat_family_as_pattern) {
28861
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
102 FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)family);
26591
0f069e41d8d2 Allow inexact font family matching.
eugeni
parents: 26582
diff changeset
103
28861
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
104 // In SSA/ASS fonts are sometimes referenced by their "full name",
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
105 // which is usually a concatenation of family name and font
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
106 // style (ex. Ottawa Bold). Full name is available from
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
107 // FontConfig pattern element FC_FULLNAME, but it is never
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
108 // used for font matching.
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
109 // Therefore, I'm removing words from the end of the name one
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
110 // by one, and adding shortened names to the pattern. It seems
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
111 // that the first value (full name in this case) has
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
112 // precedence in matching.
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
113 // An alternative approach could be to reimplement FcFontSort
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
114 // using FC_FULLNAME instead of FC_FAMILY.
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
115 family_cnt = 1;
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
116 {
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
117 char* s = strdup(family);
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
118 char* p = s + strlen(s);
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
119 while (--p > s)
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
120 if (*p == ' ' || *p == '-') {
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
121 *p = '\0';
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
122 FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)s);
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
123 ++ family_cnt;
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
124 }
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
125 free(s);
5e03bb996d31 Cosmetics: reindent.
eugeni
parents: 28860
diff changeset
126 }
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
127 }
19063
5525af2ee4c7 Use FcPatternAdd-Type instead of FcNameParse. The latter, as it turns out, requires escaping of some characters ('-', maybe more).
eugeni
parents: 19001
diff changeset
128 FcPatternAddBool(pat, FC_OUTLINE, FcTrue);
5525af2ee4c7 Use FcPatternAdd-Type instead of FcNameParse. The latter, as it turns out, requires escaping of some characters ('-', maybe more).
eugeni
parents: 19001
diff changeset
129 FcPatternAddInteger(pat, FC_SLANT, italic);
5525af2ee4c7 Use FcPatternAdd-Type instead of FcNameParse. The latter, as it turns out, requires escaping of some characters ('-', maybe more).
eugeni
parents: 19001
diff changeset
130 FcPatternAddInteger(pat, FC_WEIGHT, bold);
5525af2ee4c7 Use FcPatternAdd-Type instead of FcNameParse. The latter, as it turns out, requires escaping of some characters ('-', maybe more).
eugeni
parents: 19001
diff changeset
131
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
132 FcDefaultSubstitute(pat);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
133
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
134 rc = FcConfigSubstitute(priv->config, pat, FcMatchPattern);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
135 if (!rc)
23215
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
136 goto error;
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
137
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
138 fset = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
27096
a2c8efd917ea Check if the font set returned from FcFontSort in not NULL.
eugeni
parents: 27095
diff changeset
139 if (!fset)
a2c8efd917ea Check if the font set returned from FcFontSort in not NULL.
eugeni
parents: 27095
diff changeset
140 goto error;
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
141
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
142 for (curf = 0; curf < fset->nfont; ++curf) {
26658
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
143 FcPattern* curp = fset->fonts[curf];
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
144
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
145 result = FcPatternGetBool(curp, FC_OUTLINE, 0, &r_outline);
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
146 if (result != FcResultMatch)
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
147 continue;
26613
92939846ff49 Cosmetics: rename local variables to better reflect their contents.
eugeni
parents: 26592
diff changeset
148 if (r_outline != FcTrue)
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
149 continue;
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
150 if (!code)
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
151 break;
26658
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
152 result = FcPatternGetCharSet(curp, FC_CHARSET, 0, &r_charset);
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
153 if (result != FcResultMatch)
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
154 continue;
26613
92939846ff49 Cosmetics: rename local variables to better reflect their contents.
eugeni
parents: 26592
diff changeset
155 if (FcCharSetHasChar(r_charset, code))
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
156 break;
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
157 }
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
158
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
159 if (curf >= fset->nfont)
23215
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
160 goto error;
21351
c611dfc4cb85 If a glyph is not found in the current font, switch to another one.
eugeni
parents: 21279
diff changeset
161
26819
d288ec15f2cc Fix compilation with FontConfig <= 2.2.96.
eugeni
parents: 26738
diff changeset
162 #if (FC_VERSION >= 20297)
26658
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
163 // Remove all extra family names from original pattern.
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
164 // After this, FcFontRenderPrepare will select the most relevant family
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
165 // name in case there are more than one of them.
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
166 for (; family_cnt > 1; --family_cnt)
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
167 FcPatternRemove(pat, FC_FAMILY, family_cnt - 1);
26819
d288ec15f2cc Fix compilation with FontConfig <= 2.2.96.
eugeni
parents: 26738
diff changeset
168 #endif
26658
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
169
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
170 rpat = FcFontRenderPrepare(priv->config, pat, fset->fonts[curf]);
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
171 if (!rpat)
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
172 goto error;
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
173
26613
92939846ff49 Cosmetics: rename local variables to better reflect their contents.
eugeni
parents: 26592
diff changeset
174 result = FcPatternGetInteger(rpat, FC_INDEX, 0, &r_index);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
175 if (result != FcResultMatch)
23215
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
176 goto error;
26613
92939846ff49 Cosmetics: rename local variables to better reflect their contents.
eugeni
parents: 26592
diff changeset
177 *index = r_index;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
178
26614
875a7878626c Move font family check to the end of the list.
eugeni
parents: 26613
diff changeset
179 result = FcPatternGetString(rpat, FC_FILE, 0, &r_file);
875a7878626c Move font family check to the end of the list.
eugeni
parents: 26613
diff changeset
180 if (result != FcResultMatch)
875a7878626c Move font family check to the end of the list.
eugeni
parents: 26613
diff changeset
181 goto error;
875a7878626c Move font family check to the end of the list.
eugeni
parents: 26613
diff changeset
182 retval = strdup((const char*)r_file);
875a7878626c Move font family check to the end of the list.
eugeni
parents: 26613
diff changeset
183
26613
92939846ff49 Cosmetics: rename local variables to better reflect their contents.
eugeni
parents: 26592
diff changeset
184 result = FcPatternGetString(rpat, FC_FAMILY, 0, &r_family);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
185 if (result != FcResultMatch)
26615
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
186 r_family = NULL;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
187
26615
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
188 result = FcPatternGetString(rpat, FC_FULLNAME, 0, &r_fullname);
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
189 if (result != FcResultMatch)
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
190 r_fullname = NULL;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
191
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
192 if (!treat_family_as_pattern &&
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
193 !(r_family && strcasecmp((const char*)r_family, family) == 0) &&
26615
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
194 !(r_fullname && strcasecmp((const char*)r_fullname, family) == 0))
75154771f2f3 Rewrite font family check in a simpler way.
eugeni
parents: 26614
diff changeset
195 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_SelectedFontFamilyIsNotTheRequestedOne,
26659
9e1d66c990fa If both full name and family are available, use the former in inexact match warning.
eugeni
parents: 26658
diff changeset
196 (const char*)(r_fullname ? r_fullname : r_family), family);
26616
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
197
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
198 result = FcPatternGetString(rpat, FC_STYLE, 0, &r_style);
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
199 if (result != FcResultMatch)
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
200 r_style = NULL;
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
201
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
202 result = FcPatternGetInteger(rpat, FC_SLANT, 0, &r_slant);
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
203 if (result != FcResultMatch)
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
204 r_slant = 0;
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
205
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
206 result = FcPatternGetInteger(rpat, FC_WEIGHT, 0, &r_weight);
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
207 if (result != FcResultMatch)
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
208 r_weight = 0;
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
209
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
210 result = FcPatternGetBool(rpat, FC_EMBOLDEN, 0, &r_embolden);
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
211 if (result != FcResultMatch)
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
212 r_embolden = 0;
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
213
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
214 mp_msg(MSGT_ASS, MSGL_V, "[ass] Font info: family '%s', style '%s', fullname '%s',"
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
215 " slant %d, weight %d%s\n",
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
216 (const char*)r_family, (const char*)r_style, (const char*)r_fullname,
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
217 r_slant, r_weight, r_embolden ? ", embolden" : "");
c37a85037fc2 Print more info about selected font.
eugeni
parents: 26615
diff changeset
218
23215
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
219 error:
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
220 if (pat) FcPatternDestroy(pat);
26658
1e1ebebc8f5b Remove extra family names from the search pattern after FcFontSort and
eugeni
parents: 26620
diff changeset
221 if (rpat) FcPatternDestroy(rpat);
23215
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
222 if (fset) FcFontSetDestroy(fset);
c52636be7c4b Deallocate FontConfig objects.
eugeni
parents: 22946
diff changeset
223 return retval;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
224 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
225
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
226 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
227 * \brief Find a font. Use default family or path if necessary.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
228 * \param priv_ private data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
229 * \param family font family
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
230 * \param treat_family_as_pattern treat family as fontconfig pattern
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
231 * \param bold font weight value
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
232 * \param italic font slant value
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
233 * \param index out: font index inside a file
23980
27bac14b4ce4 More simple and correct font reselection.
eugeni
parents: 23216
diff changeset
234 * \param code: the character that should be present in the font, can be 0
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
235 * \return font file path
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
236 */
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
237 char* fontconfig_select(fc_instance_t* priv, const char* family, int treat_family_as_pattern,
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
238 unsigned bold, unsigned italic, int* index, uint32_t code)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
239 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
240 char* res = 0;
26582
62ac4f8062ee Remove libass dependency on global font_fontconfig variable.
eugeni
parents: 25351
diff changeset
241 if (!priv->config) {
25351
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
242 *index = priv->index_default;
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
243 return priv->path_default;
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
244 }
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
245 if (family && *family)
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
246 res = _select_font(priv, family, treat_family_as_pattern, bold, italic, index, code);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
247 if (!res && priv->family_default) {
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
248 res = _select_font(priv, priv->family_default, 0, bold, italic, index, code);
21279
9040bce9f768 Remove obsolete "no_more_font_messages" hack.
eugeni
parents: 21066
diff changeset
249 if (res)
21066
6196ba31e97e MSGTRs for libass
kraymer
parents: 21026
diff changeset
250 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFontFamily,
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
251 family, bold, italic, res, *index);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
252 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
253 if (!res && priv->path_default) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
254 res = priv->path_default;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
255 *index = priv->index_default;
21279
9040bce9f768 Remove obsolete "no_more_font_messages" hack.
eugeni
parents: 21066
diff changeset
256 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFont,
9040bce9f768 Remove obsolete "no_more_font_messages" hack.
eugeni
parents: 21066
diff changeset
257 family, bold, italic, res, *index);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
258 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
259 if (!res) {
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
260 res = _select_font(priv, "Arial", 0, bold, italic, index, code);
21279
9040bce9f768 Remove obsolete "no_more_font_messages" hack.
eugeni
parents: 21066
diff changeset
261 if (res)
21066
6196ba31e97e MSGTRs for libass
kraymer
parents: 21026
diff changeset
262 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingArialFontFamily,
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
263 family, bold, italic, res, *index);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
264 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
265 if (res)
20629
e8885ec63928 Introduce MSGT_ASS, use it for all libass messages.
eugeni
parents: 20105
diff changeset
266 mp_msg(MSGT_ASS, MSGL_V, "fontconfig_select: (%s, %d, %d) -> %s, %d\n",
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
267 family, bold, italic, res, *index);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
268 return res;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
269 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
270
23216
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
271 #if (FC_VERSION < 20402)
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
272 static char* validate_fname(char* name)
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
273 {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
274 char* fname;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
275 char* p;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
276 char* q;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
277 unsigned code;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
278 int sz = strlen(name);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
279
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
280 q = fname = malloc(sz + 1);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
281 p = name;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
282 while (*p) {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
283 code = utf8_get_char(&p);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
284 if (code == 0)
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
285 break;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
286 if ( (code > 0x7F) ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
287 (code == '\\') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
288 (code == '/') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
289 (code == ':') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
290 (code == '*') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
291 (code == '?') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
292 (code == '<') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
293 (code == '>') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
294 (code == '|') ||
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
295 (code == 0))
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
296 {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
297 *q++ = '_';
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
298 } else {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
299 *q++ = code;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
300 }
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
301 if (p - name > sz)
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
302 break;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
303 }
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
304 *q = 0;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
305 return fname;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
306 }
23216
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
307 #endif
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
308
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
309 /**
21630
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
310 * \brief Process memory font.
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
311 * \param priv private data
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
312 * \param library library object
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
313 * \param ftlibrary freetype library object
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
314 * \param idx index of the processed font in library->fontdata
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
315 * With FontConfig >= 2.4.2, builds a font pattern in memory via FT_New_Memory_Face/FcFreeTypeQueryFace.
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
316 * With older FontConfig versions, save the font to ~/.mplayer/fonts.
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
317 */
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
318 static void process_fontdata(fc_instance_t* priv, ass_library_t* library, FT_Library ftlibrary, int idx)
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
319 {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
320 int rc;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
321 const char* name = library->fontdata[idx].name;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
322 const char* data = library->fontdata[idx].data;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
323 int data_size = library->fontdata[idx].size;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
324
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
325 #if (FC_VERSION < 20402)
23216
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
326 struct stat st;
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
327 char* fname;
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
328 const char* fonts_dir = library->fonts_dir;
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
329 char buf[1000];
27842
c03685299634 Consistently use NULL for pointers instead of 0.
reimar
parents: 27841
diff changeset
330 FILE* fp = NULL;
23216
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
331
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
332 if (!fonts_dir)
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
333 return;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
334 rc = stat(fonts_dir, &st);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
335 if (rc) {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
336 int res;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
337 #ifndef __MINGW32__
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
338 res = mkdir(fonts_dir, 0700);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
339 #else
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
340 res = mkdir(fonts_dir);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
341 #endif
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
342 if (res) {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
343 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FailedToCreateDirectory, fonts_dir);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
344 }
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
345 } else if (!S_ISDIR(st.st_mode)) {
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
346 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_NotADirectory, fonts_dir);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
347 }
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
348
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
349 fname = validate_fname((char*)name);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
350
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
351 snprintf(buf, 1000, "%s/%s", fonts_dir, fname);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
352 free(fname);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
353
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
354 fp = fopen(buf, "wb");
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
355 if (!fp) return;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
356
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
357 fwrite(data, data_size, 1, fp);
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
358 fclose(fp);
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
359
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
360 #else // (FC_VERSION >= 20402)
23216
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
361 FT_Face face;
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
362 FcPattern* pattern;
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
363 FcFontSet* fset;
b863ed752149 Move variables and a function under #ifdef FC_VERSION to avoid warnings.
eugeni
parents: 23215
diff changeset
364 FcBool res;
26824
6112b693fab9 Read all faces of a memory font, not just the first one.
eugeni
parents: 26819
diff changeset
365 int face_index, num_faces = 1;
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
366
26824
6112b693fab9 Read all faces of a memory font, not just the first one.
eugeni
parents: 26819
diff changeset
367 for (face_index = 0; face_index < num_faces; ++face_index) {
26825
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
368 rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, face_index, &face);
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
369 if (rc) {
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
370 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningMemoryFont, name);
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
371 return;
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
372 }
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
373 num_faces = face->num_faces;
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
374
26825
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
375 pattern = FcFreeTypeQueryFace(face, (unsigned char*)name, 0, FcConfigGetBlanks(priv->config));
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
376 if (!pattern) {
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
377 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcFreeTypeQueryFace");
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
378 FT_Done_Face(face);
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
379 return;
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
380 }
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
381
26825
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
382 fset = FcConfigGetFonts(priv->config, FcSetSystem); // somehow it failes when asked for FcSetApplication
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
383 if (!fset) {
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
384 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcConfigGetFonts");
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
385 FT_Done_Face(face);
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
386 return;
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
387 }
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
388
26825
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
389 res = FcFontSetAdd(fset, pattern);
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
390 if (!res) {
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
391 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FunctionCallFailed, "FcFontSetAdd");
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
392 FT_Done_Face(face);
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
393 return;
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
394 }
13ef1f050cfc Cosmetics: reindent after the last commit.
eugeni
parents: 26824
diff changeset
395
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
396 FT_Done_Face(face);
26824
6112b693fab9 Read all faces of a memory font, not just the first one.
eugeni
parents: 26819
diff changeset
397 }
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
398 #endif
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
399 }
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
400
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
401 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
402 * \brief Init fontconfig.
21630
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
403 * \param library libass library object
0d8005d2fe5c Update some comments.
eugeni
parents: 21615
diff changeset
404 * \param ftlibrary freetype library object
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
405 * \param family default font family
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
406 * \param path default font path
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
407 * \return pointer to fontconfig private data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
408 */
26582
62ac4f8062ee Remove libass dependency on global font_fontconfig variable.
eugeni
parents: 25351
diff changeset
409 fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path, int fc)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
410 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
411 int rc;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
412 fc_instance_t* priv = calloc(1, sizeof(fc_instance_t));
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
413 const char* dir = library->fonts_dir;
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
414 int i;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
415
26582
62ac4f8062ee Remove libass dependency on global font_fontconfig variable.
eugeni
parents: 25351
diff changeset
416 if (!fc) {
25351
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
417 mp_msg(MSGT_ASS, MSGL_WARN,
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
418 MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed);
27841
29d72a47da0c Fallback to non-fontconfig behaviour when fontconfig initialization fails.
reimar
parents: 27393
diff changeset
419 goto exit;
25351
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
420 }
f46e91c64b39 Fix libass to support -nofontconfig.
ulion
parents: 23988
diff changeset
421
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
422 rc = FcInit();
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
423 assert(rc);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
424
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
425 priv->config = FcConfigGetCurrent();
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
426 if (!priv->config) {
21066
6196ba31e97e MSGTRs for libass
kraymer
parents: 21026
diff changeset
427 mp_msg(MSGT_ASS, MSGL_FATAL, MSGTR_LIBASS_FcInitLoadConfigAndFontsFailed);
27841
29d72a47da0c Fallback to non-fontconfig behaviour when fontconfig initialization fails.
reimar
parents: 27393
diff changeset
428 goto exit;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
429 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
430
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
431 for (i = 0; i < library->num_fontdata; ++i)
21460
62bd8e0d3a0f Open embedded fonts directly from memory.
eugeni
parents: 21458
diff changeset
432 process_fontdata(priv, library, ftlibrary, i);
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21351
diff changeset
433
27094
bafda9ff0221 Only use application font dir if library->fonts_dir is not NULL.
eugeni
parents: 26825
diff changeset
434 if (dir) {
27095
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
435 if (FcDirCacheValid((const FcChar8 *)dir) == FcFalse)
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
436 {
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
437 mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_UpdatingFontCache);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
438 if (FcGetVersion() >= 20390 && FcGetVersion() < 20400)
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
439 mp_msg(MSGT_ASS, MSGL_WARN,
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
440 MSGTR_LIBASS_BetaVersionsOfFontconfigAreNotSupported);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
441 // FontConfig >= 2.4.0 updates cache automatically in FcConfigAppFontAddDir()
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
442 if (FcGetVersion() < 20390) {
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
443 FcFontSet* fcs;
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
444 FcStrSet* fss;
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
445 fcs = FcFontSetCreate();
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
446 fss = FcStrSetCreate();
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
447 rc = FcStrSetAdd(fss, (const FcChar8*)dir);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
448 if (!rc) {
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
449 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FcStrSetAddFailed);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
450 goto ErrorFontCache;
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
451 }
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
452
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
453 rc = FcDirScan(fcs, fss, NULL, FcConfigGetBlanks(priv->config),
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
454 (const FcChar8 *)dir, FcFalse);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
455 if (!rc) {
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
456 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FcDirScanFailed);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
457 goto ErrorFontCache;
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
458 }
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
459
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
460 rc = FcDirSave(fcs, fss, (const FcChar8 *)dir);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
461 if (!rc) {
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
462 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FcDirSave);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
463 goto ErrorFontCache;
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
464 }
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
465 ErrorFontCache:
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
466 ;
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
467 }
19902
2c43912bb46a Cosmetics: fix indentation after last commit.
eugeni
parents: 19901
diff changeset
468 }
19340
f0d49f38ce97 Use FontConfig cache to speedup mplayer startup.
eugeni
parents: 19064
diff changeset
469
27095
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
470 rc = FcConfigAppFontAddDir(priv->config, (const FcChar8*)dir);
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
471 if (!rc) {
a0e00d065593 Reindent.
eugeni
parents: 27094
diff changeset
472 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FcConfigAppFontAddDirFailed);
19901
27b87a9dc19a Don't call FcDirScan/FcDirSave with FontConfig >= 2.4.
eugeni
parents: 19481
diff changeset
473 }
19340
f0d49f38ce97 Use FontConfig cache to speedup mplayer startup.
eugeni
parents: 19064
diff changeset
474 }
f0d49f38ce97 Use FontConfig cache to speedup mplayer startup.
eugeni
parents: 19064
diff changeset
475
27842
c03685299634 Consistently use NULL for pointers instead of 0.
reimar
parents: 27841
diff changeset
476 priv->family_default = family ? strdup(family) : NULL;
27841
29d72a47da0c Fallback to non-fontconfig behaviour when fontconfig initialization fails.
reimar
parents: 27393
diff changeset
477 exit:
27842
c03685299634 Consistently use NULL for pointers instead of 0.
reimar
parents: 27841
diff changeset
478 priv->path_default = path ? strdup(path) : NULL;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
479 priv->index_default = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
480
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
481 return priv;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
482 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
483
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27096
diff changeset
484 #else /* CONFIG_FONTCONFIG */
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
485
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
486 char* fontconfig_select(fc_instance_t* priv, const char* family, int treat_family_as_pattern,
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 27842
diff changeset
487 unsigned bold, unsigned italic, int* index, uint32_t code)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
488 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
489 *index = priv->index_default;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
490 return priv->path_default;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
491 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
492
26620
c64b5434f2de Fix the second fontconfig_init function as the declaration in the .h file.
ulion
parents: 26616
diff changeset
493 fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path, int fc)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
494 {
19481
5890c54b755c no c++ decls!
rfelker
parents: 19340
diff changeset
495 fc_instance_t* priv;
5890c54b755c no c++ decls!
rfelker
parents: 19340
diff changeset
496
21066
6196ba31e97e MSGTRs for libass
kraymer
parents: 21026
diff changeset
497 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
498
19481
5890c54b755c no c++ decls!
rfelker
parents: 19340
diff changeset
499 priv = calloc(1, sizeof(fc_instance_t));
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
500
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
501 priv->path_default = strdup(path);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
502 priv->index_default = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
503 return priv;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
504 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
505
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
506 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
507
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
508 void fontconfig_done(fc_instance_t* priv)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
509 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
510 // don't call FcFini() here, library can still be used by some code
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
511 if (priv && priv->path_default) free(priv->path_default);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
512 if (priv && priv->family_default) free(priv->family_default);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
513 if (priv) free(priv);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
514 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
515
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
516