int wxArchive::LoadInt()
{
	wxUint8 intsize = 0;
	int tmpval = 0;

	if(CanLoad())
	{
		// get size
		intsize = LoadChar();
		switch(intsize)
		{
		case 1:	// 8 bits
			tmpval = (int)LoadChar();
			break;
		case 2:	// 16 bits
			tmpval = (int)LoadUint16();
			break;
		case 4:	// 32 bits
			tmpval = (int)LoadUint32();
			break;
		case 8:	// 64 bits
			tmpval = (int)LoadUint64();
			break;

		default:
			LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_RINTSIZE);
			break;
		}
	}

	return tmpval;
}
void wxArchive::FindCurrentEnterLevel()
{
	// the next read should be the begin marker. If not, we search for the
	// begin marker

	if(m_haveBoundary && m_lastBoundary == wxARCHIVE_HDR_ENTER)
	{
		m_haveBoundary = false;
		return;
	}

	wxUint8 hdr = LoadChar();	// we do not care about the header
	while(IsOk() && hdr != wxARCHIVE_HDR_ENTER)
	{
		// here we have data loss, as we need to look for our marker
		m_status.SetNewDataLoss();

		// we should find the enter level, not leave
		if(hdr == wxARCHIVE_HDR_LEAVE)
			LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_ILL_LEAVE);

		SkipData(hdr);
		hdr = LoadChar();
	}
}
Exemple #3
0
static void LoadConstants(LoadState* S, Proto* f)
{
 int i,n;
 n=LoadInt(S);
 f->k=luaM_newvector(S->L,n,TValue);
 f->sizek=n;
 for (i=0; i<n; i++) setnilvalue(&f->k[i]);
 for (i=0; i<n; i++)
 {
  TValue* o=&f->k[i];
  int t=LoadChar(S);
  switch (t)
  {
   case LUA_TNIL:
	setnilvalue(o);
	break;
   case LUA_TBOOLEAN:
	setbvalue(o,LoadChar(S));
	break;
   case LUA_TNUMBER:
	setnvalue(o,LoadNumber(S));
	break;
   case LUA_TSTRING:
	setsvalue2n(S->L,o,LoadString(S));
	break;
  }
 }
 n=LoadInt(S);
 f->p=luaM_newvector(S->L,n,Proto*);
 f->sizep=n;
 for (i=0; i<n; i++) f->p[i]=NULL;
 for (i=0; i<n; i++) f->p[i]=LoadFunction(S);
}
static void LoadUpvalues(LoadState* S, Proto* f)
{
 int i,n;
 n=LoadInt(S);
 f->upvalues=luaM_newvector(S->L,n,Upvaldesc);
 f->sizeupvalues=n;
 for (i=0; i<n; i++) f->upvalues[i].name=NULL;
 for (i=0; i<n; i++)
 {
  f->upvalues[i].instack=LoadChar(S);
  f->upvalues[i].idx=LoadChar(S);
 }
}
Exemple #5
0
static void LoadConstants(LoadState* S, Proto* f)
{
 int i,n;
#if LUA_REFCOUNT    
 lua_State *L = S->L;
#endif /* LUA_REFCOUNT */
 n=LoadInt(S);
 f->k=luaM_newvector(S->L,n,TValue);
 f->sizek=n;
#if LUA_REFCOUNT
 for (i=0; i<n; i++) setnilvalue2n(L, &f->k[i]);
#else
 for (i=0; i<n; i++) setnilvalue(&f->k[i]);
#endif /* LUA_REFCOUNT */
 for (i=0; i<n; i++)
 {
  TValue* o=&f->k[i];
  int t=LoadChar(S);
  switch (t)
  {
   case LUA_TNIL:
   	setnilvalue(o);
	break;
   case LUA_TBOOLEAN:
   	setbvalue(o,LoadChar(S)!=0);
	break;
   case LUA_TNUMBER:
	setnvalue(o,LoadNumber(S));
	break;
   case LUA_TSTRING:
	setsvalue2n(S->L,o,LoadString(S));
	break;
   default:
	error(S,"bad constant");
	break;
  }
 }
 n=LoadInt(S);
 f->p=luaM_newvector(S->L,n,Proto*);
 f->sizep=n;
 for (i=0; i<n; i++) f->p[i]=NULL;
#if LUA_REFCOUNT
 for (i=0; i<n; i++) {
  f->p[i]=LoadFunction(S,f->source);
  luarc_addrefproto(f->p[i]);
 }
#else
 for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
#endif /* LUA_REFCOUNT */
}
Exemple #6
0
static void TH135LoadProfile()
{
#define LoadAddress(N) { TCHAR addrStr[16]; \
	s_##N = profile.ReadString(_T("Address"), _T(#N), _T(""), addrStr, sizeof addrStr); \
	if (!::StrToIntEx(addrStr, STIF_SUPPORT_HEX, reinterpret_cast<int *>(&s_##N))) s_##N = Default_##N;  }
#define LoadChar(N) profile.ReadString(_T("TH135"), _T(#N), Default_##N, s_##N, sizeof s_##N)

	Minimal::ProcessHeapPath profPath = g_appPath;
	CProfileIO profile(profPath /= _T("TH135Addr.ini"));
	LoadChar(WindowClass);
	LoadChar(WindowCaption);

	LoadAddress(CoreBase);
}
Exemple #7
0
/* kpchen said, record is the index array of interval */
static void OutputRecordStr(
		ChewingData *pgdata,
		char *out_buf, int out_buf_len,
		int *record, int nRecord, 
		uint16_t phoneSeq[], int nPhoneSeq,
		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
		IntervalType selectInterval[],
		int nSelect, TreeDataType *ptd )
{
	PhraseIntervalType inter;
	int i;

	LoadChar( pgdata, out_buf, out_buf_len, phoneSeq, nPhoneSeq );
	for ( i = 0; i < nRecord; i++ ) {
		inter = ptd->interval[ record[ i ] ];
		ueStrNCpy(
				ueStrSeek( out_buf, inter.from ),
				( inter.p_phr )->phrase,
				( inter.to - inter.from ), -1);
	}
	for ( i = 0; i < nSelect; i++ ) {
		inter.from = selectInterval[ i ].from;
		inter.to = selectInterval[ i ].to ;
		ueStrNCpy(
				ueStrSeek( out_buf, inter.from ),
				selectStr[ i ], ( inter.to - inter.from ), -1);
	}
}
	void GlyphFont::TextSize(const char* pText, SDL_Rect* pRect)
	{
		int maxX = 0;
		int advance = 0;

		pRect->x = 0;
		pRect->y = 0;
		pRect->w = 0;
		pRect->h = mHeight;

		while(*pText != 0)
		{
			if(sMinGlyph <= *pText && *pText <= sMaxGlyph)
			{
				LoadChar(*pText);

				maxX = mGlyphs[((int)*pText)].MaxX;
				advance = mGlyphs[((int)*pText)].Advance;

				pRect->w += advance;
			}

			pText++;
		}

		pRect->w = pRect->w - advance + maxX;
	}
int wxArchive::LoadChunkHeader(int expheader)
{
	int hdr = 0;

    if(CanLoad())
	{
		if(m_haveBoundary)
			return 0;

		hdr = (int)LoadChar();
		if(hdr == wxARCHIVE_HDR_ENTER || hdr == wxARCHIVE_HDR_LEAVE)
		{
			// remember this state
			m_lastBoundary = hdr;
			m_haveBoundary = true;
			return 0;
		}

        // when header is not ok
        if(hdr != expheader)
        {
        	LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_WRONGCHUNK_s1_s2,
        	         GetHeaderName(expheader), GetHeaderName(hdr));
        	return -1;
        }
    }

    return hdr;
}
Exemple #10
0
  static FT_Error
  Render_All( int  first_glyph,
              int  pt_size )
  {
    FT_F26Dot6  start_x, start_y, step_y, x, y;
    int         i;


    start_x = 4;
    start_y = 36 + pt_size;

    step_y = size->metrics.y_ppem + 10;

    x = start_x;
    y = start_y;

    i = first_glyph;

#if 0
     while ( i < first_glyph + 1 )
#else
     while ( i < num_glyphs )
#endif
    {
      if ( !( error = LoadChar( i, hinted ) ) )
      {
#ifdef DEBUG
        if ( i <= first_glyph + 6 )
        {
          LOG(( "metrics[%02d] = [%x %x]\n",
                i,
                glyph->metrics.horiBearingX,
                glyph->metrics.horiAdvance ));

          if ( i == first_glyph + 6 )
            LOG(( "-------------------------\n" ));
        }
#endif

        Render_Glyph( x, y );

        x += ( glyph->metrics.horiAdvance >> 6 ) + 1;

        if ( x + size->metrics.x_ppem > bit.width )
        {
          x  = start_x;
          y += step_y;

          if ( y >= bit.rows )
            return FT_Err_Ok;
        }
      }
      else
        Fail++;

      i++;
    }
	void GlyphFont::DrawText(const char* pText, int pX, int pY)
	{
		GLfloat left;
		GLfloat right;
		GLfloat top;
		GLfloat bottom;
		GLfloat texMinX;
		GLfloat texMinY;
		GLfloat texMaxX;
		GLfloat texMaxY;
		int baseleft = pX;

		glPushAttrib(GL_ALL_ATTRIB_BITS);

		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		glEnable(GL_TEXTURE_2D);
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	
		while(*pText != 0)
		{
			if(*pText == '\n')
			{
				pX = baseleft;
				pY += mLineSkip;
			}
			else if(sMinGlyph <= *pText && *pText <= sMaxGlyph)
			{
				LoadChar(*pText);

				texMinX = mGlyphs[((int)*pText)].TexMinX;
				texMinY = mGlyphs[((int)*pText)].TexMinY;
				texMaxX = mGlyphs[((int)*pText)].TexMaxX;
				texMaxY = mGlyphs[((int)*pText)].TexMaxY;

				left   = (GLfloat)pX;
				right  = (GLfloat)(pX + mGlyphs[((int)*pText)].Surface->w);
				top    = (GLfloat)pY;
				bottom = (GLfloat)(pY + mGlyphs[((int)*pText)].Surface->h);

				glBindTexture(GL_TEXTURE_2D, mGlyphs[((int)*pText)].Texture);
				glBegin(GL_TRIANGLE_STRIP);
				glTexCoord2f(texMinX, texMinY); glVertex2f( left,    top);
				glTexCoord2f(texMaxX, texMinY); glVertex2f(right,    top);
				glTexCoord2f(texMinX, texMaxY); glVertex2f( left, bottom);
				glTexCoord2f(texMaxX, texMaxY); glVertex2f(right, bottom);
				glEnd();

				pX += mGlyphs[((int)*pText)].Advance;
			}

			pText++;
		}

		glPopAttrib();
	}
void wxArchive::SkipData(wxUint8 hdr)
{
	switch(hdr)
	{
	case wxARCHIVE_HDR_BOOL:
		LoadBool();
		break;

	case wxARCHIVE_HDR_INT8:
		LoadChar();
		break;

	case wxARCHIVE_HDR_INT16:
		LoadUint16();
		break;

	case wxARCHIVE_HDR_INT32:
		LoadUint32();
		break;

	case wxARCHIVE_HDR_INT64:
		LoadUint64();
		break;

	case wxARCHIVE_HDR_DOUBLE:
		LoadDouble();
		break;

	case wxARCHIVE_HDR_STRING:
		LoadString();
		break;

	case wxARCHIVE_HDR_ARRSTRING:
		LoadArrayString();
		break;

	case wxARCHIVE_HDR_RECORD:
		{
			wxCharBuffer buf;
			Load(buf);
		}
		break;

	case wxARCHIVE_HDR_INT:
		LoadInt();
		break;

	case wxARCHIVE_HDR_ENTER:
		break;

	case wxARCHIVE_HDR_LEAVE:
		break;
	default:
		LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_ILL_UNKNOWN_HDR_s1, GetHeaderName(hdr));
		break;
	}
}
int CPDF_Type3Font::GetCharWidthF(uint32_t charcode, int level) {
  if (charcode >= FX_ArraySize(m_CharWidthL))
    charcode = 0;

  if (m_CharWidthL[charcode])
    return m_CharWidthL[charcode];

  const CPDF_Type3Char* pChar = LoadChar(charcode, level);
  return pChar ? pChar->m_Width : 0;
}
Exemple #14
0
static void LoadConstants(LoadState* S, Proto* f)
{
 int i,n;
 n=LoadInt(S);
 f->k=luaM_newvector(S->L,n,TValue);
 f->sizek=n;
 for (i=0; i<n; i++) setnilvalue(&f->k[i]);
 for (i=0; i<n; i++)
 {
  TValue* o=&f->k[i];
  int t=LoadChar(S);
  switch (t)
  {
   case LUA_TNIL:
   	setnilvalue(o);
	break;
   case LUA_TBOOLEAN:
   	setbvalue(o,LoadChar(S)!=0);
	break;
   case LUA_TNUMBER:
	setnvalue(o,LoadNumber(S));
	break;
#ifdef LUA_TINT
   case LUA_TINT:   /* Integer type saved in bytecode (see lcode.c) */
	setivalue(o,LoadInteger(S));
	break;
#endif
   case LUA_TSTRING:
	setsvalue2n(S->L,o,LoadString(S));
	break;
   default:
	error(S,"bad constant");
	break;
  }
 }
 n=LoadInt(S);
 f->p=luaM_newvector(S->L,n,Proto*);
 f->sizep=n;
 for (i=0; i<n; i++) f->p[i]=NULL;
 for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
}
void wxArchive::FindCurrentLeaveLevel()
{
	bool firstHdr = true;
	unsigned char hdr = 0;
	// the next read should be the leave marker. If not, we search for the
	// leave marker that belongs to our current state (this means skipping
	// data that we cannot read, and potential enter and leave markers
	// that we do not read anyway

	int foundLevel = 1;
	if(m_haveBoundary)
	{
		// reset the boundary scan
		m_haveBoundary = false;

		// determine what to do
		if(m_lastBoundary == wxARCHIVE_HDR_ENTER)
			foundLevel++;
		else if(m_lastBoundary == wxARCHIVE_HDR_LEAVE)
			return;
	}

	while(IsOk() && foundLevel > 0)
	{
		if(hdr == wxARCHIVE_HDR_ENTER)
			foundLevel++;
		else if(hdr == wxARCHIVE_HDR_LEAVE)
		{
			foundLevel--;
			if(foundLevel < 0)
			{
				LogError(wxARCHIVE_ERR_ILL, wxARCHIVE_ERR_STR_ILL_LEAVE);
				return;
			}
		}

		if(foundLevel > 0)
		{
			hdr = LoadChar();

			// here we have data loss, as we need to look for our marker
			// the first header should have been the proper marker (if in sync)
			if(!firstHdr)
				m_status.SetNewDataLoss();

			SkipData(hdr);
		}

		firstHdr = false;
	}
}
bool wxArchive::LoadBool()
{
	bool value = false;
	wxUint8 chr;

	if(CanLoad())
	{
		chr = LoadChar();
		if(IsOk())
		    value = (chr != 0);
	}

	return value;
}
bool wxArchive::ReadUint8(wxUint8& value)
{
    // load integer value
    if(LoadChunkHeader(wxARCHIVE_HDR_INT8))
    {
        wxUint8 tmpvalue = LoadChar();

		if(IsOk())
		{
            value = tmpvalue;
			return true;
		}
    }

    return false;
}
Exemple #18
0
void Font::TextSize( std::string text, SDL_Rect *r )
{
	if( ! Initialized )
		return;
	
	int advance = 0;
	int w_largest = 0;
	char lastchar = 0;
	
	r->x = 0;
	r->y = 0;
	r->w = 0;
	r->h = Height;
	
	const char *text_ptr = text.c_str();
	while( *text_ptr != '\0' )
	{
		lastchar = *text_ptr;
		if( *text_ptr == '\n' )
		{
			r->h += LineSkip;
			if( r->w > w_largest )
				w_largest = r->w;
			r->w = 0;
		}
		else
		{
			LoadChar( *text_ptr );
			
			advance = Glyphs[ (unsigned char) *text_ptr ].Advance;
			r->w += advance;
		}
		
		text_ptr ++;
	}
	
	if( lastchar != '\n' )
	{
		if( r->w > w_largest )
			w_largest = r->w;
	}
	else
		r->h -= LineSkip;
	
	if( w_largest > r->w )
		r->w = w_largest;
}
Exemple #19
0
int Font::LineWidth( std::string text )
{
	if( ! Initialized )
		return 0;
	
	int w = 0;
	
	const char *text_ptr = text.c_str();
	while( (*text_ptr != '\0') && (*text_ptr != '\n') )
	{
		LoadChar( *text_ptr );
		w += Glyphs[ (unsigned char) *text_ptr ].Advance;
		text_ptr ++;
	}
	
	return w;
}
Exemple #20
0
void Font::DrawText( std::string text, int x, int y, uint8_t align, float r, float g, float b, float a )
{
	if( ! Initialized )
		return;
	
	if( LoadedTime.ElapsedSeconds() > Raptor::Game->Res.ResetTime.ElapsedSeconds() )
		InitFont();
	
	// Adjust for text vertical alignment.
	int text_height = TextHeight( text );
	switch( align )
	{
		case ALIGN_MIDDLE_LEFT:
		case ALIGN_MIDDLE_CENTER:
		case ALIGN_MIDDLE_RIGHT:
			y -= text_height / 2;
			break;
		case ALIGN_BASELINE_LEFT:
		case ALIGN_BASELINE_CENTER:
		case ALIGN_BASELINE_RIGHT:
			y -= Ascent;
			break;
		case ALIGN_BOTTOM_LEFT:
		case ALIGN_BOTTOM_CENTER:
		case ALIGN_BOTTOM_RIGHT:
			y -= text_height;
			break;
	}
	
	GLfloat left = 0.0f, right = 0.0f;
	GLfloat top = 0.0f, bottom = 0.0f;
	GLfloat tex_min_x = 0.0f, tex_min_y = 0.0f;
	GLfloat tex_max_x = 0.0f, tex_max_y = 0.0f;
	GLfloat min_x = 0.0f;
	GLfloat base_left = x;
	
	glPushAttrib( GL_ALL_ATTRIB_BITS );
	
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	
	glEnable( GL_TEXTURE_2D );
	glColor4f( r, g, b, a );
	
	// Adjust for text horizontal alignment.
	int line_width = LineWidth( text );
	switch( align )
	{
		case ALIGN_TOP_CENTER:
		case ALIGN_MIDDLE_CENTER:
		case ALIGN_BASELINE_CENTER:
		case ALIGN_BOTTOM_CENTER:
			x -= line_width / 2;
			break;
		case ALIGN_TOP_RIGHT:
		case ALIGN_MIDDLE_RIGHT:
		case ALIGN_BASELINE_RIGHT:
		case ALIGN_BOTTOM_RIGHT:
			x -= line_width;
			break;
	}
	
	const char *text_ptr = text.c_str();
	while( *text_ptr != '\0' )
	{
		if( *text_ptr == '\n' )
		{
			x = base_left;
			y += LineSkip;
			
			// Adjust for text horizontal alignment.
			line_width = LineWidth( text_ptr + 1 );
			switch( align )
			{
				case ALIGN_TOP_CENTER:
				case ALIGN_MIDDLE_CENTER:
				case ALIGN_BASELINE_CENTER:
				case ALIGN_BOTTOM_CENTER:
					x -= line_width / 2;
					break;
				case ALIGN_TOP_RIGHT:
				case ALIGN_MIDDLE_RIGHT:
				case ALIGN_BASELINE_RIGHT:
				case ALIGN_BOTTOM_RIGHT:
					x -= line_width;
					break;
			}
		}
		else
		{
			LoadChar( *text_ptr );
			
			tex_min_x = Glyphs[ (unsigned char) *text_ptr ].TexMinX;
			tex_min_y = Glyphs[ (unsigned char) *text_ptr ].TexMinY;
			tex_max_x = Glyphs[ (unsigned char) *text_ptr ].TexMaxX;
			tex_max_y = Glyphs[ (unsigned char) *text_ptr ].TexMaxY;
			
			min_x = Glyphs[ (unsigned char) *text_ptr ].MinX;
			
			left = x + min_x;
			right = x + Glyphs[ (unsigned char) *text_ptr ].Pic->w + min_x;
			top = y;
			bottom = y + Glyphs[ (unsigned char) *text_ptr ].Pic->h;
			
			glBindTexture( GL_TEXTURE_2D, Glyphs[ (unsigned char) *text_ptr ].Tex );
			
			glBegin( GL_QUADS );
				glTexCoord2f( tex_min_x, tex_min_y ); glVertex2f( left, top );
				glTexCoord2f( tex_max_x, tex_min_y ); glVertex2f( right, top );
				glTexCoord2f( tex_max_x, tex_max_y ); glVertex2f( right, bottom );
				glTexCoord2f( tex_min_x, tex_max_y ); glVertex2f( left, bottom );
			glEnd();
			
			x += Glyphs[ (unsigned char) *text_ptr ].Advance;
		}
		
		text_ptr ++;
	}
	
	glPopAttrib();
}
Exemple #21
0
WORD NEAR  LoadLine(PSTR line, int *lineLen, int nbLines)
{
    char prevCh = 0;
    register char ch;
    int level = NON_VALID_LEVEL;
    int extLineLen = 0;
    int totLen;

    *lineLen = 0;

    while (TRUE) {

        //Load next char, don't call LoadChar function to go faster

        if (dwOffsetDoc < dwBytesReadDoc) {
            ch = (char)pszBufferDoc[dwOffsetDoc++];
        } else  if (dwBytesReadDoc < DISK_BLOCK_SIZE) {
            ch = CTRL_Z;
        } else {
            if (!ReadFile(hFileDoc, pszBufferDoc, DISK_BLOCK_SIZE, 
                &dwBytesReadDoc, NULL)) {
                  
                return ERR_File_Read;

            } else {
                if (dwBytesReadDoc == 0) {
                    ch = CTRL_Z;
                } else {
                    ch = (char)pszBufferDoc[0];
                }
            }
            dwOffsetDoc = 1;
        }

        switch (ch) {
            
        case CR:
            break;
            
        case LF:
            if (*lineLen > MAX_USER_LINE) {
                if (TruncateLine(line, nbLines)) {
                    (*lineLen)--;
                } else {
                    return END_ABORT;
                }
            }
            return END_OF_LINE;



          case TAB:
            {
                int  i;

                //Calc number of spaces to insert

                totLen = extLineLen;

                i = g_contGlobalPreferences_WkSp.m_nTabSize - (totLen % g_contGlobalPreferences_WkSp.m_nTabSize);

                if (totLen + i >= MAX_USER_LINE) {
                    if (TruncateLine(line, nbLines)) {

                        char k;

                        //Padd blanks until end of line or remove char
                        (*lineLen)--;

                        //Discard rest of line from input file

                        do {
                            k = LoadChar();
                        } while (k != - 1 && k != CTRL_Z && k != LF);
                        switch (k) {
                          case -1:
                            return ERR_File_Read;
                          case LF:
                            return END_OF_LINE;
                          case CTRL_Z:
                            return END_OF_FILE;
                        }

                        return END_OF_LINE;

                    } else
                          return END_ABORT;
                }

                //Skip if we keep the tab

                extLineLen += i;
                goto defaut;

                //Insert spaces otherwise

                while (i--)
                    line[(*lineLen)++] = ' ';
                break;
            }

          case CTRL_Z:
            return END_OF_FILE;

          default:
          defaut:
            totLen = extLineLen;

            if (totLen > MAX_USER_LINE) {
                if (TruncateLine(line, nbLines)) {

                    char k;

                    (*lineLen)--;


                    //Discard rest of line from input file
                    do {
                        k = LoadChar();
                    } while (k != - 1 && k != CTRL_Z && k != LF);
                    switch (k) {
                      case -1:
                        return ERR_File_Read;
                      case LF:
                        return END_OF_LINE;
                      case CTRL_Z:
                        return END_OF_FILE;
                    }
                    return END_OF_LINE;


                } else
                    return END_ABORT;
             }
             line[(*lineLen)++] = (char)ch;
             extLineLen++;
         }
         prevCh = ch;
     }
}                                       /* LoadLine() */
FX_RECT CPDF_Type3Font::GetCharBBox(uint32_t charcode, int level) {
  const CPDF_Type3Char* pChar = LoadChar(charcode, level);
  return pChar ? pChar->m_BBox : FX_RECT();
}
Exemple #23
0
void Font::DrawText3D( std::string text, const Pos3D *pos, uint8_t align, float r, float g, float b, float a, double scale )
{
	if( ! Initialized )
		return;
	
	if( LoadedTime.ElapsedSeconds() > Raptor::Game->Res.ResetTime.ElapsedSeconds() )
		InitFont();
	
	GLdouble x = 0., y = 0.;
	Pos3D tl, tr, br, bl;
	
	// Adjust for text vertical alignment.
	int text_height = TextHeight( text );
	switch( align )
	{
		case ALIGN_MIDDLE_LEFT:
		case ALIGN_MIDDLE_CENTER:
		case ALIGN_MIDDLE_RIGHT:
			y -= text_height / 2;
			break;
		case ALIGN_BASELINE_LEFT:
		case ALIGN_BASELINE_CENTER:
		case ALIGN_BASELINE_RIGHT:
			y -= Ascent;
			break;
		case ALIGN_BOTTOM_LEFT:
		case ALIGN_BOTTOM_CENTER:
		case ALIGN_BOTTOM_RIGHT:
			y -= text_height;
			break;
	}
	
	GLdouble left = 0., right = 0.;
	GLdouble top = 0., bottom = 0.;
	GLfloat tex_min_x = 0.f, tex_min_y = 0.f;
	GLfloat tex_max_x = 0.f, tex_max_y = 0.f;
	GLdouble min_x = 0.;
	GLdouble base_left = x;
	
	glPushAttrib( GL_ALL_ATTRIB_BITS );
	
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	
	glEnable( GL_TEXTURE_2D );
	glColor4f( r, g, b, a );
	
	// Adjust for text horizontal alignment.
	int line_width = LineWidth( text );
	switch( align )
	{
		case ALIGN_TOP_CENTER:
		case ALIGN_MIDDLE_CENTER:
		case ALIGN_BASELINE_CENTER:
		case ALIGN_BOTTOM_CENTER:
			x -= line_width / 2;
			break;
		case ALIGN_TOP_RIGHT:
		case ALIGN_MIDDLE_RIGHT:
		case ALIGN_BASELINE_RIGHT:
		case ALIGN_BOTTOM_RIGHT:
			x -= line_width;
			break;
	}
	
	const char *text_ptr = text.c_str();
	while( *text_ptr != '\0' )
	{
		if( *text_ptr == '\n' )
		{
			x = base_left;
			y += LineSkip;
			
			// Adjust for text horizontal alignment.
			line_width = LineWidth( text_ptr + 1 );
			switch( align )
			{
				case ALIGN_TOP_CENTER:
				case ALIGN_MIDDLE_CENTER:
				case ALIGN_BASELINE_CENTER:
				case ALIGN_BOTTOM_CENTER:
					x -= line_width / 2;
					break;
				case ALIGN_TOP_RIGHT:
				case ALIGN_MIDDLE_RIGHT:
				case ALIGN_BASELINE_RIGHT:
				case ALIGN_BOTTOM_RIGHT:
					x -= line_width;
					break;
			}
		}
		else
		{
			LoadChar( *text_ptr );
			
			tex_min_x = Glyphs[ (unsigned char) *text_ptr ].TexMinX;
			tex_min_y = Glyphs[ (unsigned char) *text_ptr ].TexMinY;
			tex_max_x = Glyphs[ (unsigned char) *text_ptr ].TexMaxX;
			tex_max_y = Glyphs[ (unsigned char) *text_ptr ].TexMaxY;
			
			min_x = Glyphs[ (unsigned char) *text_ptr ].MinX;
			
			left = x + min_x;
			right = x + Glyphs[ (unsigned char) *text_ptr ].Pic->w + min_x;
			top = y;
			bottom = y + Glyphs[ (unsigned char) *text_ptr ].Pic->h;
			
			tl.Copy( pos );
			tl.MoveAlong( &(pos->Right), left * scale );
			tl.MoveAlong( &(pos->Up), -top * scale );
			tr.Copy( pos );
			tr.MoveAlong( &(pos->Right), right * scale );
			tr.MoveAlong( &(pos->Up), -top * scale );
			br.Copy( pos );
			br.MoveAlong( &(pos->Right), right * scale );
			br.MoveAlong( &(pos->Up), -bottom * scale );
			bl.Copy( pos );
			bl.MoveAlong( &(pos->Right), left * scale );
			bl.MoveAlong( &(pos->Up), -bottom * scale );
			
			glBindTexture( GL_TEXTURE_2D, Glyphs[ (unsigned char) *text_ptr ].Tex );
			
			glBegin( GL_QUADS );
				glTexCoord2f( tex_min_x, tex_min_y ); glVertex3d( tl.X, tl.Y, tl.Z );
				glTexCoord2f( tex_max_x, tex_min_y ); glVertex3d( tr.X, tr.Y, tr.Z );
				glTexCoord2f( tex_max_x, tex_max_y ); glVertex3d( br.X, br.Y, br.Z );
				glTexCoord2f( tex_min_x, tex_max_y ); glVertex3d( bl.X, bl.Y, bl.Z );
			glEnd();
			
			x += Glyphs[ (unsigned char) *text_ptr ].Advance;
		}
		
		text_ptr ++;
	}
	
	glPopAttrib();
}
Exemple #24
0
static void Align4(LoadState* S)
{
    while(S->total&3)
        LoadChar(S);
}