⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tibetan-fc.c

📁 Pango is a library for layout and rendering of text, with an emphasis on internationalization. Pang
💻 C
📖 第 1 页 / 共 2 页
字号:
    { 1,  2,  4,  3,  8,  7,  9, 10, 14, 13, 17, 18, 19, 19, 20, 21, 21,}, /*  0 - ground state*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, /*  1 - exit state (or sign to the right of the syllable)*/    {-1, -1,  4,  3,  8,  7,  9, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /*  2 - Base consonant*/    {-1, -1,  5, -1,  8,  7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /*  3 - Tsa phru after base*/    {-1, -1,  4,  6,  8,  7,  9, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /*  4 - Subjoined consonant after base*/    {-1, -1,  5, -1,  8,  7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /*  5 - Subjoined consonant after tsa phru*/    {-1, -1, -1, -1,  8,  7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /*  6 - Tsa phru after subjoined consonant*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1,}, /*  7 - Pre Composed Sanskrit*/    {-1, -1, -1, -1, -1, -1, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /*  8 - A-chung*/    {-1, -1, -1, -1, -1, -1, -1, -1, 14, 13, 17, -1, 19, 19, -1, -1, -1,}, /*  9 - Halanta*/    {-1, -1, -1, -1, -1, -1, -1, 11, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 10 - below vowel 1*/    {-1, -1, -1, -1, -1, -1, -1, 12, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 11 - below vowel 2*/    {-1, -1, -1, -1, -1, -1, -1, -1, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 12 - below vowel 3*/    {-1, -1, -1, -1, -1, -1, -1, -1, 14, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 13 - Anusvara before vowel*/    {-1, -1, -1, -1, -1, -1, -1, -1, 15, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 14 - above vowel 1*/    {-1, -1, -1, -1, -1, -1, -1, -1, 16, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 15 - above vowel 2*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 16 - above vowel 3*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 19, 19, -1, -1, -1,}, /* 17 - Anusvara or Candrabindu after vowel*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1,}, /* 18 - Visarga*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, /* 19 - strss mark*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 21,}, /* 20 - digit*/    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, /* 21 - digit mark*/};enum property_flags{  abvf = 0x0001,  pref = 0x0002,  pstf = 0x0004,  blwf = 0x0008,  pres = 0x0010,  blws = 0x0020,  abvs = 0x0040,  psts = 0x0080,  clig = 0x0100,  dist = 0x0200,  blwm = 0x0400,  abvm = 0x0800,};enum properties{  blwf_p    = /*(blwf | blws | clig | dist | blwm)*/ (abvf | pref | pstf | pres | abvs | psts | abvm),  pstf_p    = /*(blwf | blws | pref | pres | pstf | psts | clig | dist | blwm)*/ (abvf | abvs | abvm),  abvf_p    = /*(abvf | abvs | clig | dist | abvm)*/ (pref | pstf | blwf | pres | blws | psts | blwm),  pref_p    = /*(pref | pres | clig | dist)*/ (abvf | pstf | blwf | blws | abvs | psts | blwm | abvm),  default_p = /*(pres | blws | clig | dist | abvm | blwm)*/ (pref | blwf |abvf | pstf | abvs | psts)};/* Below we define how a character in the input string is either in the tibetanCharClasses table * (in which case we get its type back), or an unknown object in which case we get _xx (CC_RESERVED) back */static TibetanCharClassget_char_class (gunichar ch){  if (ch < firstChar || ch > lastChar)    return CC_RESERVED;  return tibetanCharClasses[ch - firstChar];}/* Given an input string of characters and a location in which to start looking * calculate, using the state table, which one is the last character of the syllable * that starts in the starting position. */static glongfind_syllable (const gunichar *chars,	       glong           start,	       glong           char_count){  glong cursor = start;  gint8 state = 0;  TibetanCharClass charClass;  while (cursor < char_count)    {      charClass = get_char_class (chars[cursor]) & CF_CLASS_MASK;      state = tibetanStateTable[state][charClass];      if (state < 0)	break;      cursor += 1;    }  return cursor;}static const PangoOTFeatureMap gsub_features[] ={  {"ccmp", PANGO_OT_ALL_GLYPHS},  {"locl", PANGO_OT_ALL_GLYPHS},  {"blws", blws},  {"abvs", abvs},  {"psts", psts},  {"clig", clig},  {"calt", PANGO_OT_ALL_GLYPHS}};static const PangoOTFeatureMap gpos_features[] ={  {"dist", dist},  {"blwm", blwm},  {"abvm", abvm},  {"kern", PANGO_OT_ALL_GLYPHS},  {"mark", PANGO_OT_ALL_GLYPHS},  {"mkmk", PANGO_OT_ALL_GLYPHS}};static PangoGlyphget_index (PangoFcFont *fc_font, gunichar wc){  PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc);  if (!index)    index = PANGO_GET_UNKNOWN_GLYPH ( wc);  return index;}static voidtibetan_engine_shape (PangoEngineShape *engine,		    PangoFont        *font,		    const char       *text,		    int               length,		    const PangoAnalysis *analysis,		    PangoGlyphString *glyphs){  PangoFcFont *fc_font;  FT_Face face;  PangoOTRulesetDescription desc;  const PangoOTRuleset *ruleset;  PangoOTBuffer *buffer;  glong n_chars;  gunichar *wcs;  const char *p;  int i;  glong syllable;  TibetanCharClass charClass;  glong cursor = 0;  g_return_if_fail (font != NULL);  g_return_if_fail (text != NULL);  g_return_if_fail (length >= 0);  g_return_if_fail (analysis != NULL);  fc_font = PANGO_FC_FONT (font);  face = pango_fc_font_lock_face (fc_font);  if (!face)    return;  buffer = pango_ot_buffer_new (fc_font);  wcs = g_utf8_to_ucs4_fast (text, length, &n_chars);  p = text;  /* This loop only exits when we reach the end of a run, which may contain   * several syllables.   */  while (cursor < n_chars)    {      syllable = find_syllable (wcs, cursor, n_chars);      /* shall we add a dotted circle?      * If in the position in which the base should be (first char in the string) there is      * a character that has the Dotted circle flag (a character that cannot be a base)      * then write a dotted circle      */      if (get_char_class (wcs[cursor]) & CF_DOTTED_CIRCLE)	{	  pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_DOTTED_CIRCLE), default_p, p - text);	}      /* If it encounters a digit followed by number pre combining mark, then reorder the two characters      * coeng Ro if they are present      */      for (i = cursor; i < syllable; i += 1)	{	  charClass = get_char_class (wcs[i]);	  if ((charClass & CF_DIGIT )	      && ( get_char_class (wcs[i+1]) & CF_PREDIGIT))	   {			 pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_PRE_NUMBER_MARK), pref_p, p - text);			 p = g_utf8_next_char (p);			 pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pref_p, p - text);			       i += 1;	 } else {	  switch (charClass & CF_POS_MASK)	    {	      case CF_POS_ABOVE :			     pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), abvf_p, p - text);			     break;	      case CF_POS_AFTER :			     pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text);			     break;	      case CF_POS_BELOW :			     pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text);			     break;	      default:		   /* default - any other characters  */		  pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text);		  break;	    } /* switch */	   }	  p = g_utf8_next_char (p);	} /* for */      cursor = syllable; /* move the pointer to the start of next syllable */    } /* while */  desc.script = analysis->script;  desc.language = analysis->language;  desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features);  desc.static_gsub_features = gsub_features;  desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features);  desc.static_gpos_features = gpos_features;  /* TODO populate other_features from analysis->extra_attrs */  desc.n_other_features = 0;  desc.other_features = NULL;  ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc);  pango_ot_ruleset_substitute (ruleset, buffer);  pango_ot_ruleset_position (ruleset, buffer);  pango_ot_buffer_output (buffer, glyphs);  g_free (wcs);  pango_ot_buffer_destroy (buffer);  pango_fc_font_unlock_face (fc_font);}static voidtibetan_engine_fc_class_init (PangoEngineShapeClass *class){  class->script_shape = tibetan_engine_shape;}PANGO_ENGINE_SHAPE_DEFINE_TYPE (TibetanEngineFc, tibetan_engine_fc,				tibetan_engine_fc_class_init, NULL)voidPANGO_MODULE_ENTRY(init) (GTypeModule *module){  tibetan_engine_fc_register_type (module);}voidPANGO_MODULE_ENTRY(exit) (void){}voidPANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,			  int              *n_engines){  *engines = script_engines;  *n_engines = G_N_ELEMENTS (script_engines);}PangoEngine *PANGO_MODULE_ENTRY(create) (const char *id){  if (!strcmp (id, SCRIPT_ENGINE_NAME))    return g_object_new (tibetan_engine_fc_type, NULL);  else    return NULL;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -