のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

get_shaper_and_font

1257 static gboolean
1258 get_shaper_and_font (ItemizeState      *state,
1259        gunichar                    wc,
1260        PangoEngineShape  **shape_engine,
1261	        PangoFont                 **font)
1262 {
1263     GetShaperFontInfo info;
1264
1265     /* We'd need a separate cache when fallback is disabled, but since lookup
1266      * with fallback disabled is faster anyways, we just skip caching */
1267     if (state->enable_fallback && shaper_font_cache_get (state->cache, wc, shape_engine, font))
1268        return *shape_engine != NULL;
1269
1270     if (!state->exact_engines && !state->fallback_engines)
1271          get_engines (state->context, state->derived_lang, get_script (state),
1272		                      &state->exact_engines, &state->fallback_engines);
1273
1274     info.lang = state->derived_lang;
1275     info.wc = wc;
1276     info.shape_engine = NULL;
1277     info.font = NULL;
1278
1279     info.engines = state->exact_engines;
1280     if (info.engines)
1281      {
1282          if (state->enable_fallback)
1283	       pango_fontset_foreach (state->current_fonts, get_shaper_and_font_foreach, &info);
1284          else
1285	       get_shaper_and_font_foreach (NULL, get_base_font (state), &info);
1286
1287          if (info.shape_engine)
1288	  {
1289	       *shape_engine = info.shape_engine;
1290	       *font = info.font;
1291
1292	      /* skip caching if fallback disabled (see above) */
1293             if (state->enable_fallback)
1294                 shaper_font_cache_insert (state->cache, wc, *shape_engine, *font);
1295
1296	     return TRUE;
1297         }
1298     }
1299
1300     info.engines = state->fallback_engines;
1301     if (info.engines)
1302     {
1303         if (state->enable_fallback)
1304	     pango_fontset_foreach (state->current_fonts, get_shaper_and_font_foreach, &info);
1305         else
1306            get_shaper_and_font_foreach (NULL, get_base_font (state), &info);
1307     }
1308
1309     *shape_engine = info.shape_engine;
1310     *font = info.font;
1311
1312     /* skip caching if fallback disabled (see above) */
1313     if (state->enable_fallback)
1314           shaper_font_cache_insert (state->cache, wc, *shape_engine, *font);
1315
1316     return *shape_engine != NULL;
1317 }
1318