~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_libraries/ADM_libass/ass_fontconfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2008-01-23 14:24:55 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123142455-wznqmv3teznzpmjb
Tags: 1:2.4.0-0.3ubuntu1
* Merged new upstream release from debian-multimedia.org
  (LP: #178845, LP: #180393), remaining Ubuntu changes:
  + debian/control:
    - set maintainer fields per Ubuntu policy.
    - removed libamrnb-dev, not in Ubuntu and most likely
      will never be (due to being proprietary software).
    - build against current libx264-dev (LP: #177082).
    - build against current libfaac-dev (LP: #181389).
    - build-depend on chrpath to strip rpath from avidemux2_qt4.
  + debian/rules: strip rpath from avidemux2_qt4.
  + debian/source.lintian-overrides: re-added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <sys/types.h>
28
28
#include <sys/stat.h>
29
29
#include <inttypes.h>
30
 
#ifdef HAVE_UNISTD_H
31
 
// avoid warnings due to different definition of this in freetype headers
32
 
#define WE_DO_HAVE_UNISTD_H
33
 
#undef HAVE_UNISTD_H
34
 
#endif
35
30
#include <ft2build.h>
36
31
#include FT_FREETYPE_H
37
 
#ifdef WE_DO_HAVE_UNISTD_H
38
 
#undef HAVE_UNISTD_H
39
 
#define HAVE_UNISTD_H
40
 
#endif
41
32
 
42
33
#include "mputils.h"
43
34
#include "ass.h"
66
57
 * \param bold font weight value
67
58
 * \param italic font slant value
68
59
 * \param index out: font index inside a file
69
 
 * \param charset: contains the characters that should be present in the font, can be NULL
 
60
 * \param code: the character that should be present in the font, can be 0
70
61
 * \return font file path
71
62
*/ 
72
63
static char* _select_font(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
73
 
                          FcCharSet* charset)
 
64
                          uint32_t code)
74
65
{
75
66
        FcBool rc;
76
67
        FcResult result;
80
71
        FcBool val_b;
81
72
        FcCharSet* val_cs;
82
73
        FcFontSet* fset = 0;
83
 
        int curf, bestf, bestdiff = 0;
 
74
        int curf;
84
75
        char* retval = 0;
85
76
        
86
77
        *index = 0;
102
93
 
103
94
        fset = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
104
95
 
105
 
        bestf = -1;
106
 
        if (charset)
107
 
                bestdiff = FcCharSetCount(charset) + 1;
108
96
        for (curf = 0; curf < fset->nfont; ++curf) {
109
97
                rpat = fset->fonts[curf];
110
98
                
113
101
                        continue;
114
102
                if (val_b != FcTrue)
115
103
                        continue;
116
 
 
117
 
                if (charset) {
118
 
                        int diff;
119
 
                        result = FcPatternGetCharSet(rpat, FC_CHARSET, 0, &val_cs);
120
 
                        if (result != FcResultMatch)
121
 
                                continue;
122
 
                        diff = FcCharSetSubtractCount(charset, val_cs);
123
 
                        if (diff < bestdiff) {
124
 
                                bestdiff = diff;
125
 
                                bestf = curf;
126
 
                        }
127
 
                        if (diff == 0)
128
 
                                break;
129
 
                } else {
130
 
                        bestf = curf;
131
 
                        break;
132
 
                }
 
104
                if (!code)
 
105
                        break;
 
106
                result = FcPatternGetCharSet(rpat, FC_CHARSET, 0, &val_cs);
 
107
                if (result != FcResultMatch)
 
108
                        continue;
 
109
                if (FcCharSetHasChar(val_cs, code))
 
110
                        break;
133
111
        }
134
112
 
135
 
        if (bestf < 0)
 
113
        if (curf >= fset->nfont)
136
114
                goto error;
137
115
 
138
 
        rpat = fset->fonts[bestf];
 
116
        rpat = fset->fonts[curf];
139
117
        
140
118
        result = FcPatternGetInteger(rpat, FC_INDEX, 0, &val_i);
141
119
        if (result != FcResultMatch)
168
146
 * \param bold font weight value
169
147
 * \param italic font slant value
170
148
 * \param index out: font index inside a file
171
 
 * \param charset: contains the characters that should be present in the font, can be NULL
 
149
 * \param code: the character that should be present in the font, can be 0
172
150
 * \return font file path
173
151
*/ 
174
 
char* fontconfig_select_with_charset(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
175
 
                        FcCharSet* charset)
 
152
char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
 
153
                        uint32_t code)
176
154
{
177
155
        char* res = 0;
178
156
        if (family && *family)
179
 
                res = _select_font(priv, family, bold, italic, index, charset);
 
157
                res = _select_font(priv, family, bold, italic, index, code);
180
158
        if (!res && priv->family_default) {
181
 
                res = _select_font(priv, priv->family_default, bold, italic, index, charset);
 
159
                res = _select_font(priv, priv->family_default, bold, italic, index, code);
182
160
                if (res)
183
161
                        mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFontFamily, 
184
162
                                        family, bold, italic, res, *index);
190
168
                       family, bold, italic, res, *index);
191
169
        }
192
170
        if (!res) {
193
 
                res = _select_font(priv, "Arial", bold, italic, index, charset);
 
171
                res = _select_font(priv, "Arial", bold, italic, index, code);
194
172
                if (res)
195
173
                        mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingArialFontFamily, 
196
174
                                        family, bold, italic, res, *index);
201
179
        return res;
202
180
}
203
181
 
204
 
char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index)
205
 
{
206
 
        return fontconfig_select_with_charset(priv, family, bold, italic, index, 0);
207
 
}
208
 
 
209
182
#if (FC_VERSION < 20402)
210
183
static char* validate_fname(char* name)
211
184
{
407
380
 
408
381
#else // HAVE_FONTCONFIG
409
382
 
410
 
char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index)
 
383
char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index,
 
384
                        uint32_t code)
411
385
{
412
386
        *index = priv->index_default;
413
387
        return priv->path_default;