/* Compute a font's score against selection parameters. TRM 8-27. * Also set *mapp to the symbol map to be used if this font wins. */ static void score_match(const pcl_state_t *pcs, const pcl_font_selection_t *pfs, const pl_font_t *fp, pl_symbol_map_t **mapp, match_score_t score) { int tscore; /* 1. Symbol set. 2 for exact match or full support, 1 for * default supported, 0 for no luck. */ score[score_symbol_set] = check_support(pcs, pfs->params.symbol_set, fp, mapp, false); /* 2. Spacing. */ score[score_spacing] = pfs->params.proportional_spacing == fp->params.proportional_spacing; /* 3. Pitch. */ /* Need to score this so that (1) exact match is highest, (2) any * higher-than-requested pitch is better than any lower-than- * requested pitch, (3) within these categories, nearer is better. */ if ( pfs->params.proportional_spacing ) score[score_pitch] = 0; /* should not influence score */ else { /* fixed space selection */ if ( fp->params.proportional_spacing ) /* scalable; match is worst possible */ score[score_pitch] = 0; else { int delta = pl_fp_pitch_per_inch_x100(&fp->params) - pl_fp_pitch_per_inch_x100(&pfs->params); /* If within one unit, call it exact; otherwise give * preference to higher pitch than requested. */ if (font_is_scalable_selection_wise(fp) || (abs(delta) <= 10 )) score[score_pitch] = 0x2000000; else if ( delta > 0 ) score[score_pitch] = 0x2000000 - delta; else score[score_pitch] = 0x1000000 + delta; } } /* 4. Height. */ /* Closest match scores highest (no preference for + or -). Otherwise * similar to pitch, and again, values assigned have no meaning out- * side this code. */ if ( font_is_scalable_selection_wise(fp) ) score[score_height] = 0x1000000; else { int delta = abs(pfs->params.height_4ths - fp->params.height_4ths); /* As before, allow one unit of error to appear "exact". */ if ( delta <= 1 ) delta = 0; score[score_height] = 0x1000000 - delta; } /* 5. Style. */ if ( pfs->params.style == fp->params.style ) score[score_style] = 2; else if ( fp->params.style == 0 && pfs->params.style != 0 ) score[score_style] = 1; /* prefer NO style fonts to wrong style */ else score[score_style] = 0; /* 6. Stroke Weight. */ /* If not exact match, prefer closest value away from 0 (more * extreme). If none, then prefer closest value nearer 0. Once * again, the actual values assigned here have no meaning outside * this chunk of code. */ { /* Worst cases (font value toward zero from request) 0..13. * Nearest more extreme: 14..21. 21 is exact. */ int fwt = fp->params.stroke_weight; int pwt = pfs->params.stroke_weight; int delta = pwt - fwt; /* With a little time, this could be collapsed. */ if ( pwt >= 0 ) if ( fwt >= pwt ) tscore = 21 + delta; else tscore = 14 - delta; else if ( fwt <= pwt ) tscore = 21 - delta; else tscore = 14 + delta; score[score_weight] = tscore; } /* 7. Typeface family. */ { uint diff = pfs->params.typeface_family - fp->params.typeface_family; if (diff == 0) score[score_typeface] = 2; else { diff = (pfs->params.typeface_family & 0x7ff) - (fp->params.typeface_family & 0x7ff); if (diff == 0) score[score_typeface] = 1; else score[score_typeface] = 0; } } /* 8. Location. */ /* Rearrange the value from "storage" into priority for us. We * only care that we get the priority sequence: soft-font, cartridge, * SIMM, and internal, and that we order at least 2 cartridges. (TRM * implies that SIMMs are *not* to be ordered.) Once again, values * assigned here have no external meaning. */ /* 1 bit at bottom for SIMM _vs_ internal, then cartridge-number * bits, then soft-font bit at top. */ if ( fp->storage & pcds_downloaded ) tscore = 1 << (pcds_cartridge_max + 1); else if ( fp->storage & pcds_all_cartridges ) tscore = (fp->storage & pcds_all_cartridges) >> (pcds_cartridge_shift - 1); else
static void install_support (PythonPlugin *lang_plugin) { IAnjutaLanguage* lang_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell, IAnjutaLanguage, NULL); IAnjutaSymbolManager* sym_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell, IAnjutaSymbolManager, NULL); IAnjutaDocumentManager* docman = anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell, IAnjutaDocumentManager, NULL); if (!lang_manager || !sym_manager || !docman) return; if (lang_plugin->support_installed) return; lang_plugin->current_language = ianjuta_language_get_name_from_editor (lang_manager, IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL); if (lang_plugin->current_language && (g_str_equal (lang_plugin->current_language, "Python"))) { g_signal_connect (lang_plugin->current_editor, "char-added", G_CALLBACK (on_editor_char_inserted_python), lang_plugin); } else { return; } python_indent_init (lang_plugin); /* Disable editor intern auto-indent */ ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(lang_plugin->current_editor), FALSE, NULL); if (IANJUTA_IS_EDITOR_ASSIST (lang_plugin->current_editor) ) { AnjutaPlugin *plugin; AnjutaUI *ui; IAnjutaEditorAssist* iassist; const gchar *project_root; gchar *editor_filename; check_support (lang_plugin); plugin = ANJUTA_PLUGIN (lang_plugin); ui = anjuta_shell_get_ui (plugin->shell, NULL); iassist = IANJUTA_EDITOR_ASSIST (lang_plugin->current_editor); g_assert (lang_plugin->assist == NULL); project_root = ANJUTA_PLUGIN_PYTHON(plugin)->project_root_directory; editor_filename = ANJUTA_PLUGIN_PYTHON(plugin)->current_editor_filename; lang_plugin->assist = python_assist_new (iassist, sym_manager, docman, lang_plugin->settings, editor_filename, project_root); } if (IANJUTA_IS_EDITOR_GLADE_SIGNAL (lang_plugin->current_editor)) { g_signal_connect (lang_plugin->current_editor, "drop-possible", G_CALLBACK (gtk_true), NULL); g_signal_connect (lang_plugin->current_editor, "drop", G_CALLBACK (on_glade_drop), lang_plugin); } lang_plugin->support_installed = TRUE; }