Beispiel #1
0
/**
 * \brief Computes the size of a glyph.
 * \param c The glyph from which we take the size.
 */
claw::math::coordinate_2d<unsigned int>
bear::visual::freetype_face::get_glyph_size( charset::char_type c ) const
{
  load_char( c );
  
  return claw::math::coordinate_2d<unsigned int>
    ( m_face->glyph->bitmap.width, m_face->glyph->bitmap.rows );
} // freetype_face::get_glyph_size()
Beispiel #2
0
 /* 
  * Find the char, if not online, load char up. Currently unused. If you can get this to work
  * for you, please send me an update!  Where you get_player_vis in do_clan, substitute this
  * and theoretically you can do anything with the victim offline.
  * Theoretically.  Can also be used in cedit when saving the clan to set leader
  * at clan creation/edit.
  */
 struct char_data *find_clan_char( struct char_data *ch, char *arg )
 {
   struct char_data *vict = NULL, *cbuf = NULL;
 
   if (!(vict = get_player_vis(ch, arg, FIND_CHAR_WORLD))) {
     /* we need to load the file up :( */
    CREATE(cbuf, struct char_data, 1);
     clear_char(cbuf);
     if (load_char(arg, vict) > -1) {
       vict = cbuf;
     }
   }
Beispiel #3
0
int main(int argc, char **argv) {
  uint8_t chararray[2] = { 99, 100 };
  union TIFF_value tv;
  struct Value v;
  /* 1 */
  tv.UChar = 99;
  store(&v, tiff_char,tv);
  if(load_char(&v) != 99) return 1;
  /* 2 */
  tv.UCharArray = &chararray[0];
  store(&v, tiff_chars, tv);
  if(load_char_array(&v)[1] != 100) return 1;
  return 0;
}
Beispiel #4
0
ae::RawModel* ae::load_line(const std::string &line)
{
	std::unique_ptr< ae::RawModel > model{ new RawModel };
	int index_count = 0;

	// Move the next char a bit to the right so they won't stack
	int pos = 0;
	for( char c : line )
	{
		int highest = 0;

		if( c != ' ' )
		{
			std::pair<std::vector< math::vec3 >, std::vector< GLushort > > character = load_char( c );

			//Get the highest index of the current letter so the number can be added to the next, we need continous numbers
			for ( size_t var = 0; var < character.second.size(); ++var) {
				highest = ( highest > character.second[ var ] ) ? highest : character.second[ var ];
			}

			for ( size_t i = 0; i < character.second.size(); ++i )
			{
				character.second[ i ] += index_count;
			}

			if( index_count != 0 )
			{
				for ( size_t var = 0; var < character.first.size(); ++var ) {
					character.first[ var ] += math::vec3{ 0.13f * pos , 0.0f, 0.0f };
				}
			}

			model.get()->vertices.insert( model.get()->vertices.end(), character.first.begin(), character.first.end() );
			model.get()->indices.insert( model.get()->indices.end(), character.second.begin(), character.second.end() );

			index_count += highest + 1;
			pos++;
		}
		else
		{
			pos +=1;
		}
	}

	return model.release();
}
Beispiel #5
0
int main(int argc, char const *argv[])
{
	char* source = "わたしわ阿飞, and my English name is Rex Lee. 网名是独孤影! ^_^。下面是一段多音分词歧义测试,这个人无伤无臭味磕头如捣蒜。";
	// char* source = "hello world, here is an English string to test buffer transfer. thank you.";
	char* pinyin = 0;

    PinTable dict;
	pinyin_init(&dict);

	pinyin_set_locale("zh_CN.UTF-8");

//    load_char("/root/pinyin-php/data/chars.csv", &dict);
    load_word("../data/words.csv", &dict);
    load_char("../data/chars.csv", &dict);

    
    printf("[source] \n%s\n\n", source);
	printf("[transl] \n");
	pinyin = pinyin_translate(source, &dict);

	printf("%s\n", pinyin);
	free_buffer(pinyin);

    
  //  HashNode* r = ht_lookup(&dict, "下");
  //  printf("[L]%d\n", dict.ht_size);
  //  printf("t[%s]\n", r->nValue);

  //  ht_print(&dict);

	//  char buf[256]={"わたしわ阿飞, and"};
	//	setlocale(LC_ALL,"zh_CN.UTF-8");
	//	wchar_t ar[256]={'\0'};
	//	int read = mbstowcs(ar,buf,strlen(buf)); 
	//	printf("%lu\n",strlen(buf)); //输出为:9 [字节] UF-8编码下一个汉字占三个字节3*3=9
	//	printf("%d\n",read); //输出为:3 [个数] “你好啊”三个子字个数

	return 0;
}
Beispiel #6
0
/* Returns TRUE if this character name would be acceptable for a
 * new player.
 * Returns FALSE if it fails any checks, including being an
 * already existing character or mob, an illegal name, banned, etc.
 */
int acceptable_name(const char *name)
{
    char                                    tmp_name[20] = "\0\0\0";
    struct char_file_u                      tmp_store;
    struct char_data                        tmp_char;

    if (!valid_parse_name(name, tmp_name))
	return FALSE;
    if (check_playing(NULL, tmp_name))
	return FALSE;
    /*
     * We don't check ValidPlayer here 
     */
    if (fread_char(tmp_name, &tmp_store, &tmp_char) > -1)
	return FALSE;
    if (load_char(tmp_name, &tmp_store) > -1)
	return FALSE;
    if (already_mob_name(tmp_name))
	return FALSE;
    if (banned_name(tmp_name))
	return FALSE;

    return TRUE;
}
Beispiel #7
0
// лоад списка неодобренных имен
void NewNameLoad()
{
	std::ifstream file(NNAME_FILE);
	if (!file.is_open())
	{
		log("Error open file: %s! (%s %s %d)", NNAME_FILE, __FILE__, __func__, __LINE__);
		return;
	}

	std::string buffer;
	while (file >> buffer)
	{
		// сразу проверяем не сделетился ли уже персонаж
		Player t_tch;
		Player *tch = &t_tch;
		if (load_char(buffer.c_str(), tch) < 0)
			continue;
		// не сделетился...
		NewNameAdd(tch, 0);
	}

	file.close();
	NewNameSave();
}
GlyphToType3::GlyphToType3(TTStreamWriter& stream, struct TTFONT *font, int charindex, bool embedded /* = false */)
{
    BYTE *glyph;

    tt_flags = NULL;
    xcoor = NULL;
    ycoor = NULL;
    epts_ctr = NULL;
    area_ctr = NULL;
    check_ctr = NULL;
    ctrset = NULL;
    stack_depth = 0;
    pdf_mode = font->target_type < 0;

    /* Get a pointer to the data. */
    glyph = find_glyph_data( font, charindex );

    /* If the character is blank, it has no bounding box, */
    /* otherwise read the bounding box. */
    if ( glyph == (BYTE*)NULL )
    {
        llx=lly=urx=ury=0;      /* A blank char has an all zero BoundingBox */
        num_ctr=0;              /* Set this for later if()s */
    }
    else
    {
        /* Read the number of contours. */
        num_ctr = getSHORT(glyph);

        /* Read PostScript bounding box. */
        llx = getFWord(glyph + 2);
        lly = getFWord(glyph + 4);
        urx = getFWord(glyph + 6);
        ury = getFWord(glyph + 8);

        /* Advance the pointer. */
        glyph += 10;
    }

    /* If it is a simple character, load its data. */
    if (num_ctr > 0)
    {
        load_char(font, glyph);
    }
    else
    {
        num_pts=0;
    }

    /* Consult the horizontal metrics table to determine */
    /* the character width. */
    if ( charindex < font->numberOfHMetrics )
    {
        advance_width = getuFWord( font->hmtx_table + (charindex * 4) );
    }
    else
    {
        advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) );
    }

    /* Execute setcachedevice in order to inform the font machinery */
    /* of the character bounding box and advance width. */
    stack(stream, 7);
    if (pdf_mode)
    {
        if (!embedded) {
            stream.printf("%d 0 %d %d %d %d d1\n",
                          topost(advance_width),
                          topost(llx), topost(lly), topost(urx), topost(ury) );
        }
    }
    else if (font->target_type == PS_TYPE_42_3_HYBRID)
    {
        stream.printf("pop gsave .001 .001 scale %d 0 %d %d %d %d setcachedevice\n",
                      topost(advance_width),
                      topost(llx), topost(lly), topost(urx), topost(ury) );
    }
    else
    {
        stream.printf("%d 0 %d %d %d %d _sc\n",
                      topost(advance_width),
                      topost(llx), topost(lly), topost(urx), topost(ury) );
    }

    /* If it is a simple glyph, convert it, */
    /* otherwise, close the stack business. */
    if ( num_ctr > 0 )          /* simple */
    {
        PSConvert(stream);
    }
    else if ( num_ctr < 0 )     /* composite */
    {
        do_composite(stream, font, glyph);
    }

    if (font->target_type == PS_TYPE_42_3_HYBRID)
    {
        stream.printf("\ngrestore\n");
    }

    stack_end(stream);
}
Beispiel #9
0
/*read the data contain in the file
*/
int32_t macsim_read(GenericReader_T* genreader,glu_item_t* item)
{
	char  	      data_var[LG_MAX_STRING_MACSIM];
	uint32_t      indice_data=0,
	              rep=EOF,
	              dimension=0;
	uint8_t       continuer=1;
	

	TSP_sample_symbol_info_list_t  ssi_list;

	ssi_list=*genreader->ssi_list;

	
	if(NULL!=genreader->handler->file)
	{

	  /*TYPE_CHAR or TYPE_UCHAR is a  string of  LG_MAX_STRING_MACSIM length */
	  if( (TSP_TYPE_CHAR==ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type)
	      || (TSP_TYPE_UCHAR==ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type) )
	  {
	    item->size=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension;
	    /*calculate the real dimension for the string symbol*/
	    dimension=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension/LG_MAX_STRING_MACSIM;
	  }
	  else
	  {
	    item->size=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension;
	    dimension=ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].dimension;
	      
	  }
	  
	  item->size*=tsp_type_size[ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type];

	    
	  while( continuer  && 
                (indice_data<dimension))
	  {

	    memset(data_var,'\0',LG_MAX_STRING_MACSIM);

	    /*read one data of the file*/
	    rep=read_data_file(genreader->handler->file,data_var);
              
	    if(EOF!=rep)
	    {
	      /*end of line*/
	      if(END_SAMPLE_SET==rep)
	      {
		continuer=0;
	      }

	      /*load retrieve data in the raw value*/
	      switch(ssi_list.TSP_sample_symbol_info_list_t_val[item->provider_global_index].type) 
	      {

	        case TSP_TYPE_DOUBLE :
		  load_double(data_var,item->raw_value,indice_data);
		  break;
				       
	        case TSP_TYPE_FLOAT :
		  load_float(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_INT8 :
		  load_int8(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_INT16:
		  load_int16(data_var,item->raw_value,indice_data);
		  break;

	        case TSP_TYPE_INT32 :
		  load_int32(data_var,item->raw_value,indice_data);
		  break;
      
	        case TSP_TYPE_INT64 :
		  load_int64(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT8:
		  load_uint8(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT16:
		  load_uint16(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT32:
		  load_uint32(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UINT64:
		  load_uint64(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_CHAR:
		  load_char(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_UCHAR:
		  load_uchar(data_var,item->raw_value,indice_data);
		  break;
    
	        case TSP_TYPE_RAW:
		  load_type_raw(data_var,item->raw_value,indice_data);
		  break;
    
	        default:
		  break;
	      }

	      ++indice_data;
	    
	    }
	    else
	    {
	      continuer=0;
	    }

	  }
   
	}
         return(rep);
}