ReactOS  0.4.14-dev-1332-g6db3d88
winfnt.c File Reference
#include <ft2build.h>
#include "winfnt.h"
#include "fnterrs.h"
Include dependency graph for winfnt.c:

Go to the source code of this file.

Classes

struct  FNT_CMapRec_
 

Macros

#define FT_COMPONENT   trace_winfnt
 
#define FT_STRUCTURE   WinMZ_HeaderRec
 
#define FT_STRUCTURE   WinNE_HeaderRec
 
#define FT_STRUCTURE   WinPE32_HeaderRec
 
#define FT_STRUCTURE   WinPE32_SectionRec
 
#define FT_STRUCTURE   WinPE_RsrcDirRec
 
#define FT_STRUCTURE   WinPE_RsrcDirEntryRec
 
#define FT_STRUCTURE   WinPE_RsrcDataEntryRec
 
#define FT_STRUCTURE   FT_WinFNT_HeaderRec
 

Typedefs

typedef struct FNT_CMapRec_ FNT_CMapRec
 
typedef struct FNT_CMapRec_FNT_CMap
 

Functions

static void fnt_font_done (FNT_Face face)
 
static FT_Error fnt_font_load (FNT_Font font, FT_Stream stream)
 
static FT_Error fnt_face_get_dll_font (FNT_Face face, FT_Int face_instance_index)
 
static FT_Error fnt_cmap_init (FNT_CMap cmap, FT_Pointer pointer)
 
static FT_UInt fnt_cmap_char_index (FNT_CMap cmap, FT_UInt32 char_code)
 
static FT_UInt32 fnt_cmap_char_next (FNT_CMap cmap, FT_UInt32 *pchar_code)
 
static void FNT_Face_Done (FT_Face fntface)
 
static FT_Error FNT_Face_Init (FT_Stream stream, FT_Face fntface, FT_Int face_instance_index, FT_Int num_params, FT_Parameter *params)
 
static FT_Error FNT_Size_Select (FT_Size size, FT_ULong strike_index)
 
static FT_Error FNT_Size_Request (FT_Size size, FT_Size_Request req)
 
static FT_Error FNT_Load_Glyph (FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
 
static FT_Error winfnt_get_header (FT_Face face, FT_WinFNT_HeaderRec *aheader)
 
static FT_Module_Interface winfnt_get_service (FT_Module module, const FT_String *service_id)
 

Variables

static const FT_Frame_Field winmz_header_fields []
 
static const FT_Frame_Field winne_header_fields []
 
static const FT_Frame_Field winpe32_header_fields []
 
static const FT_Frame_Field winpe32_section_fields []
 
static const FT_Frame_Field winpe_rsrc_dir_fields []
 
static const FT_Frame_Field winpe_rsrc_dir_entry_fields []
 
static const FT_Frame_Field winpe_rsrc_data_entry_fields []
 
static const FT_Frame_Field winfnt_header_fields []
 
static const FT_CMap_ClassRec fnt_cmap_class_rec
 
static FT_CMap_Class const fnt_cmap_class = &fnt_cmap_class_rec
 
static const FT_Service_WinFntRec winfnt_service_rec
 
static const FT_ServiceDescRec winfnt_services []
 
FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec winfnt_driver_class
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_winfnt

Definition at line 40 of file winfnt.c.

◆ FT_STRUCTURE [1/8]

#define FT_STRUCTURE   WinMZ_HeaderRec

◆ FT_STRUCTURE [2/8]

#define FT_STRUCTURE   WinNE_HeaderRec

◆ FT_STRUCTURE [3/8]

#define FT_STRUCTURE   WinPE32_HeaderRec

◆ FT_STRUCTURE [4/8]

#define FT_STRUCTURE   WinPE32_SectionRec

◆ FT_STRUCTURE [5/8]

#define FT_STRUCTURE   WinPE_RsrcDirRec

◆ FT_STRUCTURE [6/8]

#define FT_STRUCTURE   WinPE_RsrcDirEntryRec

◆ FT_STRUCTURE [7/8]

#define FT_STRUCTURE   WinPE_RsrcDataEntryRec

◆ FT_STRUCTURE [8/8]

#define FT_STRUCTURE   FT_WinFNT_HeaderRec

Typedef Documentation

◆ FNT_CMap

◆ FNT_CMapRec

Function Documentation

◆ fnt_cmap_char_index()

static FT_UInt fnt_cmap_char_index ( FNT_CMap  cmap,
FT_UInt32  char_code 
)
static

Definition at line 630 of file winfnt.c.

632  {
633  FT_UInt gindex = 0;
634 
635 
636  char_code -= cmap->first;
637  if ( char_code < cmap->count )
638  /* we artificially increase the glyph index; */
639  /* FNT_Load_Glyph reverts to the right one */
640  gindex = (FT_UInt)( char_code + 1 );
641  return gindex;
642  }
GLuint GLuint GLsizei count
Definition: gl.h:1545
FT_UInt32 first
Definition: winfnt.c:606
unsigned int FT_UInt
Definition: fttypes.h:231

◆ fnt_cmap_char_next()

static FT_UInt32 fnt_cmap_char_next ( FNT_CMap  cmap,
FT_UInt32 *  pchar_code 
)
static

Definition at line 646 of file winfnt.c.

648  {
649  FT_UInt gindex = 0;
650  FT_UInt32 result = 0;
651  FT_UInt32 char_code = *pchar_code + 1;
652 
653 
654  if ( char_code <= cmap->first )
655  {
656  result = cmap->first;
657  gindex = 1;
658  }
659  else
660  {
661  char_code -= cmap->first;
662  if ( char_code < cmap->count )
663  {
664  result = cmap->first + char_code;
665  gindex = (FT_UInt)( char_code + 1 );
666  }
667  }
668 
669  *pchar_code = result;
670  return gindex;
671  }
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLint * first
Definition: glext.h:5794
FT_UInt32 first
Definition: winfnt.c:606
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint64EXT * result
Definition: glext.h:11304

◆ fnt_cmap_init()

static FT_Error fnt_cmap_init ( FNT_CMap  cmap,
FT_Pointer  pointer 
)
static

Definition at line 613 of file winfnt.c.

615  {
616  FNT_Face face = (FNT_Face)FT_CMAP_FACE( cmap );
617  FNT_Font font = face->font;
618 
619  FT_UNUSED( pointer );
620 
621 
622  cmap->first = (FT_UInt32) font->header.first_char;
623  cmap->count = (FT_UInt32)( font->header.last_char - cmap->first + 1 );
624 
625  return 0;
626  }
#define FT_CMAP_FACE(x)
Definition: ftobjs.h:165
Definition: mk_font.cpp:20
GLsizei const GLvoid * pointer
Definition: glext.h:5848
FT_UInt32 count
Definition: winfnt.c:607
struct FNT_FaceRec_ * FNT_Face
FT_UInt32 first
Definition: winfnt.c:606
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ FNT_Face_Done()

static void FNT_Face_Done ( FT_Face  fntface)
static

Definition at line 690 of file winfnt.c.

691  {
692  FNT_Face face = (FNT_Face)fntface;
694 
695 
696  if ( !face )
697  return;
698 
700 
701  fnt_font_done( face );
702 
703  FT_FREE( fntface->available_sizes );
704  fntface->num_fixed_sizes = 0;
705  }
static char memory[1024 *256]
Definition: process.c:116
FT_Bitmap_Size * available_sizes
Definition: freetype.h:1082
#define FT_FREE(ptr)
Definition: ftmemory.h:329
static void fnt_font_done(FNT_Face face)
Definition: winfnt.c:189
struct FNT_FaceRec_ * FNT_Face
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:636
FT_Int num_fixed_sizes
Definition: freetype.h:1081
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by FNT_Face_Init().

◆ fnt_face_get_dll_font()

static FT_Error fnt_face_get_dll_font ( FNT_Face  face,
FT_Int  face_instance_index 
)
static

Definition at line 271 of file winfnt.c.

273  {
274  FT_Error error;
275  FT_Stream stream = FT_FACE( face )->stream;
276  FT_Memory memory = FT_FACE( face )->memory;
277  WinMZ_HeaderRec mz_header;
278  FT_Long face_index;
279 
280 
281  face->font = NULL;
282 
283  face_index = FT_ABS( face_instance_index ) & 0xFFFF;
284 
285  /* does it begin with an MZ header? */
286  if ( FT_STREAM_SEEK( 0 ) ||
288  goto Exit;
289 
290  error = FT_ERR( Unknown_File_Format );
291  if ( mz_header.magic == WINFNT_MZ_MAGIC )
292  {
293  /* yes, now look for an NE header in the file */
294  WinNE_HeaderRec ne_header;
295 
296 
297  FT_TRACE2(( "MZ signature found\n" ));
298 
299  if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
301  goto Exit;
302 
303  error = FT_ERR( Unknown_File_Format );
304  if ( ne_header.magic == WINFNT_NE_MAGIC )
305  {
306  /* good, now look into the resource table for each FNT resource */
307  FT_ULong res_offset = mz_header.lfanew +
308  ne_header.resource_tab_offset;
309  FT_UShort size_shift;
310  FT_UShort font_count = 0;
311  FT_ULong font_offset = 0;
312 
313 
314  FT_TRACE2(( "NE signature found\n" ));
315 
316  if ( FT_STREAM_SEEK( res_offset ) ||
317  FT_FRAME_ENTER( ne_header.rname_tab_offset -
318  ne_header.resource_tab_offset ) )
319  goto Exit;
320 
321  size_shift = FT_GET_USHORT_LE();
322 
323  /* Microsoft's specification of the executable-file header format */
324  /* for `New Executable' (NE) doesn't give a limit for the */
325  /* alignment shift count; however, in 1985, the year of the */
326  /* specification release, only 32bit values were supported, thus */
327  /* anything larger than 16 doesn't make sense in general, given */
328  /* that file offsets are 16bit values, shifted by the alignment */
329  /* shift count */
330  if ( size_shift > 16 )
331  {
332  FT_TRACE2(( "invalid alignment shift count for resource data\n" ));
333  error = FT_THROW( Invalid_File_Format );
334  goto Exit;
335  }
336 
337 
338  for (;;)
339  {
341 
342 
344  if ( !type_id )
345  break;
346 
348 
349  if ( type_id == 0x8008U )
350  {
351  font_count = count;
352  font_offset = FT_STREAM_POS() + 4 +
353  (FT_ULong)( stream->cursor - stream->limit );
354  break;
355  }
356 
357  stream->cursor += 4 + count * 12;
358  }
359 
360  FT_FRAME_EXIT();
361 
362  if ( !font_count || !font_offset )
363  {
364  FT_TRACE2(( "this file doesn't contain any FNT resources\n" ));
365  error = FT_THROW( Invalid_File_Format );
366  goto Exit;
367  }
368 
369  /* loading `winfnt_header_fields' needs at least 118 bytes; */
370  /* use this as a rough measure to check the expected font size */
371  if ( font_count * 118UL > stream->size )
372  {
373  FT_TRACE2(( "invalid number of faces\n" ));
374  error = FT_THROW( Invalid_File_Format );
375  goto Exit;
376  }
377 
378  face->root.num_faces = font_count;
379 
380  if ( face_instance_index < 0 )
381  goto Exit;
382 
383  if ( face_index >= font_count )
384  {
385  error = FT_THROW( Invalid_Argument );
386  goto Exit;
387  }
388 
389  if ( FT_NEW( face->font ) )
390  goto Exit;
391 
392  if ( FT_STREAM_SEEK( font_offset + (FT_ULong)face_index * 12 ) ||
393  FT_FRAME_ENTER( 12 ) )
394  goto Fail;
395 
396  face->font->offset = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
397  face->font->fnt_size = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
398 
399  stream->cursor += 8;
400 
401  FT_FRAME_EXIT();
402 
403  error = fnt_font_load( face->font, stream );
404  }
405  else if ( ne_header.magic == WINFNT_PE_MAGIC )
406  {
407  WinPE32_HeaderRec pe32_header;
408  WinPE32_SectionRec pe32_section;
409  WinPE_RsrcDirRec root_dir, name_dir, lang_dir;
410  WinPE_RsrcDirEntryRec dir_entry1, dir_entry2, dir_entry3;
411  WinPE_RsrcDataEntryRec data_entry;
412 
413  FT_ULong root_dir_offset, name_dir_offset, lang_dir_offset;
414  FT_UShort i, j, k;
415 
416 
417  FT_TRACE2(( "PE signature found\n" ));
418 
419  if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
421  goto Exit;
422 
423  FT_TRACE2(( "magic %04lx, machine %02x, number_of_sections %u, "
424  "size_of_optional_header %02x\n"
425  "magic32 %02x, rsrc_virtual_address %04lx, "
426  "rsrc_size %04lx\n",
427  pe32_header.magic, pe32_header.machine,
428  pe32_header.number_of_sections,
429  pe32_header.size_of_optional_header,
430  pe32_header.magic32, pe32_header.rsrc_virtual_address,
431  pe32_header.rsrc_size ));
432 
433  if ( pe32_header.magic != WINFNT_PE_MAGIC /* check full signature */ ||
434  pe32_header.machine != 0x014C /* i386 */ ||
435  pe32_header.size_of_optional_header != 0xE0 /* FIXME */ ||
436  pe32_header.magic32 != 0x10B )
437  {
438  FT_TRACE2(( "this file has an invalid PE header\n" ));
439  error = FT_THROW( Invalid_File_Format );
440  goto Exit;
441  }
442 
443  face->root.num_faces = 0;
444 
445  for ( i = 0; i < pe32_header.number_of_sections; i++ )
446  {
448  &pe32_section ) )
449  goto Exit;
450 
451  FT_TRACE2(( "name %.8s, va %04lx, size %04lx, offset %04lx\n",
452  pe32_section.name, pe32_section.virtual_address,
453  pe32_section.size_of_raw_data,
454  pe32_section.pointer_to_raw_data ));
455 
456  if ( pe32_header.rsrc_virtual_address ==
457  pe32_section.virtual_address )
458  goto Found_rsrc_section;
459  }
460 
461  FT_TRACE2(( "this file doesn't contain any resources\n" ));
462  error = FT_THROW( Invalid_File_Format );
463  goto Exit;
464 
465  Found_rsrc_section:
466  FT_TRACE2(( "found resources section %.8s\n", pe32_section.name ));
467 
468  if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data ) ||
470  goto Exit;
471 
472  root_dir_offset = pe32_section.pointer_to_raw_data;
473 
474  for ( i = 0; i < root_dir.number_of_named_entries +
475  root_dir.number_of_id_entries; i++ )
476  {
477  if ( FT_STREAM_SEEK( root_dir_offset + 16 + i * 8 ) ||
479  &dir_entry1 ) )
480  goto Exit;
481 
482  if ( !(dir_entry1.offset & 0x80000000UL ) /* DataIsDirectory */ )
483  {
484  error = FT_THROW( Invalid_File_Format );
485  goto Exit;
486  }
487 
488  dir_entry1.offset &= ~0x80000000UL;
489 
490  name_dir_offset = pe32_section.pointer_to_raw_data +
491  dir_entry1.offset;
492 
493  if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
494  dir_entry1.offset ) ||
496  goto Exit;
497 
498  for ( j = 0; j < name_dir.number_of_named_entries +
499  name_dir.number_of_id_entries; j++ )
500  {
501  if ( FT_STREAM_SEEK( name_dir_offset + 16 + j * 8 ) ||
503  &dir_entry2 ) )
504  goto Exit;
505 
506  if ( !(dir_entry2.offset & 0x80000000UL ) /* DataIsDirectory */ )
507  {
508  error = FT_THROW( Invalid_File_Format );
509  goto Exit;
510  }
511 
512  dir_entry2.offset &= ~0x80000000UL;
513 
514  lang_dir_offset = pe32_section.pointer_to_raw_data +
515  dir_entry2.offset;
516 
517  if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
518  dir_entry2.offset ) ||
520  goto Exit;
521 
522  for ( k = 0; k < lang_dir.number_of_named_entries +
523  lang_dir.number_of_id_entries; k++ )
524  {
525  if ( FT_STREAM_SEEK( lang_dir_offset + 16 + k * 8 ) ||
527  &dir_entry3 ) )
528  goto Exit;
529 
530  if ( dir_entry2.offset & 0x80000000UL /* DataIsDirectory */ )
531  {
532  error = FT_THROW( Invalid_File_Format );
533  goto Exit;
534  }
535 
536  if ( dir_entry1.name == 8 /* RT_FONT */ )
537  {
538  if ( FT_STREAM_SEEK( root_dir_offset + dir_entry3.offset ) ||
540  &data_entry ) )
541  goto Exit;
542 
543  FT_TRACE2(( "found font #%lu, offset %04lx, "
544  "size %04lx, cp %lu\n",
545  dir_entry2.name,
546  pe32_section.pointer_to_raw_data +
547  data_entry.offset_to_data -
548  pe32_section.virtual_address,
549  data_entry.size, data_entry.code_page ));
550 
551  if ( face_index == face->root.num_faces )
552  {
553  if ( FT_NEW( face->font ) )
554  goto Exit;
555 
556  face->font->offset = pe32_section.pointer_to_raw_data +
557  data_entry.offset_to_data -
558  pe32_section.virtual_address;
559  face->font->fnt_size = data_entry.size;
560 
561  error = fnt_font_load( face->font, stream );
562  if ( error )
563  {
564  FT_TRACE2(( "font #%lu load error 0x%x\n",
565  dir_entry2.name, error ));
566  goto Fail;
567  }
568  else
569  FT_TRACE2(( "font #%lu successfully loaded\n",
570  dir_entry2.name ));
571  }
572 
573  face->root.num_faces++;
574  }
575  }
576  }
577  }
578  }
579 
580  if ( !face->root.num_faces )
581  {
582  FT_TRACE2(( "this file doesn't contain any RT_FONT resources\n" ));
583  error = FT_THROW( Invalid_File_Format );
584  goto Exit;
585  }
586 
587  if ( face_index >= face->root.num_faces )
588  {
589  error = FT_THROW( Invalid_Argument );
590  goto Exit;
591  }
592  }
593 
594  Fail:
595  if ( error )
596  fnt_font_done( face );
597 
598  Exit:
599  return error;
600  }
FT_UShort size_of_optional_header
Definition: winfnt.h:60
int FT_Error
Definition: fttypes.h:300
FT_UShort number_of_named_entries
Definition: winfnt.h:89
signed long FT_Long
Definition: fttypes.h:242
FT_UShort resource_tab_offset
Definition: winfnt.h:48
unsigned long FT_ULong
Definition: fttypes.h:253
FT_UShort number_of_id_entries
Definition: winfnt.h:90
#define error(str)
Definition: mkdosfs.c:1605
FT_ULong offset_to_data
Definition: winfnt.h:105
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FT_ABS(a)
Definition: ftobjs.h:74
static const FT_Frame_Field winne_header_fields[]
Definition: winfnt.c:55
FT_ULong virtual_address
Definition: winfnt.h:75
FT_UShort magic
Definition: winfnt.h:46
FT_BEGIN_HEADER struct WinMZ_HeaderRec_ WinMZ_HeaderRec
FT_ULong pointer_to_raw_data
Definition: winfnt.h:77
static char memory[1024 *256]
Definition: process.c:116
FT_UShort machine
Definition: winfnt.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FT_THROW(e)
Definition: ftdebug.h:213
smooth NULL
Definition: ftsmooth.c:416
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:508
static const char root_dir[]
Definition: create.c:31
FT_ULong magic
Definition: winfnt.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
FT_UShort rname_tab_offset
Definition: winfnt.h:49
static const FT_Frame_Field winpe32_section_fields[]
Definition: winfnt.c:88
#define FT_ERR(e)
Definition: fttypes.h:586
static void fnt_font_done(FNT_Face face)
Definition: winfnt.c:189
#define WINFNT_MZ_MAGIC
Definition: winfnt.h:133
static const FT_Frame_Field winmz_header_fields[]
Definition: winfnt.c:43
#define FT_GET_USHORT_LE()
Definition: ftstream.h:297
static void Exit(void)
Definition: sock.c:1331
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
FT_ULong rsrc_virtual_address
Definition: winfnt.h:64
static FT_Error fnt_font_load(FNT_Font font, FT_Stream stream)
Definition: winfnt.c:209
type_id
unsigned int size
Definition: parse.h:27
Definition: parse.h:22
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static const FT_Frame_Field winpe32_header_fields[]
Definition: winfnt.c:68
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
Definition: hiveinit.c:368
#define FT_STREAM_POS()
Definition: ftstream.h:486
FT_Byte name[8]
Definition: winfnt.h:73
#define FT_FACE(x)
Definition: ftobjs.h:630
FT_ULong rsrc_size
Definition: winfnt.h:65
static const FT_Frame_Field winpe_rsrc_data_entry_fields[]
Definition: winfnt.c:129
FT_ULong size_of_raw_data
Definition: winfnt.h:76
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
static const FT_Frame_Field winpe_rsrc_dir_entry_fields[]
Definition: winfnt.c:118
FT_UShort number_of_sections
Definition: winfnt.h:58
#define WINFNT_PE_MAGIC
Definition: winfnt.h:135
#define FT_NEW(ptr)
Definition: ftmemory.h:331
unsigned short FT_UShort
Definition: fttypes.h:209
static const FT_Frame_Field winpe_rsrc_dir_fields[]
Definition: winfnt.c:103
#define UL
Definition: tui.h:82
int k
Definition: mpi.c:3369
FT_UShort magic32
Definition: winfnt.h:62
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define WINFNT_NE_MAGIC
Definition: winfnt.h:134

Referenced by FNT_Face_Init().

◆ FNT_Face_Init()

static FT_Error FNT_Face_Init ( FT_Stream  stream,
FT_Face  fntface,
FT_Int  face_instance_index,
FT_Int  num_params,
FT_Parameter params 
)
static

Definition at line 709 of file winfnt.c.

714  {
715  FNT_Face face = (FNT_Face)fntface;
716  FT_Error error;
718  FT_Int face_index;
719 
720  FT_UNUSED( num_params );
721  FT_UNUSED( params );
722 
723 
724  FT_TRACE2(( "Windows FNT driver\n" ));
725 
726  face_index = FT_ABS( face_instance_index ) & 0xFFFF;
727 
728  /* try to load font from a DLL */
729  error = fnt_face_get_dll_font( face, face_instance_index );
730  if ( !error && face_instance_index < 0 )
731  goto Exit;
732 
733  if ( FT_ERR_EQ( error, Unknown_File_Format ) )
734  {
735  /* this didn't work; try to load a single FNT font */
736  FNT_Font font;
737 
738  if ( FT_NEW( face->font ) )
739  goto Exit;
740 
741  fntface->num_faces = 1;
742 
743  font = face->font;
744  font->offset = 0;
745  font->fnt_size = stream->size;
746 
748 
749  if ( !error )
750  {
751  if ( face_instance_index < 0 )
752  goto Exit;
753 
754  if ( face_index > 0 )
755  error = FT_THROW( Invalid_Argument );
756  }
757  }
758 
759  if ( error )
760  goto Fail;
761 
762  /* sanity check */
763  if ( !face->font->header.pixel_height )
764  {
765  FT_TRACE2(( "invalid pixel height\n" ));
766  error = FT_THROW( Invalid_File_Format );
767  goto Fail;
768  }
769 
770  /* we now need to fill the root FT_Face fields */
771  /* with relevant information */
772  {
773  FT_Face root = FT_FACE( face );
774  FNT_Font font = face->font;
775  FT_ULong family_size;
776 
777 
778  root->face_index = face_index;
779 
780  root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
782 
783  if ( font->header.avg_width == font->header.max_width )
784  root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
785 
786  if ( font->header.italic )
787  root->style_flags |= FT_STYLE_FLAG_ITALIC;
788 
789  if ( font->header.weight >= 800 )
790  root->style_flags |= FT_STYLE_FLAG_BOLD;
791 
792  /* set up the `fixed_sizes' array */
793  if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
794  goto Fail;
795 
796  root->num_fixed_sizes = 1;
797 
798  {
799  FT_Bitmap_Size* bsize = root->available_sizes;
800  FT_UShort x_res, y_res;
801 
802 
803  bsize->width = (FT_Short)font->header.avg_width;
804  bsize->height = (FT_Short)( font->header.pixel_height +
805  font->header.external_leading );
806  bsize->size = font->header.nominal_point_size << 6;
807 
808  x_res = font->header.horizontal_resolution;
809  if ( !x_res )
810  x_res = 72;
811 
812  y_res = font->header.vertical_resolution;
813  if ( !y_res )
814  y_res = 72;
815 
816  bsize->y_ppem = FT_MulDiv( bsize->size, y_res, 72 );
817  bsize->y_ppem = FT_PIX_ROUND( bsize->y_ppem );
818 
819  /*
820  * this reads:
821  *
822  * the nominal height is larger than the bbox's height
823  *
824  * => nominal_point_size contains incorrect value;
825  * use pixel_height as the nominal height
826  */
827  if ( bsize->y_ppem > ( font->header.pixel_height << 6 ) )
828  {
829  FT_TRACE2(( "use pixel_height as the nominal height\n" ));
830 
831  bsize->y_ppem = font->header.pixel_height << 6;
832  bsize->size = FT_MulDiv( bsize->y_ppem, 72, y_res );
833  }
834 
835  bsize->x_ppem = FT_MulDiv( bsize->size, x_res, 72 );
836  bsize->x_ppem = FT_PIX_ROUND( bsize->x_ppem );
837  }
838 
839  {
840  FT_CharMapRec charmap;
841 
842 
843  charmap.encoding = FT_ENCODING_NONE;
844  /* initial platform/encoding should indicate unset status? */
847  charmap.face = root;
848 
849  if ( font->header.charset == FT_WinFNT_ID_MAC )
850  {
851  charmap.encoding = FT_ENCODING_APPLE_ROMAN;
853 /* charmap.encoding_id = TT_MAC_ID_ROMAN; */
854  }
855 
857  NULL,
858  &charmap,
859  NULL );
860  if ( error )
861  goto Fail;
862  }
863 
864  /* set up remaining flags */
865 
866  if ( font->header.last_char < font->header.first_char )
867  {
868  FT_TRACE2(( "invalid number of glyphs\n" ));
869  error = FT_THROW( Invalid_File_Format );
870  goto Fail;
871  }
872 
873  /* reserve one slot for the .notdef glyph at index 0 */
874  root->num_glyphs = font->header.last_char -
875  font->header.first_char + 1 + 1;
876 
877  if ( font->header.face_name_offset >= font->header.file_size )
878  {
879  FT_TRACE2(( "invalid family name offset\n" ));
880  error = FT_THROW( Invalid_File_Format );
881  goto Fail;
882  }
883  family_size = font->header.file_size - font->header.face_name_offset;
884  /* Some broken fonts don't delimit the face name with a final */
885  /* NULL byte -- the frame is erroneously one byte too small. */
886  /* We thus allocate one more byte, setting it explicitly to */
887  /* zero. */
888  if ( FT_ALLOC( font->family_name, family_size + 1 ) )
889  goto Fail;
890 
891  FT_MEM_COPY( font->family_name,
892  font->fnt_frame + font->header.face_name_offset,
893  family_size );
894 
895  font->family_name[family_size] = '\0';
896 
897  if ( FT_REALLOC( font->family_name,
898  family_size,
899  ft_strlen( font->family_name ) + 1 ) )
900  goto Fail;
901 
902  root->family_name = font->family_name;
903  root->style_name = (char *)"Regular";
904 
905  if ( root->style_flags & FT_STYLE_FLAG_BOLD )
906  {
907  if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
908  root->style_name = (char *)"Bold Italic";
909  else
910  root->style_name = (char *)"Bold";
911  }
912  else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
913  root->style_name = (char *)"Italic";
914  }
915  goto Exit;
916 
917  Fail:
918  FNT_Face_Done( fntface );
919 
920  Exit:
921  return error;
922  }
#define TT_APPLE_ID_DEFAULT
Definition: font.c:1176
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
int FT_Error
Definition: fttypes.h:300
FT_Face face
Definition: freetype.h:842
unsigned long FT_ULong
Definition: fttypes.h:253
FT_UShort encoding_id
Definition: freetype.h:845
FT_Pos x_ppem
Definition: freetype.h:378
#define error(str)
Definition: mkdosfs.c:1605
Definition: mk_font.cpp:20
signed int FT_Int
Definition: fttypes.h:220
#define FT_ABS(a)
Definition: ftobjs.h:74
struct _root root
#define FT_FACE_FLAG_FIXED_SIZES
Definition: freetype.h:1239
static FT_CMap_Class const fnt_cmap_class
Definition: winfnt.c:686
static FT_Error fnt_face_get_dll_font(FNT_Face face, FT_Int face_instance_index)
Definition: winfnt.c:271
static char memory[1024 *256]
Definition: process.c:116
FT_Long num_faces
Definition: freetype.h:1070
GLenum const GLfloat * params
Definition: glext.h:5645
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_STYLE_FLAG_BOLD
Definition: freetype.h:1518
#define TT_PLATFORM_APPLE_UNICODE
Definition: font.c:1172
smooth NULL
Definition: ftsmooth.c:416
#define FT_FACE_FLAG_FIXED_WIDTH
Definition: freetype.h:1240
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:416
#define TT_PLATFORM_MACINTOSH
Definition: font.c:1173
#define FT_FACE_FLAG_HORIZONTAL
Definition: freetype.h:1242
static void Exit(void)
Definition: sock.c:1331
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
#define FT_ERR_EQ(x, e)
Definition: fttypes.h:591
static FT_Error fnt_font_load(FNT_Font font, FT_Stream stream)
Definition: winfnt.c:209
FT_Pos y_ppem
Definition: freetype.h:379
FT_Short width
Definition: freetype.h:374
struct FNT_FaceRec_ * FNT_Face
FT_Encoding encoding
Definition: freetype.h:843
unsigned int size
Definition: parse.h:27
Definition: parse.h:22
signed short FT_Short
Definition: fttypes.h:198
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:636
Definition: hiveinit.c:368
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3614
FT_UShort platform_id
Definition: freetype.h:844
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:306
#define FT_FACE(x)
Definition: ftobjs.h:630
#define FT_NEW(ptr)
Definition: ftmemory.h:331
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228
#define FT_WinFNT_ID_MAC
Definition: ftwinfnt.h:158
#define FT_STYLE_FLAG_ITALIC
Definition: freetype.h:1517
unsigned short FT_UShort
Definition: fttypes.h:209
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define ft_strlen
Definition: ftstdlib.h:88
static void FNT_Face_Done(FT_Face fntface)
Definition: winfnt.c:690
FT_Short height
Definition: freetype.h:373
#define FT_PIX_ROUND(x)
Definition: ftobjs.h:93
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ fnt_font_done()

static void fnt_font_done ( FNT_Face  face)
static

Definition at line 189 of file winfnt.c.

190  {
191  FT_Memory memory = FT_FACE( face )->memory;
192  FT_Stream stream = FT_FACE( face )->stream;
193  FNT_Font font = face->font;
194 
195 
196  if ( !font )
197  return;
198 
199  if ( font->fnt_frame )
200  FT_FRAME_RELEASE( font->fnt_frame );
201  FT_FREE( font->family_name );
202 
203  FT_FREE( font );
204  face->font = NULL;
205  }
Definition: mk_font.cpp:20
static char memory[1024 *256]
Definition: process.c:116
smooth NULL
Definition: ftsmooth.c:416
#define FT_FREE(ptr)
Definition: ftmemory.h:329
Definition: parse.h:22
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_FRAME_RELEASE(bytes)
Definition: ftstream.h:526
#define FT_FACE(x)
Definition: ftobjs.h:630
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by FNT_Face_Done(), and fnt_face_get_dll_font().

◆ fnt_font_load()

static FT_Error fnt_font_load ( FNT_Font  font,
FT_Stream  stream 
)
static

Definition at line 209 of file winfnt.c.

211  {
212  FT_Error error;
213  FT_WinFNT_Header header = &font->header;
214  FT_Bool new_format;
215  FT_UInt size;
216 
217 
218  /* first of all, read the FNT header */
219  if ( FT_STREAM_SEEK( font->offset ) ||
221  goto Exit;
222 
223  /* check header */
224  if ( header->version != 0x200 &&
225  header->version != 0x300 )
226  {
227  FT_TRACE2(( " not a Windows FNT file\n" ));
228  error = FT_THROW( Unknown_File_Format );
229  goto Exit;
230  }
231 
232  new_format = FT_BOOL( font->header.version == 0x300 );
233  size = new_format ? 148 : 118;
234 
235  if ( header->file_size < size )
236  {
237  FT_TRACE2(( " not a Windows FNT file\n" ));
238  error = FT_THROW( Unknown_File_Format );
239  goto Exit;
240  }
241 
242  /* Version 2 doesn't have these fields */
243  if ( header->version == 0x200 )
244  {
245  header->flags = 0;
246  header->A_space = 0;
247  header->B_space = 0;
248  header->C_space = 0;
249 
250  header->color_table_offset = 0;
251  }
252 
253  if ( header->file_type & 1 )
254  {
255  FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
256  error = FT_THROW( Unknown_File_Format );
257  goto Exit;
258  }
259 
260  /* this is a FNT file/table; extract its frame */
261  if ( FT_STREAM_SEEK( font->offset ) ||
262  FT_FRAME_EXTRACT( header->file_size, font->fnt_frame ) )
263  goto Exit;
264 
265  Exit:
266  return error;
267  }
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
Definition: mk_font.cpp:20
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:508
GLsizeiptr size
Definition: glext.h:5919
static void Exit(void)
Definition: sock.c:1331
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
static const FT_Frame_Field winfnt_header_fields[]
Definition: winfnt.c:142
#define FT_BOOL(x)
Definition: fttypes.h:578
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_FRAME_EXTRACT(size, bytes)
Definition: ftstream.h:520

Referenced by fnt_face_get_dll_font(), and FNT_Face_Init().

◆ FNT_Load_Glyph()

static FT_Error FNT_Load_Glyph ( FT_GlyphSlot  slot,
FT_Size  size,
FT_UInt  glyph_index,
FT_Int32  load_flags 
)
static

Definition at line 985 of file winfnt.c.

989  {
991  FNT_Font font;
993  FT_Byte* p;
994  FT_UInt len;
995  FT_Bitmap* bitmap = &slot->bitmap;
997  FT_Bool new_format;
998 
999 
1000  if ( !face )
1001  {
1002  error = FT_THROW( Invalid_Face_Handle );
1003  goto Exit;
1004  }
1005 
1006  font = face->font;
1007 
1008  if ( !font ||
1009  glyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) )
1010  {
1011  error = FT_THROW( Invalid_Argument );
1012  goto Exit;
1013  }
1014 
1015  FT_TRACE1(( "FNT_Load_Glyph: glyph index %d\n", glyph_index ));
1016 
1017  if ( glyph_index > 0 )
1018  glyph_index--; /* revert to real index */
1019  else
1020  glyph_index = font->header.default_char; /* the `.notdef' glyph */
1021 
1022  new_format = FT_BOOL( font->header.version == 0x300 );
1023  len = new_format ? 6 : 4;
1024 
1025  /* get glyph width and offset */
1026  offset = ( new_format ? 148 : 118 ) + len * glyph_index;
1027 
1028  if ( offset >= font->header.file_size - 2 - ( new_format ? 4 : 2 ) )
1029  {
1030  FT_TRACE2(( "invalid FNT offset\n" ));
1031  error = FT_THROW( Invalid_File_Format );
1032  goto Exit;
1033  }
1034 
1035  p = font->fnt_frame + offset;
1036 
1038 
1039  /* jump to glyph entry */
1040  if ( new_format )
1041  offset = FT_NEXT_ULONG_LE( p );
1042  else
1043  offset = FT_NEXT_USHORT_LE( p );
1044 
1045  if ( offset >= font->header.file_size )
1046  {
1047  FT_TRACE2(( "invalid FNT offset\n" ));
1048  error = FT_THROW( Invalid_File_Format );
1049  goto Exit;
1050  }
1051 
1052  bitmap->rows = font->header.pixel_height;
1053  bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
1054 
1055  slot->bitmap_left = 0;
1056  slot->bitmap_top = font->header.ascent;
1057  slot->format = FT_GLYPH_FORMAT_BITMAP;
1058 
1059  /* now set up metrics */
1060  slot->metrics.width = (FT_Pos)( bitmap->width << 6 );
1061  slot->metrics.height = (FT_Pos)( bitmap->rows << 6 );
1062  slot->metrics.horiAdvance = (FT_Pos)( bitmap->width << 6 );
1063  slot->metrics.horiBearingX = 0;
1064  slot->metrics.horiBearingY = slot->bitmap_top << 6;
1065 
1067  (FT_Pos)( bitmap->rows << 6 ) );
1068 
1069  if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
1070  goto Exit;
1071 
1072  /* jump to glyph data */
1073  p = font->fnt_frame + /* font->header.bits_offset */ + offset;
1074 
1075  /* allocate and build bitmap */
1076  {
1077  FT_Memory memory = FT_FACE_MEMORY( slot->face );
1078  FT_UInt pitch = ( bitmap->width + 7 ) >> 3;
1079  FT_Byte* column;
1080  FT_Byte* write;
1081 
1082 
1083  bitmap->pitch = (int)pitch;
1084  if ( !pitch ||
1085  offset + pitch * bitmap->rows > font->header.file_size )
1086  {
1087  FT_TRACE2(( "invalid bitmap width\n" ));
1088  error = FT_THROW( Invalid_File_Format );
1089  goto Exit;
1090  }
1091 
1092  /* note: since glyphs are stored in columns and not in rows we */
1093  /* can't use ft_glyphslot_set_bitmap */
1094  if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, pitch ) )
1095  goto Exit;
1096 
1097  column = (FT_Byte*)bitmap->buffer;
1098 
1099  for ( ; pitch > 0; pitch--, column++ )
1100  {
1101  FT_Byte* limit = p + bitmap->rows;
1102 
1103 
1104  for ( write = column; p < limit; p++, write += bitmap->pitch )
1105  *write = *p;
1106  }
1107 
1108  slot->internal->flags = FT_GLYPH_OWN_BITMAP;
1109  }
1110 
1111  Exit:
1112  return error;
1113  }
int FT_Error
Definition: fttypes.h:300
unsigned long FT_ULong
Definition: fttypes.h:253
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:58
ft_synthesize_vertical_metrics(FT_Glyph_Metrics *metrics, FT_Pos advance)
Definition: ftobjs.c:2933
uint32 width
Definition: uimain.c:91
#define error(str)
Definition: mkdosfs.c:1605
Definition: mk_font.cpp:20
#define FT_NEXT_ULONG_LE(buffer)
Definition: ftstream.h:257
GLintptr offset
Definition: glext.h:5920
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
#define FT_GLYPH_OWN_BITMAP
Definition: ftobjs.h:463
GLint limit
Definition: glext.h:10326
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define write
Definition: acwin.h:97
#define FT_TRACE1(varformat)
Definition: ftdebug.h:158
unsigned char FT_Byte
Definition: fttypes.h:154
#define FT_THROW(e)
Definition: ftdebug.h:213
Definition: uimain.c:88
GLsizeiptr size
Definition: glext.h:5919
static void Exit(void)
Definition: sock.c:1331
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
#define for
Definition: utility.h:88
struct FNT_FaceRec_ * FNT_Face
#define FT_NEXT_USHORT_LE(buffer)
Definition: ftstream.h:245
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
GLenum GLsizei len
Definition: glext.h:6722
#define FT_BOOL(x)
Definition: fttypes.h:578
Definition: vfat.h:184
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:636
#define FT_FACE(x)
Definition: ftobjs.h:630
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_SIZE_FACE(x)
Definition: ftobjs.h:639
#define FT_ALLOC_MULT(ptr, count, item_size)
Definition: ftmemory.h:309
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
GLfloat GLfloat p
Definition: glext.h:8902
#define FT_LOAD_BITMAP_METRICS_ONLY
Definition: freetype.h:3026
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ FNT_Size_Request()

static FT_Error FNT_Size_Request ( FT_Size  size,
FT_Size_Request  req 
)
static

Definition at line 947 of file winfnt.c.

949  {
950  FNT_Face face = (FNT_Face)size->face;
951  FT_WinFNT_Header header = &face->font->header;
952  FT_Bitmap_Size* bsize = size->face->available_sizes;
953  FT_Error error = FT_ERR( Invalid_Pixel_Size );
954  FT_Long height;
955 
956 
957  height = FT_REQUEST_HEIGHT( req );
958  height = ( height + 32 ) >> 6;
959 
960  switch ( req->type )
961  {
963  if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
964  error = FT_Err_Ok;
965  break;
966 
968  if ( height == header->pixel_height )
969  error = FT_Err_Ok;
970  break;
971 
972  default:
973  error = FT_THROW( Unimplemented_Feature );
974  break;
975  }
976 
977  if ( error )
978  return error;
979  else
980  return FNT_Size_Select( size, 0 );
981  }
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
#define error(str)
Definition: mkdosfs.c:1605
#define FT_REQUEST_HEIGHT(req)
Definition: ftobjs.h:694
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_ERR(e)
Definition: fttypes.h:586
FT_Size_Request_Type type
Definition: freetype.h:2619
GLsizeiptr size
Definition: glext.h:5919
struct FNT_FaceRec_ * FNT_Face
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static FT_Error FNT_Size_Select(FT_Size size, FT_ULong strike_index)
Definition: winfnt.c:926
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ FNT_Size_Select()

static FT_Error FNT_Size_Select ( FT_Size  size,
FT_ULong  strike_index 
)
static

Definition at line 926 of file winfnt.c.

928  {
929  FNT_Face face = (FNT_Face)size->face;
930  FT_WinFNT_Header header = &face->font->header;
931 
932  FT_UNUSED( strike_index );
933 
934 
935  FT_Select_Metrics( size->face, 0 );
936 
937  size->metrics.ascender = header->ascent * 64;
938  size->metrics.descender = -( header->pixel_height -
939  header->ascent ) * 64;
940  size->metrics.max_advance = header->max_width * 64;
941 
942  return FT_Err_Ok;
943  }
FT_Select_Metrics(FT_Face face, FT_ULong strike_index)
Definition: ftobjs.c:2993
return FT_Err_Ok
Definition: ftbbox.c:511
GLsizeiptr size
Definition: glext.h:5919
struct FNT_FaceRec_ * FNT_Face
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

Referenced by FNT_Size_Request().

◆ winfnt_get_header()

static FT_Error winfnt_get_header ( FT_Face  face,
FT_WinFNT_HeaderRec aheader 
)
static

Definition at line 1117 of file winfnt.c.

1119  {
1120  FNT_Font font = ((FNT_Face)face)->font;
1121 
1122 
1123  *aheader = font->header;
1124 
1125  return 0;
1126  }
Definition: mk_font.cpp:20
struct FNT_FaceRec_ * FNT_Face
GLenum GLuint GLint GLenum face
Definition: glext.h:7025

◆ winfnt_get_service()

static FT_Module_Interface winfnt_get_service ( FT_Module  module,
const FT_String service_id 
)
static

Definition at line 1148 of file winfnt.c.

1150  {
1151  FT_UNUSED( module );
1152 
1153  return ft_service_list_lookup( winfnt_services, service_id );
1154  }
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
Definition: ftobjs.c:98
static const FT_ServiceDescRec winfnt_services[]
Definition: winfnt.c:1139
#define FT_UNUSED(arg)
Definition: ftconfig.h:101

Variable Documentation

◆ fnt_cmap_class

FT_CMap_Class const fnt_cmap_class = &fnt_cmap_class_rec
static

Definition at line 686 of file winfnt.c.

Referenced by FNT_Face_Init().

◆ fnt_cmap_class_rec

const FT_CMap_ClassRec fnt_cmap_class_rec
static
Initial value:
=
{
sizeof ( FNT_CMapRec ),
}
struct FNT_CMapRec_ FNT_CMapRec
FT_UInt(* FT_CMap_CharIndexFunc)(FT_CMap cmap, FT_UInt32 char_code)
Definition: ftobjs.h:177
void(* FT_CMap_DoneFunc)(FT_CMap cmap)
Definition: ftobjs.h:174
smooth NULL
Definition: ftsmooth.c:416
static FT_UInt32 fnt_cmap_char_next(FNT_CMap cmap, FT_UInt32 *pchar_code)
Definition: winfnt.c:646
static FT_UInt fnt_cmap_char_index(FNT_CMap cmap, FT_UInt32 char_code)
Definition: winfnt.c:630
FT_UInt(* FT_CMap_CharNextFunc)(FT_CMap cmap, FT_UInt32 *achar_code)
Definition: ftobjs.h:181
FT_Error(* FT_CMap_InitFunc)(FT_CMap cmap, FT_Pointer init_data)
Definition: ftobjs.h:170
static FT_Error fnt_cmap_init(FNT_CMap cmap, FT_Pointer pointer)
Definition: winfnt.c:613

Definition at line 674 of file winfnt.c.

◆ winfnt_driver_class

Definition at line 1160 of file winfnt.c.

◆ winfnt_header_fields

const FT_Frame_Field winfnt_header_fields[]
static

Definition at line 142 of file winfnt.c.

Referenced by fnt_font_load().

◆ winfnt_service_rec

const FT_Service_WinFntRec winfnt_service_rec
static
Initial value:
=
{
}
static FT_Error winfnt_get_header(FT_Face face, FT_WinFNT_HeaderRec *aheader)
Definition: winfnt.c:1117

Definition at line 1129 of file winfnt.c.

◆ winfnt_services

const FT_ServiceDescRec winfnt_services[]
static
Initial value:
=
{
{ NULL, NULL }
}
#define FT_FONT_FORMAT_WINFNT
Definition: svfntfmt.h:44
#define FT_SERVICE_ID_WINFNT
Definition: svwinfnt.h:29
#define FT_SERVICE_ID_FONT_FORMAT
Definition: svfntfmt.h:34
smooth NULL
Definition: ftsmooth.c:416
static const FT_Service_WinFntRec winfnt_service_rec
Definition: winfnt.c:1129

Definition at line 1139 of file winfnt.c.

Referenced by winfnt_get_service().

◆ winmz_header_fields

const FT_Frame_Field winmz_header_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
FT_FRAME_ULONG_LE ( lfanew ),
}
u32_t magic(void)
#define FT_FRAME_ULONG_LE(f)
Definition: ftstream.h:130
#define FT_FRAME_SKIP_BYTES(count)
Definition: ftstream.h:147
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_FRAME_USHORT_LE(f)
Definition: ftstream.h:132
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 43 of file winfnt.c.

Referenced by fnt_face_get_dll_font().

◆ winne_header_fields

const FT_Frame_Field winne_header_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
FT_FRAME_USHORT_LE ( resource_tab_offset ),
FT_FRAME_USHORT_LE ( rname_tab_offset ),
}
u32_t magic(void)
#define FT_FRAME_SKIP_BYTES(count)
Definition: ftstream.h:147
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_FRAME_USHORT_LE(f)
Definition: ftstream.h:132
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 55 of file winfnt.c.

Referenced by fnt_face_get_dll_font().

◆ winpe32_header_fields

const FT_Frame_Field winpe32_header_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
FT_FRAME_USHORT_LE ( number_of_sections ),
FT_FRAME_USHORT_LE ( size_of_optional_header ),
FT_FRAME_USHORT_LE ( magic32 ),
FT_FRAME_ULONG_LE ( rsrc_virtual_address ),
FT_FRAME_ULONG_LE ( rsrc_size ),
}
u32_t magic(void)
#define FT_FRAME_ULONG_LE(f)
Definition: ftstream.h:130
#define FT_FRAME_SKIP_BYTES(count)
Definition: ftstream.h:147
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_FRAME_USHORT_LE(f)
Definition: ftstream.h:132
static const char machine[]
Definition: profile.c:104
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 68 of file winfnt.c.

Referenced by fnt_face_get_dll_font().

◆ winpe32_section_fields

const FT_Frame_Field winpe32_section_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
FT_FRAME_ULONG_LE ( virtual_address ),
FT_FRAME_ULONG_LE ( size_of_raw_data ),
FT_FRAME_ULONG_LE ( pointer_to_raw_data ),
}
#define FT_FRAME_BYTES(field, count)
Definition: ftstream.h:140
#define FT_FRAME_ULONG_LE(f)
Definition: ftstream.h:130
#define FT_FRAME_SKIP_BYTES(count)
Definition: ftstream.h:147
#define FT_FRAME_END
Definition: ftstream.h:118
Definition: name.c:38
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 88 of file winfnt.c.

Referenced by fnt_face_get_dll_font().

◆ winpe_rsrc_data_entry_fields

const FT_Frame_Field winpe_rsrc_data_entry_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
FT_FRAME_ULONG_LE( offset_to_data ),
FT_FRAME_ULONG_LE( code_page ),
}
#define FT_FRAME_ULONG_LE(f)
Definition: ftstream.h:130
r reserved
Definition: btrfs.c:2865
#define FT_FRAME_END
Definition: ftstream.h:118
GLsizeiptr size
Definition: glext.h:5919
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 129 of file winfnt.c.

Referenced by fnt_face_get_dll_font().

◆ winpe_rsrc_dir_entry_fields

const FT_Frame_Field winpe_rsrc_dir_entry_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
}
GLintptr offset
Definition: glext.h:5920
#define FT_FRAME_ULONG_LE(f)
Definition: ftstream.h:130
#define FT_FRAME_END
Definition: ftstream.h:118
Definition: name.c:38
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 118 of file winfnt.c.

Referenced by fnt_face_get_dll_font().

◆ winpe_rsrc_dir_fields

const FT_Frame_Field winpe_rsrc_dir_fields[]
static
Initial value:
=
{
#define FT_STRUCTURE
FT_FRAME_ULONG_LE ( characteristics ),
FT_FRAME_ULONG_LE ( time_date_stamp ),
FT_FRAME_USHORT_LE( major_version ),
FT_FRAME_USHORT_LE( minor_version ),
FT_FRAME_USHORT_LE( number_of_named_entries ),
FT_FRAME_USHORT_LE( number_of_id_entries ),
}
#define FT_FRAME_ULONG_LE(f)
Definition: ftstream.h:130
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_FRAME_USHORT_LE(f)
Definition: ftstream.h:132
#define FT_FRAME_START(size)
Definition: ftstream.h:117

Definition at line 103 of file winfnt.c.

Referenced by fnt_face_get_dll_font().