本文整理汇总了C++中FT_Stream类的典型用法代码示例。如果您正苦于以下问题:C++ FT_Stream类的具体用法?C++ FT_Stream怎么用?C++ FT_Stream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FT_Stream类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FT_Stream_TryRead
FT_Stream_TryRead( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count )
{
FT_ULong read_bytes = 0;
if ( stream->pos >= stream->size )
goto Exit;
if ( stream->read )
read_bytes = stream->read( stream, stream->pos, buffer, count );
else
{
read_bytes = stream->size - stream->pos;
if ( read_bytes > count )
read_bytes = count;
FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );
}
stream->pos += read_bytes;
Exit:
return read_bytes;
}
示例2: FT_Stream_ReadChar
FT_Stream_ReadChar( FT_Stream stream,
FT_Error* error )
{
FT_Byte result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->read )
{
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
goto Fail;
}
else
{
if ( stream->pos < stream->size )
result = stream->base[stream->pos];
else
goto Fail;
}
stream->pos++;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadChar:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
}
示例3: FT_Stream_Seek
FT_Stream_Seek( FT_Stream stream,
FT_ULong pos )
{
FT_Error error = FT_Err_Ok;
if ( stream->read )
{
if ( stream->read( stream, pos, 0, 0 ) )
{
FT_ERROR(( "FT_Stream_Seek:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_THROW( Invalid_Stream_Operation );
}
}
/* note that seeking to the first position after the file is valid */
else if ( pos > stream->size )
{
FT_ERROR(( "FT_Stream_Seek:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_THROW( Invalid_Stream_Operation );
}
if ( !error )
stream->pos = pos;
return error;
}
示例4: FT_Stream_Close
FT_Stream_Close( FT_Stream stream )
{
if ( stream && stream->close )
{
stream->close( stream );
stream->close = NULL;
}
}
示例5: FT_Stream_EnterFrame
FT_Stream_EnterFrame( FT_Stream stream,
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
FT_ULong read_bytes;
/* check for nested frame access */
FT_ASSERT( stream && stream->cursor == 0 );
if ( stream->read )
{
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
if ( FT_QALLOC( stream->base, count ) )
goto Exit;
/* read it */
read_bytes = stream->read( stream, stream->pos,
stream->base, count );
if ( read_bytes < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:" ));
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
FT_FREE( stream->base );
error = FT_Err_Invalid_Stream_Operation;
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
stream->pos += read_bytes;
}
else
{
/* check current and new position */
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
{
FT_ERROR(( "FT_Stream_EnterFrame:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
goto Exit;
}
/* set cursor */
stream->cursor = stream->base + stream->pos;
stream->limit = stream->cursor + count;
stream->pos += count;
}
Exit:
return error;
}
示例6: FT_New_Face_From_URI
/* load a typeface from a URI */
FT_Error
FT_New_Face_From_URI (FT_Library library,
const gchar* uri,
FT_Long face_index,
FT_Face *aface)
{
FT_Open_Args args;
FT_Stream stream;
FT_Error error;
stream = calloc (1, sizeof (*stream));
if (stream == NULL)
return FT_Err_Out_Of_Memory;
error = vfs_stream_open (stream, uri);
if (error != FT_Err_Ok) {
free (stream);
return error;
}
args.flags = FT_OPEN_STREAM;
args.stream = stream;
error = FT_Open_Face (library, &args, face_index, aface);
if (error != FT_Err_Ok) {
if (stream->close != NULL)
stream->close(stream);
free (stream);
return error;
}
/* so that freetype will free the stream */
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
return error;
}
示例7: ft_bzip2_file_fill_input
static FT_Error
ft_bzip2_file_fill_input( FT_BZip2File zip )
{
bz_stream* bzstream = &zip->bzstream;
FT_Stream stream = zip->source;
FT_ULong size;
if ( stream->read )
{
size = stream->read( stream, stream->pos, zip->input,
FT_BZIP2_BUFFER_SIZE );
if ( size == 0 )
{
zip->limit = zip->cursor;
return FT_THROW( Invalid_Stream_Operation );
}
}
else
{
size = stream->size - stream->pos;
if ( size > FT_BZIP2_BUFFER_SIZE )
size = FT_BZIP2_BUFFER_SIZE;
if ( size == 0 )
{
zip->limit = zip->cursor;
return FT_THROW( Invalid_Stream_Operation );
}
FT_MEM_COPY( zip->input, stream->base + stream->pos, size );
}
stream->pos += size;
bzstream->next_in = (char*)zip->input;
bzstream->avail_in = size;
return FT_Err_Ok;
}
示例8: BASE_FUNC
BASE_FUNC(FT_Long) FT_Read_LongLE(FT_Stream stream,
FT_Error *error)
{
FT_Byte reads[4];
FT_Byte *p = 0;
FT_Long result = 0;
FT_Assert(stream);
*error = FT_Err_Ok;
if(stream->pos + 3 < stream->size)
{
if(stream->read)
{
if(stream->read(stream, stream->pos, reads, 4L) != 4L)
{
goto Fail;
}
p = reads;
}
else
{
p = stream->base + stream->pos;
}
if(p)
{
result = NEXT_LongLE(p);
}
}
else
{
goto Fail;
}
stream->pos += 4;
return result;
Fail:
FT_ERROR(("FT_Read_Long:"));
FT_ERROR((" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size));
*error = FT_Err_Invalid_Stream_Operation;
return 0;
}
示例9: FT_Stream_ReadOffset
FT_Stream_ReadOffset( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[3];
FT_Byte* p = 0;
FT_Long result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 2 < stream->size )
{
if ( stream->read )
{
if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
goto Fail;
p = reads;
}
else
{
p = stream->base + stream->pos;
}
if ( p )
result = FT_NEXT_OFF3( p );
}
else
goto Fail;
stream->pos += 3;
return result;
Fail:
*error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Stream_ReadOffset:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
}
示例10: FT_Stream_ReadLongLE
FT_Stream_ReadLongLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
FT_Byte* p = 0;
FT_Long result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 3 < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
goto Fail;
p = reads;
}
else
{
p = stream->base + stream->pos;
}
if ( p )
result = FT_NEXT_LONG_LE( p );
}
else
goto Fail;
stream->pos += 4;
return result;
Fail:
FT_ERROR(( "FT_Stream_ReadLongLE:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
*error = FT_Err_Invalid_Stream_Operation;
return 0;
}
示例11: FT_Stream_ReadShortLE
FT_Stream_ReadShortLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
FT_Byte* p = 0;
FT_Short result = 0;
FT_ASSERT( stream );
*error = FT_Err_Ok;
if ( stream->pos + 1 < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
goto Fail;
p = reads;
}
else
{
p = stream->base + stream->pos;
}
if ( p )
result = FT_NEXT_SHORT_LE( p );
}
else
goto Fail;
stream->pos += 2;
return result;
Fail:
*error = FT_Err_Invalid_Stream_Operation;
FT_ERROR(( "FT_Stream_ReadShortLE:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return 0;
}
示例12: FT_Stream_Close
FT_Stream_Close( FT_Stream stream )
{
if ( stream && stream->close )
stream->close( stream );
}
示例13: FT_Stream_EnterFrame
FT_Stream_EnterFrame( FT_Stream stream,
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
FT_ULong read_bytes;
/* check for nested frame access */
FT_ASSERT( stream && stream->cursor == 0 );
if ( stream->read )
{
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
#ifdef FT_DEBUG_MEMORY
/* assume _ft_debug_file and _ft_debug_lineno are already set */
stream->base = (unsigned char*)ft_mem_qalloc( memory, count, &error );
if ( error )
goto Exit;
#else
if ( FT_QALLOC( stream->base, count ) )
goto Exit;
#endif
/* read it */
read_bytes = stream->read( stream, stream->pos,
stream->base, count );
if ( read_bytes < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:" ));
FT_ERROR(( " invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
FT_FREE( stream->base );
error = FT_Err_Invalid_Stream_Operation;
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
stream->pos += read_bytes;
}
else
{
/* check current and new position */
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
{
FT_ERROR(( "FT_Stream_EnterFrame:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
goto Exit;
}
/* set cursor */
stream->cursor = stream->base + stream->pos;
stream->limit = stream->cursor + count;
stream->pos += count;
}
Exit:
return error;
}