~ubuntu-branches/ubuntu/karmic/pango1.0/karmic-security

« back to all changes in this revision

Viewing changes to pango/pango-context.c

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2007-12-18 21:11:37 UTC
  • mfrom: (1.2.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218211137-0ibmwreimvxf3cp1
Tags: 1.19.2-1ubuntu1
* Sync with Debian; Ubuntu changes are:
  - Add patch 30_anymetrics, turns on FC_ANY_METRICS whenever looking up
    fonts with fontconfig; lets fontconfig's configuration know that we
    don't care about getting a font with exactly the same shape as the
    family we asked for and fixes (eg) a firefox vs. evince font metrics
    ugliness issue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1094
1094
  return state->base_font;
1095
1095
}
1096
1096
 
 
1097
static PangoScript
 
1098
get_script (ItemizeState      *state)
 
1099
{
 
1100
  /* Always use a basic shaper for vertical layout (ie, east/west gravity)
 
1101
   * as none of our script shapers support vertical shaping right now.
 
1102
   *
 
1103
   * XXX Should move the knowledge into the shaper interface.
 
1104
   */
 
1105
 
 
1106
  if (PANGO_GRAVITY_IS_VERTICAL (state->resolved_gravity))
 
1107
    return PANGO_SCRIPT_COMMON;
 
1108
  else
 
1109
    return state->script;
 
1110
}
 
1111
 
1097
1112
static gboolean
1098
1113
get_shaper_and_font (ItemizeState      *state,
1099
1114
                     gunichar           wc,
1108
1123
    return *shape_engine != NULL;
1109
1124
 
1110
1125
  if (!state->exact_engines && !state->fallback_engines)
1111
 
    {
1112
 
      /* Always use a basic shaper for vertical layout (ie, east/west gravity)
1113
 
       * as we do not support vertical shaping as of now.
1114
 
       */
1115
 
      PangoScript script;
1116
 
 
1117
 
      if (PANGO_GRAVITY_IS_VERTICAL (state->resolved_gravity))
1118
 
        script = PANGO_SCRIPT_COMMON;
1119
 
      else
1120
 
        script = state->script;
1121
 
 
1122
 
      get_engines (state->context, state->derived_lang, script,
1123
 
                   &state->exact_engines, &state->fallback_engines);
1124
 
    }
 
1126
    get_engines (state->context, state->derived_lang, get_script (state),
 
1127
                 &state->exact_engines, &state->fallback_engines);
1125
1128
 
1126
1129
  info.lang = state->derived_lang;
1127
1130
  info.wc = wc;
1289
1292
    }
1290
1293
}
1291
1294
 
 
1295
static const char *
 
1296
string_from_script (PangoScript script)
 
1297
{
 
1298
  static GEnumClass *class = NULL;
 
1299
  GEnumValue *value;
 
1300
  if (!class)
 
1301
    class = g_type_class_ref (PANGO_TYPE_SCRIPT);
 
1302
 
 
1303
  value = g_enum_get_value (class, script);
 
1304
  if (!value)
 
1305
    return string_from_script (PANGO_SCRIPT_INVALID_CODE);
 
1306
 
 
1307
  return value->value_nick;
 
1308
}
 
1309
 
1292
1310
static void
1293
1311
itemize_state_process_run (ItemizeState *state)
1294
1312
{
1351
1369
      PangoEngineShape *shape_engine;
1352
1370
      PangoFont *font;
1353
1371
 
1354
 
      if (!get_shaper_and_font (state, ' ', &shape_engine, &font))
 
1372
      if (G_UNLIKELY (!get_shaper_and_font (state, ' ', &shape_engine, &font)))
1355
1373
        {
 
1374
          /* If no shaper was found, warn only once per fontmap/script pair */
 
1375
          PangoFontMap *fontmap = state->context->font_map;
 
1376
          const char *script_name = string_from_script (get_script (state));
 
1377
 
 
1378
          if (!g_object_get_data (G_OBJECT (fontmap), script_name))
 
1379
            {
 
1380
              const char *what;
 
1381
              if (shape_engine == NULL)
 
1382
                what = "shape engine";
 
1383
              else if (font == NULL)
 
1384
                what = "font";
 
1385
              else
 
1386
                what = "nothing (oops!)";
 
1387
               
 
1388
              g_warning ("failed to find shape engine, expect ugly output. engine-type='%s', script='%s'",
 
1389
                         pango_font_map_get_shape_engine_type (fontmap),
 
1390
                         script_name);
 
1391
 
 
1392
              g_object_set_data_full (G_OBJECT (fontmap), script_name,
 
1393
                                      GINT_TO_POINTER (1), NULL);
 
1394
            }
 
1395
 
1356
1396
          shape_engine = _pango_get_fallback_shaper ();
1357
1397
          font = NULL;
1358
1398
        }