Beispiel #1
0
UINT32 thai_get_cell_size(UINT8  *pText)
{
	UINT16 lead_wc, follow_wc;
	UINT8 *pStr;
	UINT32 count = 0;

	do
	{
		pStr = pText + count;
		lead_wc = ComMB16ToWord(pStr);
		follow_wc = ComMB16ToWord(pStr+2);
		count += 2;
	}while(thai_get_rule(lead_wc,follow_wc)==CP);
	
	return count;   
}
Beispiel #2
0
UINT32 thai_get_cell(UINT8  *pText, struct thai_cell *cell)
{
	UINT16 wc;
	UINT8 *pStr;
	UINT32 count = 0;

	if(pText==NULL || cell==NULL)
		return 0;

	MEMSET(cell, 0, sizeof(struct thai_cell));
	
	pStr = pText + count;
	if((wc = ComMB16ToWord(pStr))==0)
		return 0;
	
	cell->unicode[cell->char_num++]= wc;

	count += 2;
	if((wc = ComMB16ToWord(pStr+count))==0)
		return count;
	
	if(thai_get_rule(cell->unicode[cell->char_num-1],wc)==CP)
	{
		cell->unicode[cell->char_num++]= wc;
		count += 2;
		if((wc = ComMB16ToWord(pStr+count))==0)
			return count;
		if(thai_get_rule(cell->unicode[cell->char_num-1],wc)==CP)
		{
			cell->unicode[cell->char_num++]= wc;
			count += 2;
		}
	}
	
	return count;   
}
Beispiel #3
0
UINT16 OSD_GetWordLen(UINT8* pText, UINT8 font,UINT16* wordwidth,UINT16* wordheight ,UINT16 width)
{
	UINT16 wc,wordlen = 0;
	UINT16 w,h,mh = 0,ww = 0;
	UINT32 cnt;
	UINT16 font_w = 0, font_h = 0;
	
	while( (wc = ComMB16ToWord(pText)) != 0)
	{
		if(IS_NEWLINE(wc))
		{
			*wordwidth = ww;
			*wordheight = mh;
			return wordlen;
		}
		else if((wc > 0x4e00 && wc < 0x9f45)||
			(wc > 0x3000 && wc < 0x303f)||  
			(wc > 0xff00 && wc < 0xffef)||              
			(wc > 0x2e80 && wc < 0x2eff))//chinese
		{
			if(font_w == 0)
			{
				font_w = 36;
				font_h = 36;
				OSD_GetCharWidthHeight(wc, font, &font_w, &font_h);
				//libc_printf("font_w = %d,font_h = %d\n",font_w,font_h);
			}
			ww += font_w;
			mh = font_h;
			wordlen += 1;
			pText += 2;
			break;
		}
		else if(IS_WORD_END(wc) && wordlen>0)
			break;
		w = 10;
		h = 0;
		cnt = 2;
		if(is_thai_unicode(wc))
		{
			struct thai_cell cell;

			cnt = thai_get_cell(pText, &cell);
			if(cnt == 0)
				break;

			OSD_GetThaiCellWidthHeight(&cell, font,&w,&h);
		}
		else
		{
			OSD_GetCharWidthHeight(wc ,font, &w, &h);
		}
		if(mh < h)
			mh = h;
		if((ww+w)<=width)
			ww += w;
		else
			break;
		wordlen += cnt/2;
		pText += cnt;

		if(IS_WORD_END(wc))
			break;
	}
	*wordwidth = ww;
	*wordheight = mh;

	return wordlen;
}
Beispiel #4
0
UINT16 OSD_GetTextTotalLine(UINT8* pText,UINT8 font,UINT16 width,
                              INT16 lineidx,UINT8**  lineStr, UINT8* linesheght)
{
	UINT16 l;
	UINT16 wc,wordlen;
	//UINT16 maxw,maxh;
	UINT16 chl;
	UINT16 wordw,wordh;
	UINT16 line = 0;

	if(pText==NULL)
	return 0;
    
	l = 0;
	chl = 0;
	wc = ComMB16ToWord(pText);
	while(wc!=0 && line<MAX_LINE_NUM)
	{       
		if(l==0 && line == lineidx  && lineStr!=NULL)
			*lineStr = pText;

		if(IS_NEWLINE(wc))
		{            
			if(chl== 0)
				chl = OSD_FONT_HEIGHT;
			if(linesheght != NULL)
				linesheght[line] = chl;
			line++;
			l = 0;
			chl = 0;
			pText += 2;
		}
		else
		{
			wordlen = OSD_GetWordLen(pText,font,&wordw,&wordh,width);
			if(wordlen > 0)
			{
				if(chl== 0)
					chl = wordh;

				/*If first char of the line is a space, ignore it.*/
				//                if(l == 0 && wordlen==1 && wc == ' ')
				//               {
				//                    pText += 2;
				//                }
				//                else if(l + wordw <= width || l == 0)
				if(l + wordw <= width || l == 0)
				{
					l += wordw;
					pText += wordlen*2;
				}
				else    /* Next line*/
				{
					if(chl < wordh)
						chl = wordh;
					if(chl== 0)
						chl = OSD_FONT_HEIGHT;
					if(linesheght != NULL)
						linesheght[line] = chl;
					line++;
					l = 0;
					chl = 0;
				}
			}
		}
        
		wc = ComMB16ToWord(pText);
		if(l !=0 && wc==0)
		{
			if(chl== 0)
				chl = OSD_FONT_HEIGHT;
			if(linesheght != NULL)
				linesheght[line] = chl;
			line++;
		}
	}
#ifdef BIDIRECTIONAL_OSD_STYLE
	lastLineWidth = l;
#endif
	return line;
}
Beispiel #5
0
UINT16 OSD_GetTextTotalLine(UINT8* pText,UINT8 font,UINT16 width,
                              INT16 lineidx,UINT8**  lineStr, UINT8* linesheght)
{
	UINT16 l,wc,wordlen,chl,wordw,wordh,line;

	l = 0;
	chl = 0;
	line = 0;
	if(pText==NULL)
		return 0;
    
	wc = ComMB16ToWord(pText);
	while(wc!=0 && line<MAX_LINE_NUM)
	{       
	    if(l==0 && line == lineidx  && lineStr!=NULL)
	        *lineStr = pText;
	    
	    if(IS_NEWLINE(wc))
	    {            
	        if(chl== 0)
	            chl = OSD_FONT_HEIGHT;
	        if(linesheght != NULL)
	            linesheght[line] = chl;
			
	        line++;
	        l = 0;
	        chl = 0;
	        pText += 2;
	    }
	    else
	    {
	        wordlen = OSD_GetWordLen(pText,font,&wordw,&wordh,width);
	        if(wordlen > 0)
	        {
	            if(chl== 0)
	                chl = wordh;

	            if(l + wordw <= width || l == 0)
	            {
	                l += wordw;
	                pText += wordlen*2;
	            }
	            else    /* Next line*/
	            {
	                if(chl < wordh)
	                    chl = wordh;
	                if(chl== 0)
	                    chl = OSD_FONT_HEIGHT;
	                if(linesheght != NULL)
	                    linesheght[line] = chl;
					
	                line++;
	                l = 0;
	                chl = 0;
	            }
	        }
	    }
	    
		wc = ComMB16ToWord(pText);
		if(l !=0 && wc==0)
		{//end of the multitext content
			if(chl== 0)
				chl = OSD_FONT_HEIGHT;
			
			linesheght[line] = chl;
			line++;
		}
	}

	return line;
}