FreeType 1.31.1
This commit is contained in:
12
test/.cvsignore
Normal file
12
test/.cvsignore
Normal file
@@ -0,0 +1,12 @@
|
||||
.libs
|
||||
ftview
|
||||
fttimer
|
||||
ftlint
|
||||
ftdump
|
||||
ftzoom
|
||||
ftstring
|
||||
ftstrpnm
|
||||
fterror
|
||||
ftsbit
|
||||
ftmetric
|
||||
ftstrtto
|
||||
6
test/README
Normal file
6
test/README
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
The instructions how to use the test programs can be found in the
|
||||
main `README' file located in the parent directory.
|
||||
|
||||
|
||||
--- end of README ---
|
||||
386
test/arabic.c
Normal file
386
test/arabic.c
Normal file
@@ -0,0 +1,386 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* arabic -- An implementation of the contextual algorithm given in the */
|
||||
/* Unicode 2.0 book to assign the `isolated', `initial', `medial', and */
|
||||
/* `final' properties to an input string of character codes for the Arabic */
|
||||
/* script. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "arabic.h"
|
||||
#include "freetype.h"
|
||||
#include "ftxopen.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Here a table of the joining classes for characters in the range
|
||||
U+0620 - U+06FF.
|
||||
|
||||
The following character also has a joining class:
|
||||
|
||||
U+200C ZERO WIDTH NON-JOINER -> causing
|
||||
|
||||
All other characters are given the joining class `none'.
|
||||
|
||||
*/
|
||||
|
||||
joining_class arabic[] =
|
||||
{
|
||||
/* U+0620 */
|
||||
none, none, right, right,
|
||||
right, right, dual, right,
|
||||
dual, right, dual, dual,
|
||||
dual, dual, dual, right,
|
||||
|
||||
/* U+0630 */
|
||||
right, right, right, dual,
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, none,
|
||||
none, none, none, none,
|
||||
|
||||
/* U+0640 */
|
||||
causing, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
right, right, dual, transparent,
|
||||
transparent, transparent, transparent, transparent,
|
||||
|
||||
/* U+0650 */
|
||||
transparent, transparent, transparent, none,
|
||||
none, none, none, none,
|
||||
none, none, none, none,
|
||||
none, none, none, none,
|
||||
|
||||
/* U+0660 */
|
||||
none, none, none, none,
|
||||
none, none, none, none,
|
||||
none, none, none, none,
|
||||
none, none, none, none,
|
||||
|
||||
/* U+0670 */
|
||||
transparent, none, right, right,
|
||||
none, right, right, right,
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
|
||||
/* U+0680 */
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
right, right, right, right,
|
||||
right, right, right, right,
|
||||
|
||||
/* U+0690 */
|
||||
right, right, right, right,
|
||||
right, right, right, right,
|
||||
right, right, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
|
||||
/* U+06A0 */
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
|
||||
/* U+06B0 */
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
dual, dual, dual, dual,
|
||||
|
||||
/* U+06C0 */
|
||||
right, dual, right, right,
|
||||
right, right, right, right,
|
||||
right, right, right, right,
|
||||
dual, right, dual, right,
|
||||
|
||||
/* U+06D0 */
|
||||
dual, dual, right, right,
|
||||
none, none, none, transparent,
|
||||
transparent, transparent, transparent, transparent,
|
||||
transparent, transparent, transparent, transparent,
|
||||
|
||||
/* U+06E0 */
|
||||
transparent, transparent, transparent, transparent,
|
||||
transparent, none, none, transparent,
|
||||
transparent, none, transparent, transparent,
|
||||
transparent, transparent, none, none,
|
||||
|
||||
/* U+06F0 */
|
||||
none, none, none, none,
|
||||
none, none, none, none,
|
||||
none, none, dual, dual,
|
||||
dual, none, none, none
|
||||
};
|
||||
|
||||
|
||||
struct cgc_
|
||||
{
|
||||
TT_UShort char_code;
|
||||
TT_UShort glyph_index;
|
||||
TT_UShort class;
|
||||
};
|
||||
|
||||
typedef struct cgc_ cgc;
|
||||
|
||||
|
||||
int compare_cgc( const void* a,
|
||||
const void* b )
|
||||
{
|
||||
return ( ((cgc*)a)->glyph_index > ((cgc*)b)->glyph_index ) ?
|
||||
1 : ( ( ((cgc*)a)->glyph_index == ((cgc*)b)->glyph_index ) ?
|
||||
0 : -1 );
|
||||
}
|
||||
|
||||
|
||||
TT_Error Build_Arabic_Glyph_Properties( TT_CharMap char_map,
|
||||
TT_UShort max_glyphs,
|
||||
TTO_GDEFHeader** gdef )
|
||||
{
|
||||
TT_UShort i, j, num_glyphs;
|
||||
|
||||
cgc Arabic[0x0700 - 0x0620];
|
||||
|
||||
TT_UShort glyph_indices[0x700 - 0x0620];
|
||||
TT_UShort classes[0x700 - 0x0620];
|
||||
|
||||
if ( !gdef )
|
||||
return TT_Err_Invalid_Argument;
|
||||
|
||||
j = 0;
|
||||
|
||||
for ( i = 0x0620; i < 0x0700; i++ )
|
||||
{
|
||||
Arabic[j].char_code = i;
|
||||
Arabic[j].class = ( arabic[i - 0x0620] == transparent ) ?
|
||||
MARK_GLYPH : SIMPLE_GLYPH;
|
||||
Arabic[j].glyph_index = TT_Char_Index( char_map, i );
|
||||
if ( Arabic[j].glyph_index )
|
||||
j++;
|
||||
}
|
||||
num_glyphs = j;
|
||||
|
||||
if ( !num_glyphs )
|
||||
{
|
||||
/* no Arabic font */
|
||||
*gdef = NULL;
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
/* sort it */
|
||||
|
||||
qsort( Arabic, num_glyphs, sizeof ( cgc ), compare_cgc );
|
||||
|
||||
/* write it to the arrays, removing duplicates */
|
||||
|
||||
glyph_indices[0] = Arabic[0].glyph_index;
|
||||
classes[0] = Arabic[0].class;
|
||||
|
||||
j = 1;
|
||||
|
||||
for ( i = 1; i < num_glyphs; i++ )
|
||||
{
|
||||
glyph_indices[j] = Arabic[i].glyph_index;
|
||||
classes[j] = Arabic[i].class;
|
||||
|
||||
if ( glyph_indices[j - 1] != glyph_indices[j] )
|
||||
j++;
|
||||
}
|
||||
num_glyphs = j;
|
||||
|
||||
TT_GDEF_Build_ClassDefinition( *gdef, max_glyphs, num_glyphs,
|
||||
glyph_indices, classes );
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/* The joining rules as given in the Unicode 2.0 book (characters are
|
||||
here specified as appearing in the byte stream, i.e. *not* in
|
||||
visual order). Joining classes are given in angle brackets, glyph
|
||||
forms in square brackets. Glyphs affected by a specific rule are
|
||||
enclosed with vertical bars.
|
||||
|
||||
Note: The description of the joining algorithm in the book is
|
||||
severely broken. You can get a corrected version from
|
||||
www.unicode.org (as of 29-Jun-1999, this hasn't appeared).
|
||||
|
||||
R1: <anything1> <transparent> <anything2>
|
||||
|
||||
apply joining rules for
|
||||
<anything1> <anything2> -> [shape1] [shape2]
|
||||
|
||||
-> [shape1] [isolated] [shape2]
|
||||
|
||||
R2: <causing|left|dual> |<right>|
|
||||
|
||||
-> [final]
|
||||
|
||||
R3: |<left>| <causing|right|dual>
|
||||
|
||||
-> [initial]
|
||||
|
||||
R4: <causing|left|dual> |<dual>| <causing|right|dual>
|
||||
|
||||
-> [medial]
|
||||
|
||||
R5: <causing|left|dual> |<dual>| <!(causing|right|dual)>
|
||||
|
||||
-> [final]
|
||||
|
||||
R6: <!(causing|left|dual)> |<dual>| <causing|right|dual>
|
||||
|
||||
-> [initial]
|
||||
|
||||
R7: If R1-R6 fail:
|
||||
|
||||
<anything> -> [isolated] */
|
||||
|
||||
|
||||
/* `direction' can be -1, 0, or 1 to indicate the last non-transparent
|
||||
glyph, the current glyph, and the next non-transparent glyph,
|
||||
respectively. */
|
||||
|
||||
static joining_class Get_Joining_Class( TT_UShort* string,
|
||||
TT_UShort pos,
|
||||
TT_UShort length,
|
||||
int direction )
|
||||
{
|
||||
joining_class j;
|
||||
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( pos == 0 && direction < 0 )
|
||||
return none;
|
||||
|
||||
pos += direction;
|
||||
|
||||
if ( pos >= length )
|
||||
return none;
|
||||
|
||||
if ( string[pos] < 0x0620 ||
|
||||
string[pos] >= 0x0700 )
|
||||
{
|
||||
if ( string[pos] == 0x200C )
|
||||
return causing;
|
||||
else
|
||||
return none;
|
||||
}
|
||||
else
|
||||
j = arabic[string[pos] - 0x0620];
|
||||
|
||||
if ( !direction || j != transparent )
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TT_Error Assign_Arabic_Properties( TT_UShort* string,
|
||||
TT_UShort* properties,
|
||||
TT_UShort length )
|
||||
{
|
||||
joining_class previous, current, next;
|
||||
|
||||
TT_UShort i;
|
||||
|
||||
|
||||
if ( !string || !properties || length == 0 )
|
||||
return TT_Err_Invalid_Argument;
|
||||
|
||||
for ( i = 0; i < length; i++ )
|
||||
{
|
||||
previous = Get_Joining_Class( string, i, length, -1 );
|
||||
current = Get_Joining_Class( string, i, length, 0 );
|
||||
next = Get_Joining_Class( string, i, length, 1 );
|
||||
|
||||
/* R1 */
|
||||
|
||||
if ( current == transparent )
|
||||
{
|
||||
properties[i] |= isolated_p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* R2 */
|
||||
|
||||
if ( previous == causing ||
|
||||
previous == left ||
|
||||
previous == dual )
|
||||
if ( current == right )
|
||||
{
|
||||
properties[i] |= final_p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* R3 */
|
||||
|
||||
if ( current == left )
|
||||
if ( next == causing ||
|
||||
next == right ||
|
||||
next == dual )
|
||||
{
|
||||
properties[i] |= initial_p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* R4 */
|
||||
|
||||
if ( previous == causing ||
|
||||
previous == left ||
|
||||
previous == dual )
|
||||
if ( current == dual )
|
||||
if ( next == causing ||
|
||||
next == right ||
|
||||
next == dual )
|
||||
{
|
||||
properties[i] |= medial_p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* R5 */
|
||||
|
||||
if ( previous == causing ||
|
||||
previous == left ||
|
||||
previous == dual )
|
||||
if ( current == dual )
|
||||
if ( !( next == causing ||
|
||||
next == right ||
|
||||
next == dual ) )
|
||||
{
|
||||
properties[i] |= final_p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* R6 */
|
||||
|
||||
if ( !( previous == causing ||
|
||||
previous == left ||
|
||||
previous == dual ) )
|
||||
if ( current == dual )
|
||||
if ( next == causing ||
|
||||
next == right ||
|
||||
next == dual )
|
||||
{
|
||||
properties[i] |= initial_p;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* R7 */
|
||||
|
||||
if ( current != none )
|
||||
properties[i] |= isolated_p;
|
||||
}
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
66
test/arabic.h
Normal file
66
test/arabic.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* arabic -- An implementation of the contextual algorithm given in the */
|
||||
/* Unicode 2.0 book to assign the `isolated', `initial', `medial', and */
|
||||
/* `final' properties to an input string of character codes for the Arabic */
|
||||
/* script. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
#include "freetype.h"
|
||||
#include "ftxopen.h"
|
||||
|
||||
|
||||
enum joining_type_
|
||||
{
|
||||
isolated = 1, /* nominal */
|
||||
final = 2, /* right_joining */
|
||||
initial = 4, /* left_joining */
|
||||
medial = 8 /* double_joining */
|
||||
};
|
||||
|
||||
typedef enum joining_type_ joining_type;
|
||||
|
||||
|
||||
/* A glyph's property value as needed by e.g. TT_GSUB_Apply_String()
|
||||
specifies which features should *not* be applied */
|
||||
|
||||
enum arabic_glyph_property_
|
||||
{
|
||||
isolated_p = final | initial | medial,
|
||||
final_p = isolated | initial | medial,
|
||||
initial_p = isolated | final | medial,
|
||||
medial_p = isolated | final | initial
|
||||
};
|
||||
|
||||
typedef enum arabic_glyph_property_ arabic_glyph_property;
|
||||
|
||||
|
||||
enum joining_class_
|
||||
{
|
||||
right,
|
||||
left, /* not used */
|
||||
dual,
|
||||
causing,
|
||||
none,
|
||||
transparent
|
||||
};
|
||||
|
||||
typedef enum joining_class_ joining_class;
|
||||
|
||||
|
||||
TT_Error Assign_Arabic_Properties( TT_UShort* string,
|
||||
TT_UShort* properties,
|
||||
TT_UShort length );
|
||||
TT_Error Build_Arabic_Glyph_Properties( TT_CharMap char_map,
|
||||
TT_UShort max_glyphs,
|
||||
TTO_GDEFHeader** gdef );
|
||||
|
||||
|
||||
/* End */
|
||||
106
test/arch/amigaos/Makefile.gcc
Normal file
106
test/arch/amigaos/Makefile.gcc
Normal file
@@ -0,0 +1,106 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for amiga using ADE.
|
||||
#
|
||||
# You will need GNU make.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -f arch/amigaos/Makefile.gcc
|
||||
|
||||
ARCH = arch/amigaos
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.gcc
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/$(ARCH) -I. -I$(LIBDIR)/extend
|
||||
|
||||
CFLAGS = -ansi -Wall -g -noixemul $(INCDIRS)
|
||||
# CFLAGS = -Wall -noixemul -O2 -Ilib $(INCDIRS)
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c $(ARCH)/gw_amiga.c
|
||||
GOBJ = $(GSRC:.c=.o)
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ @^
|
||||
|
||||
|
||||
EXEFILES = ftdump \
|
||||
fterror \
|
||||
ftlint \
|
||||
ftmetric \
|
||||
ftsbit \
|
||||
ftstring \
|
||||
ftstrpnm \
|
||||
ftstrtto \
|
||||
fttimer \
|
||||
ftview \
|
||||
ftzoom
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all
|
||||
|
||||
freetype_debug:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug
|
||||
|
||||
ftzoom: $(GOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview: $(GOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring: $(GOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer: $(GOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto: $(GOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean
|
||||
|
||||
distclean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
|
||||
-rm dep.end core
|
||||
-rm $(EXE)
|
||||
|
||||
do_clean:
|
||||
-rm *.o
|
||||
-rm arch/amigaos/*.o
|
||||
|
||||
|
||||
depend:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
|
||||
$(CC) -E -M $(INCDIRS) $(SRC) $(GSRC) > dep.end
|
||||
|
||||
ifeq (dep.end,$(wildcard dep.end))
|
||||
include dep.end
|
||||
endif
|
||||
|
||||
# end of Makefile.gcc
|
||||
16
test/arch/amigaos/TODO
Normal file
16
test/arch/amigaos/TODO
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
* To test the window oriented driver.
|
||||
|
||||
* To improve the window oriented driver to use ROM functions like
|
||||
WriteChunkyPixel() (or similar) instead of the current routine.
|
||||
|
||||
* To build a truetype.library from libttf.a
|
||||
|
||||
* truetype.datatype.
|
||||
|
||||
* Program to convert truetype fonts in Amiga fonts.
|
||||
|
||||
Suggestions, bug reports, code improvements, support for other compilers,
|
||||
... are welcome !
|
||||
|
||||
Send them to: map@medusa.es or to freetype@lists.lrz-muenchen.de
|
||||
428
test/arch/amigaos/gfsamiga.c
Normal file
428
test/arch/amigaos/gfsamiga.c
Normal file
@@ -0,0 +1,428 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gfsamiga.c graphics utility fullscreen Amiga driver. 1.0
|
||||
*
|
||||
* This is the driver for fullscreen Amiga display, used by the
|
||||
* graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
/* standard includes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* AmigaOS includes */
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <intuition/screens.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#include <inline/exec.h>
|
||||
#include <inline/intuition.h>
|
||||
#include <inline/graphics.h>
|
||||
#include <inline/dos.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
#include <clib/dos_protos.h>
|
||||
|
||||
#endif
|
||||
|
||||
/* FreeType includes */
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
/* some screen definitions */
|
||||
|
||||
#define MONO_SCREEN_WIDTH 640
|
||||
#define MONO_SCREEN_HEIGHT 512
|
||||
#define MONO_SCREEN_DEPTH 1
|
||||
|
||||
#define GRAY_SCREEN_WIDTH 320
|
||||
#define GRAY_SCREEN_HEIGHT 256
|
||||
#define GRAY_SCREEN_DEPTH 3
|
||||
|
||||
#define DISPLAY_MEM ( 1024 * 64 )
|
||||
|
||||
|
||||
/* external variables */
|
||||
|
||||
extern struct Library* SysBase;
|
||||
extern struct Library* DOSBase;
|
||||
|
||||
extern int vio_ScanLineWidth;
|
||||
extern char* Vio;
|
||||
extern char gray_palette[5];
|
||||
|
||||
/* global variables */
|
||||
|
||||
struct Library* IntuitionBase = NULL;
|
||||
struct Library* GfxBase = NULL;
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
||||
static struct Screen* fts = NULL;
|
||||
static struct Window* ftw = NULL;
|
||||
|
||||
static int graphx_mode;
|
||||
|
||||
|
||||
/* exit gracefully */
|
||||
|
||||
static void AmigaCleanUp( void )
|
||||
{
|
||||
if ( ftw )
|
||||
CloseWindow( ftw );
|
||||
|
||||
if ( fts )
|
||||
CloseScreen( fts );
|
||||
|
||||
if ( IntuitionBase )
|
||||
CloseLibrary( IntuitionBase );
|
||||
|
||||
if ( GfxBase )
|
||||
CloseLibrary( GfxBase );
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
if ( Vio )
|
||||
FreeMem( Vio, DISPLAY_MEM );
|
||||
}
|
||||
|
||||
|
||||
static void SetPalette( void )
|
||||
{
|
||||
short color[] = { 0x0000,
|
||||
0x0333,
|
||||
0x0777,
|
||||
0x0BBB,
|
||||
0x0FFF,
|
||||
0x0A00,
|
||||
0x00A0,
|
||||
0x000A
|
||||
};
|
||||
short i;
|
||||
|
||||
|
||||
for ( i = 0; i < 8; i++ )
|
||||
{
|
||||
if ( i < 5 )
|
||||
gray_palette[i] = i;
|
||||
|
||||
SetRGB4( &fts->ViewPort, i, (UBYTE)(color[i] >> 8 & 0x0f),
|
||||
(UBYTE)(color[i] >> 4 & 0x0f),
|
||||
(UBYTE)(color[i] & 0x0f ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* open libraries & custom screen */
|
||||
|
||||
static int AmigaInit( void )
|
||||
{
|
||||
/* cleanup at exit */
|
||||
if ( atexit( AmigaCleanUp ) )
|
||||
{
|
||||
PutStr( "atexit() failed\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* open intuition library */
|
||||
|
||||
IntuitionBase = (struct Library*)OpenLibrary( "intuition.library", 37L );
|
||||
if ( IntuitionBase == NULL )
|
||||
{
|
||||
PutStr( "Could not open intuition library\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open graphics library */
|
||||
|
||||
GfxBase = OpenLibrary( "graphics.library", 37L );
|
||||
if ( GfxBase == NULL )
|
||||
{
|
||||
PutStr( "Could not open graphics library\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
/* open custom screen */
|
||||
fts = (struct Screen*)OpenScreenTags(
|
||||
NULL,
|
||||
SA_DisplayID, (PAL_MONITOR_ID | LORES_KEY),
|
||||
SA_Width, GRAY_SCREEN_WIDTH,
|
||||
SA_Height, GRAY_SCREEN_HEIGHT,
|
||||
SA_Depth, GRAY_SCREEN_DEPTH,
|
||||
SA_ShowTitle, FALSE,
|
||||
TAG_DONE );
|
||||
|
||||
if ( fts == NULL )
|
||||
{
|
||||
PutStr( "Could not open custom screen\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set gray palette */
|
||||
SetPalette();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* open custom screen */
|
||||
fts = (struct Screen*)OpenScreenTags(
|
||||
NULL,
|
||||
SA_DisplayID, (PAL_MONITOR_ID | HIRESLACE_KEY),
|
||||
SA_Width, MONO_SCREEN_WIDTH,
|
||||
SA_Height, MONO_SCREEN_HEIGHT,
|
||||
SA_Depth, MONO_SCREEN_DEPTH,
|
||||
SA_ShowTitle, FALSE,
|
||||
TAG_DONE );
|
||||
|
||||
if ( fts == NULL )
|
||||
{
|
||||
PutStr( "Could not open custom screen\n" );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* open intuition window */
|
||||
ftw = OpenWindowTags(
|
||||
NULL,
|
||||
WA_Left, 0,
|
||||
WA_Width, fts->Width,
|
||||
WA_Top, 0,
|
||||
WA_Height, fts->Height,
|
||||
WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_MOUSEBUTTONS,
|
||||
WA_Flags, WFLG_BACKDROP | WFLG_BORDERLESS |
|
||||
WFLG_RMBTRAP | WFLG_ACTIVATE,
|
||||
WA_Gadgets, NULL,
|
||||
WA_Title, NULL,
|
||||
WA_CustomScreen, fts,
|
||||
TAG_DONE );
|
||||
|
||||
if ( ftw == NULL )
|
||||
{
|
||||
PutStr( "Could not open intuition window\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
Vio = (char*)AllocMem( DISPLAY_MEM, MEMF_ANY );
|
||||
|
||||
if ( !Vio )
|
||||
{
|
||||
PutStr( "Cannot AllocMem() display memory\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
vio_Width = vio_ScanLineWidth = GRAY_SCREEN_WIDTH;
|
||||
vio_Height = GRAY_SCREEN_HEIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vio = (char*)fts->BitMap.Planes[0];
|
||||
vio_ScanLineWidth = fts->BitMap.BytesPerRow;
|
||||
vio_Width = MONO_SCREEN_WIDTH;
|
||||
vio_Height = MONO_SCREEN_HEIGHT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* get events in the window */
|
||||
|
||||
static char Get_Intuition_Event( void )
|
||||
{
|
||||
struct IntuiMessage* msg;
|
||||
ULONG class;
|
||||
USHORT code;
|
||||
|
||||
|
||||
WaitPort( ftw->UserPort );
|
||||
|
||||
while ( ( msg = (struct IntuiMessage*)GetMsg( ftw->UserPort ) ) )
|
||||
{
|
||||
class = msg->Class;
|
||||
code = msg->Code;
|
||||
|
||||
ReplyMsg( (struct Message*)msg );
|
||||
|
||||
switch ( class )
|
||||
{
|
||||
case IDCMP_MOUSEBUTTONS:
|
||||
return (char)27;
|
||||
|
||||
case IDCMP_VANILLAKEY:
|
||||
return (char)code;
|
||||
}
|
||||
}
|
||||
|
||||
return '\0';
|
||||
}
|
||||
|
||||
|
||||
/* set Amiga graphics mode */
|
||||
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
graphx_mode = mode;
|
||||
|
||||
|
||||
if ( AmigaInit() == -1 )
|
||||
return 0; /* failure */
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* restore screen to its original state */
|
||||
|
||||
int Driver_Restore_Mode( void )
|
||||
{
|
||||
/* do nothing */
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* display bitmap */
|
||||
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col )
|
||||
{
|
||||
int y, z;
|
||||
char* target;
|
||||
char old = -1;
|
||||
|
||||
|
||||
target = Vio + ( line - 1 ) * vio_ScanLineWidth;
|
||||
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
CopyMem( buffer, target, col );
|
||||
target -= vio_ScanLineWidth;
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
/* clear screen */
|
||||
SetRast( &fts->RastPort, 0 );
|
||||
|
||||
/* draw glyph */
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
for ( z = 0; z < col; z++ )
|
||||
{
|
||||
int c = Vio[y * vio_ScanLineWidth + z];
|
||||
|
||||
if ( c != 0 )
|
||||
{
|
||||
if ( old != c )
|
||||
{
|
||||
if ( c < 0 || c > 5 )
|
||||
{
|
||||
PutStr( "Unexpected value!\n" );
|
||||
SetAPen( &fts->RastPort, 7 );
|
||||
}
|
||||
else
|
||||
{
|
||||
old = c;
|
||||
SetAPen( &fts->RastPort, c );
|
||||
}
|
||||
}
|
||||
|
||||
WritePixel( &fts->RastPort, z, y );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
|
||||
c = Get_Intuition_Event();
|
||||
|
||||
if ( c != '\0' )
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
event->what = trans[i].event_class;
|
||||
event->info = trans[i].event_info;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
|
||||
event->what = event_Keyboard;
|
||||
event->info = (int)c;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
522
test/arch/amigaos/gw_amiga.c
Normal file
522
test/arch/amigaos/gw_amiga.c
Normal file
@@ -0,0 +1,522 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gw_amiga.c graphics utility Intuition Amiga driver.
|
||||
*
|
||||
* This is the driver for windowed display under Amiga WorkBench,
|
||||
* used by the graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
/* modified by Richard Griffith
|
||||
open largest window we can, and adapt accordingly
|
||||
gray and mono both appear black on white
|
||||
display Header message in Window title
|
||||
add simple menus
|
||||
*/
|
||||
|
||||
/* standard includes */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* AmigaOS includes */
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <intuition/screens.h>
|
||||
#include <libraries/gadtools.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <inline/exec.h>
|
||||
#include <inline/intuition.h>
|
||||
#include <inline/graphics.h>
|
||||
#include <inline/dos.h>
|
||||
#include <inline/gadtools.h>
|
||||
#else
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
#include <clib/dos_protos.h>
|
||||
#include <clib/gadtools_protos.h>
|
||||
#endif
|
||||
|
||||
/* FreeType includes */
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
/* some screen definitions */
|
||||
|
||||
#define MONO_WINDOW_WIDTH 0xFFFF
|
||||
#define MONO_WINDOW_HEIGHT 0xFFFF
|
||||
|
||||
#define GRAY_WINDOW_WIDTH 0xFFFF
|
||||
#define GRAY_WINDOW_HEIGHT 0xFFFF
|
||||
|
||||
#define DISPLAY_MEM ( 1024 * 64 )
|
||||
|
||||
|
||||
/* external variables */
|
||||
extern struct Library* SysBase;
|
||||
extern struct Library* DOSBase;
|
||||
|
||||
extern int vio_ScanLineWidth;
|
||||
extern char* Vio;
|
||||
/* extern char gray_palette[5]; */
|
||||
|
||||
/* global variables */
|
||||
struct Library* IntuitionBase = NULL;
|
||||
struct Library* GfxBase = NULL;
|
||||
struct Library *GadToolsBase = NULL;
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
|
||||
/* local variables */
|
||||
static struct Screen* fts = NULL;
|
||||
static struct Window* ftw = NULL;
|
||||
static APTR VisualInfo = NULL;
|
||||
static struct Menu *ftmenus = NULL;
|
||||
|
||||
static int graphx_mode;
|
||||
|
||||
static ULONG vio_allocsize;
|
||||
|
||||
static struct NewMenu ftNewMenu[] = {
|
||||
{NM_TITLE, (STRPTR)"File", NULL, 0, NULL, NULL},
|
||||
{NM_ITEM, (STRPTR)"Next", (STRPTR)"n", 0, 0L, (APTR)'n'},
|
||||
{NM_ITEM, (STRPTR)"Previous",(STRPTR)"p", 0, 0L, (APTR)'p'},
|
||||
{NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL},
|
||||
{NM_ITEM, (STRPTR)"Quit", (STRPTR)"q", 0, 0L, (APTR)'q'},
|
||||
{NM_TITLE, (STRPTR)"Options", NULL, 0, NULL, NULL},
|
||||
{NM_ITEM, (STRPTR)"Scale Up", NULL, 0, NULL, NULL},
|
||||
{NM_SUB, (STRPTR)"Fine", (STRPTR)"u", 0, 0L, (APTR)'u'},
|
||||
{NM_SUB, (STRPTR)"Fast", (STRPTR)"+", 0, 0L, (APTR)'+'},
|
||||
{NM_ITEM, (STRPTR)"Scale Down", NULL, 0, NULL, NULL},
|
||||
{NM_SUB, (STRPTR)"Fine", (STRPTR)"j", 0, 0L, (APTR)'j'},
|
||||
{NM_SUB, (STRPTR)"Fast", (STRPTR)"-", 0, 0L, (APTR)'-'},
|
||||
{NM_ITEM, (STRPTR)"Toggle Hinting", (STRPTR)"h", 0, 0L, (APTR)'h'},
|
||||
{NM_ITEM, (STRPTR)"Toggle Kerning", (STRPTR)"K", 0, 0L, (APTR)'K'},
|
||||
{NM_ITEM, (STRPTR)"Toggle sbit", (STRPTR)"B", 0, 0L, (APTR)'B'},
|
||||
{NM_ITEM, (STRPTR)"Toggle GSUB", (STRPTR)"G", 0, 0L, (APTR)'G'},
|
||||
{NM_TITLE, (STRPTR)"Glyph", NULL, 0, NULL, NULL},
|
||||
{NM_ITEM, (STRPTR)"Next", NULL, 0, NULL, NULL},
|
||||
{NM_SUB, (STRPTR)"1", (STRPTR)"l", 0, 0L, (APTR)'l'},
|
||||
{NM_SUB, (STRPTR)"10", (STRPTR)"o", 0, 0L, (APTR)'o'},
|
||||
{NM_SUB, (STRPTR)"100", (STRPTR)"0", 0, 0L, (APTR)'0'},
|
||||
{NM_SUB, (STRPTR)"1000", (STRPTR)")", 0, 0L, (APTR)')'},
|
||||
{NM_SUB, (STRPTR)"10000",(STRPTR)"}", 0, 0L, (APTR)'}'},
|
||||
{NM_ITEM, (STRPTR)"Previous", NULL, 0, NULL, NULL},
|
||||
{NM_SUB, (STRPTR)"1", (STRPTR)"k", 0, 0L, (APTR)'k'},
|
||||
{NM_SUB, (STRPTR)"10", (STRPTR)"i", 0, 0L, (APTR)'i'},
|
||||
{NM_SUB, (STRPTR)"100", (STRPTR)"9", 0, 0L, (APTR)'9'},
|
||||
{NM_SUB, (STRPTR)"1000", (STRPTR)"(", 0, 0L, (APTR)'('},
|
||||
{NM_SUB, (STRPTR)"10000",(STRPTR)"{", 0, 0L, (APTR)'{'},
|
||||
{NM_TITLE, (STRPTR)"Rotate", NULL, 0, NULL, NULL},
|
||||
{NM_ITEM, (STRPTR)"Clockwise", NULL, 0, NULL, NULL},
|
||||
{NM_SUB, (STRPTR)"Fine", (STRPTR)"c", 0, 0L, (APTR)'c'},
|
||||
{NM_SUB, (STRPTR)"Fast", (STRPTR)"b", 0, 0L, (APTR)'b'},
|
||||
{NM_ITEM, (STRPTR)"Counter-clockwise", NULL, 0, NULL, NULL},
|
||||
{NM_SUB, (STRPTR)"Fine", (STRPTR)"x", 0, 0L, (APTR)'x'},
|
||||
{NM_SUB, (STRPTR)"Fast", (STRPTR)"v", 0, 0L, (APTR)'v'},
|
||||
{NM_END, NULL, NULL, 0, 0L, NULL} };
|
||||
|
||||
|
||||
/* Exit gracefully */
|
||||
static void AmigaCleanUp( void )
|
||||
{
|
||||
if ( Vio )
|
||||
FreeMem( Vio, vio_allocsize );
|
||||
|
||||
ReleasePen( fts->ViewPort.ColorMap, gray_palette[0] );
|
||||
ReleasePen( fts->ViewPort.ColorMap, gray_palette[1] );
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
ReleasePen( fts->ViewPort.ColorMap, gray_palette[2] );
|
||||
ReleasePen( fts->ViewPort.ColorMap, gray_palette[3] );
|
||||
ReleasePen( fts->ViewPort.ColorMap, gray_palette[4] );
|
||||
}
|
||||
|
||||
if ( ftmenus )
|
||||
{
|
||||
ClearMenuStrip( ftw );
|
||||
FreeMenus( ftmenus );
|
||||
}
|
||||
|
||||
if ( ftw )
|
||||
CloseWindow( ftw );
|
||||
|
||||
if ( VisualInfo )
|
||||
FreeVisualInfo( VisualInfo );
|
||||
|
||||
if ( GfxBase )
|
||||
CloseLibrary( GfxBase );
|
||||
|
||||
if ( GadToolsBase )
|
||||
CloseLibrary( GadToolsBase );
|
||||
|
||||
if ( IntuitionBase )
|
||||
CloseLibrary( IntuitionBase );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* open libraries & custom screen */
|
||||
static int AmigaInit( void )
|
||||
{
|
||||
/* cleanup at exit */
|
||||
if ( atexit( AmigaCleanUp ) )
|
||||
{
|
||||
PutStr( "atexit() failed\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* open intuition library */
|
||||
IntuitionBase = (struct Library*)OpenLibrary( "intuition.library", 39L );
|
||||
if ( IntuitionBase == NULL )
|
||||
{
|
||||
PutStr( "Could not open intuition library\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* open gaadtools library */
|
||||
GadToolsBase = (struct Library*)OpenLibrary( "gadtools.library", 39L );
|
||||
if ( GadToolsBase == NULL )
|
||||
{
|
||||
PutStr( "Could not open gadtools library\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* open graphics library */
|
||||
GfxBase = OpenLibrary( "graphics.library", 39L );
|
||||
if ( GfxBase == NULL )
|
||||
{
|
||||
PutStr( "Could not open graphics library\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* get public screen */
|
||||
fts = LockPubScreen( NULL );
|
||||
|
||||
if ( fts == NULL )
|
||||
{
|
||||
PutStr( "Could not lock public screen\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( ! ( VisualInfo = GetVisualInfo( fts, TAG_DONE )))
|
||||
{
|
||||
PutStr( "Could not get VisualInfo\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
vio_ScanLineWidth = GRAY_WINDOW_WIDTH;
|
||||
vio_Width = GRAY_WINDOW_WIDTH;
|
||||
vio_Height = GRAY_WINDOW_HEIGHT;
|
||||
|
||||
gray_palette[4] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0x00000000, 0x00000000, 0x00000000, NULL );
|
||||
gray_palette[3] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0x33333300, 0x33333300, 0x33333300, NULL );
|
||||
gray_palette[2] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0x77777700, 0x77777700, 0x77777700, NULL );
|
||||
gray_palette[1] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0xBBBBBB00, 0xBBBBBB00, 0xBBBBBB00, NULL );
|
||||
gray_palette[0] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
vio_ScanLineWidth = MONO_WINDOW_WIDTH / 8;
|
||||
vio_Width = MONO_WINDOW_WIDTH;
|
||||
vio_Height = MONO_WINDOW_HEIGHT;
|
||||
|
||||
gray_palette[0] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, NULL );
|
||||
gray_palette[1] = ObtainBestPenA( fts->ViewPort.ColorMap,
|
||||
0x00000000, 0x00000000, 0x00000000, NULL );
|
||||
}
|
||||
|
||||
if ( ! ( ftmenus = CreateMenus( ftNewMenu, GTMN_FrontPen, 0L, TAG_DONE)))
|
||||
{
|
||||
PutStr( "Could not create menus\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
LayoutMenus( ftmenus, VisualInfo, GTMN_NewLookMenus, TRUE, TAG_DONE );
|
||||
|
||||
/* open intuition window */
|
||||
ftw = OpenWindowTags(
|
||||
NULL,
|
||||
WA_InnerWidth, vio_Width,
|
||||
WA_InnerHeight, vio_Height,
|
||||
WA_IDCMP, IDCMP_MENUPICK | IDCMP_VANILLAKEY | IDCMP_CLOSEWINDOW,
|
||||
/* WA_AutoAdjust, TRUE, */
|
||||
WA_CloseGadget, TRUE,
|
||||
WA_Activate, TRUE,
|
||||
WA_DragBar, TRUE,
|
||||
WA_SmartRefresh, TRUE,
|
||||
WA_Gadgets, NULL,
|
||||
WA_Flags, WFLG_DEPTHGADGET | WFLG_SMART_REFRESH,
|
||||
WA_Title, (UBYTE*)"FreeType Project",
|
||||
WA_NewLookMenus, TRUE,
|
||||
WA_PubScreen, fts,
|
||||
TAG_DONE );
|
||||
|
||||
if ( ftw == NULL )
|
||||
{
|
||||
PutStr( "Could not open intuition window\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
SetMenuStrip( ftw, ftmenus );
|
||||
|
||||
UnlockPubScreen( NULL, fts );
|
||||
|
||||
vio_Height = ftw->Height - ftw->BorderTop - ftw->BorderBottom - 2;
|
||||
vio_Width = (ftw->Width - ftw->BorderLeft - ftw->BorderRight) & 0xFFFFFC;
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
vio_ScanLineWidth = vio_Width;
|
||||
} else {
|
||||
vio_ScanLineWidth = vio_Width / 8;
|
||||
}
|
||||
vio_allocsize = vio_Height * vio_ScanLineWidth;
|
||||
|
||||
Vio = (char*)AllocMem( vio_allocsize, MEMF_ANY );
|
||||
if ( Vio == NULL )
|
||||
{
|
||||
PutStr( "Could not allocate memory\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* get events in the window */
|
||||
static char Get_Intuition_Event( void )
|
||||
{
|
||||
struct IntuiMessage* msg;
|
||||
ULONG class;
|
||||
USHORT code;
|
||||
int rc;
|
||||
struct MenuItem *n;
|
||||
|
||||
|
||||
WaitPort( ftw->UserPort );
|
||||
|
||||
while ( ( msg = (struct IntuiMessage*)GetMsg( ftw->UserPort ) ) )
|
||||
{
|
||||
class = msg->Class;
|
||||
code = msg->Code;
|
||||
|
||||
ReplyMsg( (struct Message*)msg );
|
||||
|
||||
switch( class )
|
||||
{
|
||||
case IDCMP_REFRESHWINDOW:
|
||||
GT_BeginRefresh( ftw );
|
||||
GT_EndRefresh( ftw, TRUE );
|
||||
break;
|
||||
|
||||
case IDCMP_CLOSEWINDOW:
|
||||
return (char)27;
|
||||
|
||||
case IDCMP_VANILLAKEY:
|
||||
return (char)code;
|
||||
|
||||
case IDCMP_MENUPICK:
|
||||
while( code != MENUNULL )
|
||||
{
|
||||
n = ItemAddress( ftmenus, code );
|
||||
rc = (int)GTMENUITEM_USERDATA( n );
|
||||
code = n->NextSelect;
|
||||
} /* despite loop, we only do one */
|
||||
return (char)rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return '\0';
|
||||
}
|
||||
|
||||
|
||||
/* Set Amiga graphics mode */
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
graphx_mode = mode;
|
||||
|
||||
if ( AmigaInit() == -1 )
|
||||
return 0; /* failure */
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* restore screen to its original state */
|
||||
int Driver_Restore_Mode( void )
|
||||
{
|
||||
/* Do nothing */
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* display bitmap */
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col )
|
||||
{
|
||||
int y, z;
|
||||
char* target;
|
||||
char old = 0;
|
||||
extern char Header[];
|
||||
|
||||
SetWindowTitles(ftw,Header,Header);
|
||||
|
||||
|
||||
target = Vio + ( line - 1 ) * vio_ScanLineWidth;
|
||||
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
CopyMem( buffer, target, col );
|
||||
target -= vio_ScanLineWidth;
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
/* clear window */
|
||||
/* SetRast( ftw->RPort, gray_palette[0] ); */
|
||||
|
||||
SetAPen( ftw->RPort, gray_palette[0] );
|
||||
|
||||
RectFill( ftw->RPort, ftw->BorderLeft, ftw->BorderTop,
|
||||
ftw->Width - ftw->BorderRight - 1,
|
||||
ftw->Height - ftw->BorderBottom - 1 );
|
||||
|
||||
if ( graphx_mode != Graphics_Mode_Gray )
|
||||
{
|
||||
SetAPen( ftw->RPort, gray_palette[1] );
|
||||
old = 1;
|
||||
}
|
||||
|
||||
/* Draw glyph */
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
for ( z = 0; z < col; z++ )
|
||||
{
|
||||
int c = Vio[y * vio_ScanLineWidth + z];
|
||||
|
||||
if ( graphx_mode == Graphics_Mode_Gray )
|
||||
{
|
||||
if ( c != 0 && c != gray_palette[0] )
|
||||
{
|
||||
if ( old != c )
|
||||
{
|
||||
old = c;
|
||||
/* printf("x = %d, y = %d, color = %d\n", z, y, c ); */
|
||||
SetAPen( ftw->RPort, c );
|
||||
}
|
||||
|
||||
WritePixel( ftw->RPort, ftw->BorderLeft + z, ftw->BorderTop + y );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mask = 0x80;
|
||||
int counter = 0;
|
||||
|
||||
while ( mask )
|
||||
{
|
||||
if ( mask & c )
|
||||
WritePixel( ftw->RPort, ftw->BorderLeft + z * 8 + counter,
|
||||
ftw->BorderTop + y );
|
||||
|
||||
counter++;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
|
||||
c = Get_Intuition_Event();
|
||||
|
||||
if ( c != '\0' )
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
event->what = trans[i].event_class;
|
||||
event->info = trans[i].event_info;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
|
||||
event->what = event_Keyboard;
|
||||
event->info = (int)c;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
180
test/arch/amigaos/smakefile
Normal file
180
test/arch/amigaos/smakefile
Normal file
@@ -0,0 +1,180 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for amiga using SAS/C
|
||||
# and smake
|
||||
#
|
||||
# Use this file while in the 'test/arch/amigaos' directory with
|
||||
# the following statements:
|
||||
#
|
||||
# smake assign
|
||||
# smake
|
||||
#
|
||||
# the 'assign' step creates an assignment to simplify referencing
|
||||
# the core library module, as smake has quite a few limitations in
|
||||
# dealing with multi-directory projects.
|
||||
|
||||
OBJB = ttapi.o ttcache.o ttcalc.o ttcmap.o ttdebug.o \
|
||||
ttextend.o ttfile.o ttgload.o ttinterp.o ttload.o \
|
||||
ttmemory.o ttmutex.o ttobjs.o ttraster.o
|
||||
|
||||
OBJS = freetype.o
|
||||
|
||||
OBJX = ftxgasp.o ftxkern.o ftxpost.o ftxcmap.o ftxwidth.o ftxerr18.o \
|
||||
ftxsbit.o ftxgsub.o ftxopen.o
|
||||
|
||||
CORE = FT:lib/
|
||||
COREXT = $(CORE)extend/
|
||||
TST = FT:test/
|
||||
|
||||
OPTIMIZER = optimize optcomp=5 optdep=4 optinlocal optrdep=4
|
||||
|
||||
SCFLAGS = idlen=40 idir=$(CORE)arch/amigaos idir=$(CORE)
|
||||
|
||||
TSCFLAGS = $(SCFLAGS) idir=$(TST) idir=$(COREXT)
|
||||
|
||||
LIB=ttf.lib
|
||||
TOPTS=$(TSCFLAGS) link lib=$(LIB) lib=lib:scm.lib \
|
||||
lib=lib:sc.lib lib=lib:amiga.lib
|
||||
|
||||
EXE = ftzoom ftlint ftview fttimer ftmetric \
|
||||
ftdump ftstring ftstrpnm ftsbit ftstrtto
|
||||
|
||||
TOBJ = gw_amiga.o gmain.o common.o blitter.o
|
||||
|
||||
all: ttf.lib $(EXE)
|
||||
|
||||
assign:
|
||||
assign FT: ///
|
||||
|
||||
ttf.lib: $(OBJS) $(OBJX)
|
||||
oml $@ r $(OBJS) $(OBJX)
|
||||
|
||||
ttfdbg.lib: $(OBJB) $(OBJX)
|
||||
oml $@ r $(OBJB) $(OBJX)
|
||||
|
||||
clean:
|
||||
-delete \#?.o
|
||||
-delete //\#?.o
|
||||
-delete \#?.lib
|
||||
-delete $(EXE)
|
||||
|
||||
|
||||
#
|
||||
# freetype library core single object
|
||||
#
|
||||
freetype.o: $(CORE)arch/amigaos/freetype.c
|
||||
sc $(SCFLAGS) code=far $(OPTIMIZER) objname=$@ $<
|
||||
|
||||
#
|
||||
# freetype library core as separate objects
|
||||
#
|
||||
ttapi.o: $(CORE)ttapi.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttcache.o: $(CORE)ttcache.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttcalc.o: $(CORE)ttcalc.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttcmap.o: $(CORE)ttcmap.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttdebug.o: $(CORE)ttdebug.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttextend.o: $(CORE)ttextend.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttfile.o: $(CORE)ttfile.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttgload.o: $(CORE)ttgload.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttinterp.o: $(CORE)ttinterp.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttload.o: $(CORE)ttload.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttmemory.o: $(CORE)ttmemory.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttmutex.o: $(CORE)ttmutex.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttobjs.o: $(CORE)ttobjs.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ttraster.o: $(CORE)ttraster.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
|
||||
#
|
||||
# library extentions
|
||||
#
|
||||
ftxgasp.o: $(COREXT)ftxgasp.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxkern.o: $(COREXT)ftxkern.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxpost.o: $(COREXT)ftxpost.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxcmap.o: $(COREXT)ftxcmap.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxwidth.o: $(COREXT)ftxwidth.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxerr18.o: $(COREXT)ftxerr18.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxsbit.o: $(COREXT)ftxsbit.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxgsub.o: $(COREXT)ftxgsub.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
ftxopen.o: $(COREXT)ftxopen.c
|
||||
sc $(SCFLAGS) objname=$@ $<
|
||||
|
||||
#
|
||||
# Test programs
|
||||
#
|
||||
ftzoom: $(TST)ftzoom.c $(TOBJ) $(LIB)
|
||||
sc $(TST)ftzoom.c programname=$@ $(TOBJ) $(TOPTS)
|
||||
|
||||
ftlint: $(TST)ftlint.c common.o $(LIB)
|
||||
sc $(TST)ftlint.c programname=$@ common.o $(TOPTS)
|
||||
|
||||
ftdump: $(TST)ftdump.c common.o $(LIB)
|
||||
sc $(TST)ftdump.c programname=$@ common.o $(TOPTS)
|
||||
|
||||
# use unsigned char so full latin1 encoding may be used in string argument
|
||||
ftstring: $(TST)ftstring.c $(TOBJ) display.o $(LIB)
|
||||
sc $(TST)ftstring.c uchar programname=$@ $(TOBJ) display.o $(TOPTS)
|
||||
|
||||
ftview: $(TST)ftview.c $(TOBJ) display.o $(LIB)
|
||||
sc $(TST)ftview.c programname=$@ $(TOBJ) display.o $(TOPTS)
|
||||
|
||||
fttimer: $(TST)fttimer.c $(TOBJ) $(LIB)
|
||||
sc $(TST)fttimer.c programname=$@ $(TOBJ) $(TOPTS)
|
||||
|
||||
ftstrpnm: $(TST)ftstrpnm.c common.o $(LIB)
|
||||
sc $(TST)ftstrpnm.c uchar programname=$@ common.o $(TOPTS)
|
||||
|
||||
ftsbit: $(TST)ftsbit.c common.o $(LIB)
|
||||
sc $(TST)ftsbit.c programname=$@ common.o $(TOPTS)
|
||||
|
||||
ftmetric: $(TST)ftmetric.c common.o $(LIB)
|
||||
sc $(TST)ftmetric.c programname=$@ common.o $(TOPTS)
|
||||
|
||||
# use unsigned char so full latin1/UTF8 encoding may be used in argument
|
||||
ftstrtto: $(TST)ftstrtto.c $(TOBJ) display.o arabic.o $(LIB)
|
||||
sc $(TST)ftstrtto.c uchar programname=$@ $(TOBJ) \
|
||||
arabic.o display.o $(TOPTS)
|
||||
|
||||
#
|
||||
# Test program support modules
|
||||
#
|
||||
|
||||
gw_amiga.o: gw_amiga.c
|
||||
sc gw_amiga.c $(TSCFLAGS)
|
||||
|
||||
common.o: $(TST)common.c
|
||||
sc $(TSCFLAGS) objname=$@ $<
|
||||
|
||||
blitter.o: $(TST)blitter.c
|
||||
sc $(TSCFLAGS) objname=$@ $<
|
||||
|
||||
display.o: $(TST)display.c
|
||||
sc $(TSCFLAGS) objname=$@ $<
|
||||
|
||||
gmain.o: $(TST)gmain.c
|
||||
sc $(TSCFLAGS) objname=$@ $<
|
||||
|
||||
arabic.o: $(TST)arabic.c
|
||||
sc $(TSCFLAGS) objname=$@ $<
|
||||
|
||||
# end of smakefile
|
||||
99
test/arch/debugger/Makefile
Normal file
99
test/arch/debugger/Makefile
Normal file
@@ -0,0 +1,99 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the debugger for emx-gcc under OS/2 resp. under Unix.
|
||||
#
|
||||
# You will need GNU make.
|
||||
#
|
||||
# Use this file while in the `test' directory with the following statement:
|
||||
#
|
||||
# make -f arch/debugger/Makefile
|
||||
|
||||
ARCH = arch/debugger
|
||||
FT_MAKEFILE = $(ARCH)/Makefile
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
LIBTTF = $(LIBDIR)/$(ARCH)/libttf.a
|
||||
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/extend -I$(LIBDIR)/$(ARCH) -I.
|
||||
|
||||
# Note: The debugger uses non-ANSI functions to read the keyboard
|
||||
# on OS/2 -- do not set the `-ansi flag here.
|
||||
#
|
||||
CFLAGS = -Wall -O0 -g $(INCDIRS)
|
||||
|
||||
|
||||
SRC = fdebug.c common.c
|
||||
|
||||
ALLSRC = $(SRC)
|
||||
ALLOBJ = $(ALLSRC:.c=.o)
|
||||
|
||||
# on OS/2, do not use the curses library
|
||||
#
|
||||
ifdef OS2_SHELL
|
||||
EXE := fdebug.exe
|
||||
OS := OS2
|
||||
EFENCE :=
|
||||
EXTRAFLAGS :=
|
||||
RM := del
|
||||
else
|
||||
EXE := fdebug
|
||||
OS := UNIX
|
||||
EFENCE := -lefence
|
||||
RM := rm -f
|
||||
#
|
||||
# POSIX TERMIOS: Do not define if you use OLD U*ix like 4.2BSD.
|
||||
#
|
||||
EXTRAFLAGS := HAVE_POSIX_TERMIOS
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $< -D$(OS) -D$(EXTRAFLAGS)
|
||||
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
|
||||
|
||||
EXEFILES = $(EXE)
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
$(EXE): fdebug.o common.o $(LIBTTF)
|
||||
$(EXE):
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(EFENCE)
|
||||
|
||||
freetype:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all
|
||||
|
||||
freetype_debug:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug
|
||||
|
||||
|
||||
clean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean
|
||||
|
||||
distclean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
|
||||
-$(RM) dep.end $(EXEFILES) core
|
||||
|
||||
do_clean:
|
||||
-$(RM) $(subst /,\,$(ALLOBJ))
|
||||
|
||||
|
||||
depend: $(ALLSRC)
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
|
||||
$(CC) -E -M $(INCDIRS) $^ > dep.end
|
||||
|
||||
ifeq (dep.end,$(wildcard dep.end))
|
||||
include dep.end
|
||||
endif
|
||||
|
||||
# end of Makefile.emx
|
||||
181
test/arch/msdos/Makefile.BC
Normal file
181
test/arch/msdos/Makefile.BC
Normal file
@@ -0,0 +1,181 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for BC++ under MSDOS, large model.
|
||||
#
|
||||
# Tested with Borland C++ v.3.1, 4.02, 5.0
|
||||
# You will need Borland MAKE (v.3.6 and above should be OK, for oldest
|
||||
# versions refer to the instructions below).
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -farch\msdos\Makefile.BC
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained with
|
||||
#
|
||||
# make -DDEBUG -farch\msdos\Makefile.BC
|
||||
#
|
||||
# A special version enabled to handle big fonts (with more than 16,384
|
||||
# glyphs) can be obtained with
|
||||
#
|
||||
# make -DBIGFONTS -farch\msdos\Makefile.BC
|
||||
|
||||
ARCH = arch\msdos
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.BC
|
||||
|
||||
CC = bcc
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR);$(LIBDIR)\$(ARCH);.;$(LIBDIR)\extend
|
||||
SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -w-pia
|
||||
|
||||
# Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern
|
||||
# Borland compilers (from BC++ 3.1 on) can increase the limit of
|
||||
# the length of identifiers.
|
||||
!if ! $d(DEBUG)
|
||||
CFLAGS = -ml -A -O2 -3 -i40 $(INCDIRS) $(SPURIOUS_WARNINGS)
|
||||
LDFLAGS = -ml
|
||||
!else
|
||||
CFLAGS = -v -N -ml -A -i40 $(INCDIRS) $(SPURIOUS_WARNINGS)
|
||||
LDFLAGS = -v -ml
|
||||
!endif
|
||||
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GDRIVER = $(ARCH)\.\gfs_dos.c
|
||||
|
||||
DISPLAY = display.c
|
||||
|
||||
G1SRC = gmain.c blitter.c $(GDRIVER)
|
||||
GSRC = $(DISPLAY) $(G1SRC)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
G1OBJ = $(G1SRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
$(CC) -c -o$* @&&|
|
||||
$(CFLAGS) $<
|
||||
|
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!if !$d(DEBUG)
|
||||
# Skipped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
!if $d(BIGFONTS)
|
||||
MAKEBIG = -DBIGFONTS
|
||||
!endif
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) $(MAKEBIG) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDEBUG $(MAKEBIG) debug
|
||||
cd ..\test
|
||||
|
||||
|
||||
# Borland C compilers are unable to include <dos.h> in ANSI mode.
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER:.c=.obj):
|
||||
$(CC) -c -o$* @&&|
|
||||
$(CFLAGS) -A- $*.c
|
||||
|
|
||||
|
||||
.obj.exe:
|
||||
$(CC) -e$* @&&|
|
||||
$(LDFLAGS) $**
|
||||
|
|
||||
|
||||
# Borland versions of make are unable to use the $** variable inside
|
||||
# implicit rules (like .obj.exe:). The job has to be done by hand. :-(
|
||||
ftzoom.exe: $(G1OBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftzoom.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftview.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstring.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrtto.obj $(GOBJ) common.obj arabic.obj \
|
||||
$(LIBDIR)\libttf.lib
|
||||
|
||||
fttimer.exe: $(G1OBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fttimer.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
del time.h # clean the ugly hack for Turbo C...
|
||||
|
||||
!include "$(ARCH)\depend.dos"
|
||||
|
||||
# end of Makefile
|
||||
142
test/arch/msdos/Makefile.MS
Normal file
142
test/arch/msdos/Makefile.MS
Normal file
@@ -0,0 +1,142 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for Microsoft C for MS-DOS,
|
||||
# large model. It also works for Visual C++ 1.x 16-bits compiler, but
|
||||
# you should instead use the Makefile customized for it, Makefile.VC.
|
||||
#
|
||||
# You will need NMAKE.
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# nmake /f arch\msdos\Makefile.MS
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained with
|
||||
#
|
||||
# nmake DEBUG=1 /f arch\msdos\Makefile.MS
|
||||
#
|
||||
# A special version enabled to handle big fonts (with more than 16,384
|
||||
# glyphs) can be obtained with
|
||||
#
|
||||
# nmake BIGFONTS=1 /f arch\msdos\Makefile.MS
|
||||
|
||||
ARCH = arch\msdos
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.MS
|
||||
FT_MAKE = $(MAKE) /nologo
|
||||
|
||||
CC = cl /nologo
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\$(ARCH) -I. -I$(LIBDIR)\extend
|
||||
|
||||
!ifndef DEBUG
|
||||
CFLAGS = /Ox /AL /Za /W2 /G2 $(INCDIRS)
|
||||
LDFLAGS = /AL
|
||||
!else
|
||||
CFLAGS = /Zi /AL /Za /W2 /G2 $(INCDIRS)
|
||||
LDFLAGS = /Zi /AL
|
||||
!endif
|
||||
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GDRIVER = $(ARCH)\gfs_dos.c
|
||||
|
||||
GSRC = display.c gmain.c blitter.c $(GDRIVER)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) $<
|
||||
<<
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!ifndef DEBUG
|
||||
# Skiped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
!ifdef BIGFONTS
|
||||
MAKEBIG = BIGFONTS=1
|
||||
!endif
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) $(MAKEBIG) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 $(MAKEBIG) debug
|
||||
cd ..\test
|
||||
|
||||
.obj.exe:
|
||||
$(CC) /Fe$* @<<
|
||||
$(LDFLAGS) $**
|
||||
<<
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
fttimer.exe: $(GOBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
|
||||
|
||||
!include "$(ARCH)\depend.dos"
|
||||
|
||||
# end of Makefile.MS
|
||||
196
test/arch/msdos/Makefile.TC
Normal file
196
test/arch/msdos/Makefile.TC
Normal file
@@ -0,0 +1,196 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for Turbo C under MSDOS, large model.
|
||||
#
|
||||
# You will need Borland MAKE.
|
||||
# Tested with Turbo C v.1.5, v.2.0, Turbo C++ v.1.0
|
||||
# Turbo C v.1.0 (May '87) is too old (lack of structure assignment)
|
||||
# to compile FreeType. Update your compiler. ;-)
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -farch\msdos\Makefile.TC
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained (except for TC 1.5) with
|
||||
#
|
||||
# make -DDEBUG -farch\msdos\Makefile.TC
|
||||
|
||||
ARCH = arch\msdos
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.TC
|
||||
|
||||
CC = tcc
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR);$(LIBDIR)\$(ARCH);.;$(LIBDIR)\extend
|
||||
|
||||
!if ! $d(DEBUG)
|
||||
CFLAGS = -ml -A -O -Z -G -a -w-stv -w-sig $(INCDIRS)
|
||||
LDFLAGS = -ml
|
||||
!else
|
||||
# For Turbo C v.1.5, replace the -v option below by -y.
|
||||
CFLAGS = -v -N -ml -A -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig $(INCDIRS)
|
||||
LDFLAGS = -v -ml
|
||||
!endif
|
||||
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GDRIVER = $(ARCH)\.\gfs_dos.obj
|
||||
|
||||
# the line below does not work with these old versions of make...
|
||||
# GOBJ = $(GSRC:.c=.o)
|
||||
|
||||
DISPLAY = display.obj
|
||||
|
||||
G1OBJ = gmain.obj blitter.obj $(GDRIVER)
|
||||
GOBJ = $(DISPLAY) $(G1OBJ)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = arabic.obj \
|
||||
common.obj \
|
||||
ftdump.obj \
|
||||
fterror.obj \
|
||||
ftlint.obj \
|
||||
ftmetric.obj \
|
||||
ftsbit.obj \
|
||||
ftstring.obj \
|
||||
ftstrpnm.obj \
|
||||
ftstrtto.obj \
|
||||
fttimer.obj \
|
||||
ftview.obj \
|
||||
ftzoom.obj
|
||||
|
||||
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) -c -o$* $<
|
||||
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
|
||||
!if !$d(DEBUG)
|
||||
# Skipped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDEBUG debug
|
||||
cd ..\test
|
||||
|
||||
|
||||
# Borland C compilers are unable to include <dos.h> in ANSI mode.
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER):
|
||||
$(CC) $(CFLAGS) -A- -c -o$* $*.c
|
||||
|
||||
!if $(__MAKE__) < 0x0300
|
||||
# Also, Turbo C v.1.5 and v.2.0 are not fully ANSI compliant with regard to
|
||||
# <time.h>, particularly the clock() function.
|
||||
# So we use an ugly hack here: a modified version of time.h, with the
|
||||
# necessary machinery, is included in the arch\msdos directory.
|
||||
time.h: $(ARCH)\time_tc.h
|
||||
copy $(ARCH)\time_tc.h time.h
|
||||
|
||||
# Below is the special rule for forcing recompilation of fttimer.obj
|
||||
# using our <time.h>, without using the rule that is pulled in by
|
||||
# !include "$(ARCH)\depend.dos" at the end of the Makefile...
|
||||
fttimer.exe: $(G1OBJ) fttimer.c time.h common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) -c -o$* $*.c
|
||||
$(CC) $(LDFLAGS) fttimer.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
!else
|
||||
# Normal behaviour
|
||||
fttimer.exe: $(G1OBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fttimer.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
!endif
|
||||
|
||||
|
||||
# This old gr... make is unable to have a $ variable to name all the
|
||||
# dependencies. :-( So the job have to be done by hand...
|
||||
ftzoom.exe: $(G1OBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftzoom.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftview.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstring.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrtto.obj $(GOBJ) common.obj \
|
||||
arabic.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
# fttimer.exe is handled above (because of <time.h> hack)
|
||||
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
del time.h # clean the ugly hack for Turbo C...
|
||||
|
||||
!include "$(ARCH)\depend.dos"
|
||||
|
||||
# end of Makefile
|
||||
143
test/arch/msdos/Makefile.VC
Normal file
143
test/arch/msdos/Makefile.VC
Normal file
@@ -0,0 +1,143 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for Microsoft Visual C++ 1.x
|
||||
# and Microsoft C/C++ v.7.0 16-bit compilers for MS-DOS, large model.
|
||||
#
|
||||
# You will need NMAKE.
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# nmake /f arch\msdos\Makefile.VC
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained with
|
||||
#
|
||||
# nmake DEBUG=1 /f arch\msdos\Makefile.VC
|
||||
#
|
||||
# A special version enabled to handle big fonts (with more than 16,384
|
||||
# glyphs) can be obtained with
|
||||
#
|
||||
# nmake BIGFONTS=1 /f arch\msdos\Makefile.VC
|
||||
|
||||
ARCH = arch\msdos
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.VC
|
||||
FT_MAKE = $(MAKE) /nologo
|
||||
|
||||
CC = cl /nologo
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\$(ARCH) -I. -I$(LIBDIR)\extend
|
||||
|
||||
# One can also consider using "set MSC_CMD_FLAGS=/Gr /Op- /Gy /YX".
|
||||
# With Microsoft C/C++ 7.0, use /G2 instead of /G3.
|
||||
!ifndef DEBUG
|
||||
CFLAGS = /Ox /AL /Za /W2 /G3 $(INCDIRS)
|
||||
LDFLAGS = /AL
|
||||
!else
|
||||
CFLAGS = /Zi /Ge /AL /Za /W2 /G3 $(INCDIRS)
|
||||
LDFLAGS = /Zi /AL
|
||||
!endif
|
||||
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GDRIVER = $(ARCH)\gfs_dos.c
|
||||
|
||||
GSRC = display.c gmain.c blitter.c $(GDRIVER)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) $<
|
||||
<<
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!ifndef DEBUG
|
||||
# Skiped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
!ifdef BIGFONTS
|
||||
MAKEBIG = BIGFONTS=1
|
||||
!endif
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) $(MAKEBIG) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 $(MAKEBIG) debug
|
||||
cd ..\test
|
||||
|
||||
.obj.exe:
|
||||
$(CC) /Fe$* @<<
|
||||
$(LDFLAGS) $**
|
||||
<<
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
fttimer.exe: $(GOBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
|
||||
|
||||
!include "$(ARCH)\depend.dos"
|
||||
|
||||
# end of Makefile.VC
|
||||
145
test/arch/msdos/Makefile.dm
Normal file
145
test/arch/msdos/Makefile.dm
Normal file
@@ -0,0 +1,145 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for emx-gcc and djgpp under MSDOS.
|
||||
#
|
||||
# You will need dmake.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# dmake -r -f arch/msdos/Makefile.dm
|
||||
|
||||
ARCH = arch/msdos
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.dm
|
||||
FT_MAKE = dmake -r
|
||||
|
||||
.IMPORT: COMSPEC
|
||||
SHELL := $(COMSPEC)
|
||||
SHELLFLAGS := /c
|
||||
GROUPSHELL := $(SHELL)
|
||||
GROUPFLAGS := $(SHELLFLAGS)
|
||||
GROUPSUFFIX := .bat
|
||||
SHELLMETAS := *"?<>&|
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
LIBDIR_DOS = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/$(ARCH) -I. -I$(LIBDIR)/extend
|
||||
|
||||
CFLAGS = -Wall -ansi -O2 -g $(INCDIRS)
|
||||
# CFLAGS = -ansi -Wall -O2 -s $(INCDIRS)
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GDRIVER = $(ARCH)/gfs_dos.c
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c $(GDRIVER)
|
||||
GOBJ = $(GSRC:.c=.o)
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ @$(mktmp $(&:t"\n")\n)
|
||||
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean do_distclean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
[
|
||||
cd $(LIBDIR_DOS)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) all
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
freetype_debug:
|
||||
[
|
||||
cd $(LIBDIR_DOS)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) debug
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview.exe: $(GOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring.exe: $(GOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer.exe: $(GOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
[
|
||||
cd $(LIBDIR_DOS)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) clean
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
distclean: do_clean do_distclean
|
||||
[
|
||||
cd $(LIBDIR_DOS)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) distclean
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
do_distclean:
|
||||
-[
|
||||
del dep.end
|
||||
del *.exe
|
||||
del core
|
||||
]
|
||||
|
||||
do_clean:
|
||||
-[
|
||||
del *.o
|
||||
del $(ARCH)\gfs_dos.o
|
||||
]
|
||||
|
||||
#depend: $(SRC) $(GSRC)
|
||||
#[
|
||||
# cd $(LIBDIR_DOS)
|
||||
# $(FT_MAKE) -f $(FT_MAKEFILE) depend
|
||||
# cd $(MAKEDIR)
|
||||
# $(CC) -E -M $(INCDIRS) @$(mktmp $(<:t"\n")\n) > dep.end
|
||||
#]
|
||||
#
|
||||
#ifeq (dep.end,$(wildcard dep.end))
|
||||
# include dep.end
|
||||
#endif
|
||||
|
||||
# end of Makefile.dm
|
||||
130
test/arch/msdos/Makefile.gcc
Normal file
130
test/arch/msdos/Makefile.gcc
Normal file
@@ -0,0 +1,130 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for emx-gcc and djgpp under MSDOS.
|
||||
#
|
||||
# You will need a recent GNU make DOS port.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -f arch/msdos/Makefile.gcc
|
||||
#
|
||||
#
|
||||
# If you have the GNU gettext package installed with DJGPP, you can also try
|
||||
#
|
||||
# make -f arch/msdos/Makefile.gcc HAVE_GETTEXT
|
||||
|
||||
ARCH = arch/msdos
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.gcc
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/$(ARCH) -I. -I$(LIBDIR)/extend
|
||||
|
||||
ifndef GETTEXT
|
||||
GETTEXT=NO_GETTEXT
|
||||
endif
|
||||
|
||||
CFLAGS = -Wall -ansi -O2 -g $(INCDIRS) -D$(GETTEXT)
|
||||
# CFLAGS = -ansi -Wall -O2 -s $(INCDIRS) -D$(GETTEXT)
|
||||
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GDRIVER = $(ARCH)/gfs_dos.c
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c $(GDRIVER)
|
||||
GOBJ = $(GSRC:.c=.o)
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
ifeq ($(GETTEXT),HAVE_GETTEXT)
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ $^ -lintl
|
||||
else
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
endif
|
||||
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
HAVE_GETTEXT:
|
||||
$(MAKE) -f $(FT_MAKEFILE) GETTEXT=HAVE_GETTEXT all
|
||||
|
||||
freetype:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all
|
||||
|
||||
freetype_debug:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview.exe: $(GOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
fterror.exe: fterror.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring.exe: $(GOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer.exe: $(GOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean
|
||||
|
||||
distclean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
|
||||
-del dep.end
|
||||
-del *.exe
|
||||
-del core
|
||||
|
||||
do_clean:
|
||||
-del *.o
|
||||
-del response
|
||||
-del $(ARCH)\gfs_dos.o
|
||||
|
||||
depend: $(SRC) $(GSRC)
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
|
||||
$(CC) -E -M $(INCDIRS) $^ > dep.end
|
||||
|
||||
ifeq (dep.end,$(wildcard dep.end))
|
||||
include dep.end
|
||||
endif
|
||||
|
||||
# end of Makefile.gcc
|
||||
50
test/arch/msdos/depend.dos
Normal file
50
test/arch/msdos/depend.dos
Normal file
@@ -0,0 +1,50 @@
|
||||
# This dependency file to be used with various MS-DOS compilers
|
||||
# has been generated automatically with the script `makedep' on
|
||||
# 03-Sep-1999.
|
||||
|
||||
arabic.obj: arabic.c arabic.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxopen.h ..\lib\extend\ftxgdef.h \
|
||||
..\lib\extend\ftxgsub.h ..\lib\extend\ftxgpos.h
|
||||
blitter.obj: blitter.c blitter.h
|
||||
common.obj: common.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h
|
||||
display.obj: display.c display.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h gmain.h
|
||||
fdebug.obj: fdebug.c ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\tttypes.h ..\lib\ttconfig.h \
|
||||
..\lib\arch\msdos\ft_conf.h ..\lib\ttdebug.h ..\lib\ttobjs.h \
|
||||
..\lib\ttengine.h ..\lib\ttmutex.h ..\lib\ttcache.h ..\lib\tttables.h \
|
||||
..\lib\ttcmap.h
|
||||
ftdump.obj: ftdump.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxcmap.h ..\lib\extend\ftxopen.h \
|
||||
..\lib\extend\ftxgdef.h ..\lib\extend\ftxgsub.h \
|
||||
..\lib\extend\ftxgpos.h ..\lib\extend\ftxsbit.h ..\lib\ttobjs.h \
|
||||
..\lib\ttconfig.h ..\lib\arch\msdos\ft_conf.h ..\lib\ttengine.h \
|
||||
..\lib\tttypes.h ..\lib\ttmutex.h ..\lib\ttcache.h ..\lib\tttables.h \
|
||||
..\lib\ttcmap.h
|
||||
fterror.obj: fterror.c ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxerr18.h \
|
||||
..\lib\arch\msdos\ft_conf.h
|
||||
ftlint.obj: ftlint.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\arch\msdos\ft_conf.h
|
||||
ftmetric.obj: ftmetric.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxsbit.h ..\lib\arch\msdos\ft_conf.h
|
||||
ftsbit.obj: ftsbit.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxsbit.h ..\lib\arch\msdos\ft_conf.h
|
||||
ftstring.obj: ftstring.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h display.h gevents.h gdriver.h gmain.h
|
||||
ftstrpnm.obj: ftstrpnm.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h
|
||||
ftstrtto.obj: ftstrtto.c arabic.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxopen.h ..\lib\extend\ftxgdef.h \
|
||||
..\lib\extend\ftxgsub.h ..\lib\extend\ftxgpos.h blitter.h common.h \
|
||||
display.h ..\lib\extend\ftxkern.h ..\lib\extend\ftxsbit.h gdriver.h \
|
||||
gevents.h gmain.h
|
||||
fttimer.obj: fttimer.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h gdriver.h gevents.h gmain.h
|
||||
ftview.obj: ftview.c blitter.h common.h display.h \
|
||||
..\lib\extend\ftxsbit.h gdriver.h gevents.h gmain.h
|
||||
ftzoom.obj: ftzoom.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxpost.h gdriver.h gevents.h gmain.h
|
||||
gmain.obj: gmain.c gdriver.h gmain.h
|
||||
arch\msdos\gfs_dos.obj: arch\msdos\gfs_dos.c gdriver.h gevents.h gmain.h
|
||||
357
test/arch/msdos/gfs_dos.c
Normal file
357
test/arch/msdos/gfs_dos.c
Normal file
@@ -0,0 +1,357 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gfs_dos.c graphics utility fullscreen Dos driver. 1.0
|
||||
*
|
||||
* This is the driver for fullscreen Dos display, used by the
|
||||
* graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if defined( __STDC__ ) || defined( __TURBOC__ )
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
/* The following #ifdef are used to define the following macros : */
|
||||
/* */
|
||||
/* - int86 : function to call an interrupt */
|
||||
/* - reg_ax : the 'ax' register as stored in the REGS struct */
|
||||
/* */
|
||||
|
||||
/* ---- DJGPP dos compiler support --------------------------------------- */
|
||||
|
||||
/* DJGPP v1.x */
|
||||
#if !defined( __DJGPP__ ) && defined( __GO32__ )
|
||||
|
||||
#define DJGPP1
|
||||
#undef __STRICT_ANSI__
|
||||
#include <sys/nearptr.h>
|
||||
#include <dos.h>
|
||||
#include <strings.h>
|
||||
#include <conio.h>
|
||||
|
||||
#define reg_ax regs.x.ax
|
||||
|
||||
#endif
|
||||
|
||||
/* DJGPP v2.x */
|
||||
#ifdef __DJGPP__
|
||||
|
||||
#define DJGPP2
|
||||
#undef __STRICT_ANSI__
|
||||
#include <bios.h>
|
||||
#include <conio.h>
|
||||
#include <sys/movedata.h>
|
||||
#define int86( a, b, c ) int86( a, b, c )
|
||||
#define reg_ax regs.x.ax
|
||||
|
||||
#endif
|
||||
|
||||
/* ---- Microsoft C compilers support ------------------------------------ */
|
||||
|
||||
#if defined( M_I86 ) || defined( _M_I86 )
|
||||
|
||||
#include <dos.h>
|
||||
#include <conio.h>
|
||||
|
||||
#define reg_ax regs.x.ax
|
||||
|
||||
#ifdef _M_I86 /* a recent compiler, which do not pollute name spaces */
|
||||
#define getch() _getch()
|
||||
#define REGS _REGS
|
||||
#define int86( a, b, c ) _int86( a, b, c )
|
||||
#endif
|
||||
|
||||
#ifndef MK_FP
|
||||
#ifdef _MK_FP
|
||||
#define MK_FP( seg, ofs ) _MK_FP( seg, ofs )
|
||||
#else
|
||||
#ifndef _M_I86 /* old versions */
|
||||
#define __far _far
|
||||
#endif
|
||||
#define MK_FP( seg, offset ) (void __far *)( ((unsigned long)seg << 16) + \
|
||||
(unsigned long)(unsigned)offset )
|
||||
#endif /* _MK_FP */
|
||||
#endif /* MK_FP */
|
||||
|
||||
#endif /* Microsoft compilers */
|
||||
|
||||
/* ---- Borland C compiler support --------------------------------------- */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#ifdef __STDC__
|
||||
#error "MK_FP is incompatible with ANSI mode. Use the `-A-' switch."
|
||||
#endif
|
||||
|
||||
#include <dos.h> /* Includes the declaration of int86 */
|
||||
#include <conio.h> /* for getch */
|
||||
|
||||
#define reg_ax regs.x.ax
|
||||
#define int86( a, b, c ) int86( a, b, c )
|
||||
|
||||
#endif
|
||||
|
||||
/* ---- Phar Lap 286|DOS extender support -------------------------------- */
|
||||
|
||||
#ifdef DOSX286
|
||||
/* The symbol DOSX286 must be specified on the command line. */
|
||||
|
||||
#include <phapi.h>
|
||||
#endif
|
||||
|
||||
/* ---- EMX/Dos compiler support ----------------------------------------- */
|
||||
|
||||
#ifdef __EMX__
|
||||
|
||||
#include <dos.h>
|
||||
#include <sys/hw.h>
|
||||
#include <conio.h> /* for getch */
|
||||
extern _read_kbd(); /* to avoid an ANSI warning during compilation */
|
||||
|
||||
#define int86 _int86
|
||||
#define reg_ax regs.x.ax
|
||||
|
||||
#endif
|
||||
|
||||
/* ---- WATCOM Dos/16 & Dos/32 support ----------------------------------- */
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
|
||||
#include <i86.h>
|
||||
|
||||
#define reg_ax regs.w.ax
|
||||
|
||||
#ifdef __386__
|
||||
#define int86 int386
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined( reg_ax ) || !defined( int86 )
|
||||
#error "Your compiler is not (yet) supported. Check the source file!"
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
|
||||
/* Set Graphics Mode */
|
||||
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono: /* Standard VGA 640x480x16 mode */
|
||||
reg_ax = 0x12;
|
||||
int86( 0x10, ®s, ®s );
|
||||
|
||||
vio_ScanLineWidth = 80;
|
||||
vio_Width = 640;
|
||||
vio_Height = 480;
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray: /* Standard VGA 320x200x256 mode */
|
||||
reg_ax = 0x13;
|
||||
int86( 0x10, ®s, ®s );
|
||||
|
||||
vio_ScanLineWidth = 320;
|
||||
vio_Width = 320;
|
||||
vio_Height = 200;
|
||||
|
||||
/* default gray_palette takes the gray levels of the standard VGA */
|
||||
/* 256 colors mode */
|
||||
|
||||
gray_palette[0] = 0;
|
||||
gray_palette[1] = 23;
|
||||
gray_palette[2] = 27;
|
||||
gray_palette[3] = 29;
|
||||
gray_palette[4] = 31;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0; /* failure */
|
||||
}
|
||||
|
||||
#if defined( __EMX__ )
|
||||
Vio = _memaccess( 0xA0000, 0xAFFFF, 1 );
|
||||
#elif defined( DJGPP1 ) || defined( DJGPP2 )
|
||||
Vio = (char *)0xA0000;
|
||||
#elif defined( __WATCOMC__ ) && defined( __386__ )
|
||||
Vio = (char *)0xA0000;
|
||||
#elif defined( DOSX286 )
|
||||
{
|
||||
unsigned short sel;
|
||||
|
||||
|
||||
if ( DosMapRealSeg( 0xA000, (long)vio_ScanLineWidth*vio_Height, &sel ) )
|
||||
return 0; /* failure */
|
||||
|
||||
Vio = (char*)MK_FP( sel, 0 );
|
||||
}
|
||||
#else
|
||||
Vio = (char*)MK_FP( 0xA000, 0 );
|
||||
#endif
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* Revert to text mode */
|
||||
|
||||
int Driver_Restore_Mode()
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
|
||||
reg_ax = 0x3;
|
||||
int86( 0x10, ®s, ®s );
|
||||
|
||||
#ifdef DOSX286
|
||||
|
||||
#ifndef FP_SEG
|
||||
#define FP_SEG(fp) (*((unsigned __far *)&(fp) + 1))
|
||||
#endif
|
||||
|
||||
DosFreeSeg( FP_SEG( Vio ) );
|
||||
#endif
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col )
|
||||
{
|
||||
int y, used_col;
|
||||
char* target;
|
||||
|
||||
|
||||
#ifdef DJGPP2
|
||||
char cbuf = 0;
|
||||
int i;
|
||||
for( i = 0; i < vio_Height*vio_ScanLineWidth; i++ )
|
||||
dosmemput( &cbuf, 1, (unsigned long) Vio+i );
|
||||
#else
|
||||
|
||||
#ifdef DJGPP1
|
||||
__djgpp_nearptr_enable();
|
||||
Vio += __djgpp_conventional_base;
|
||||
|
||||
#else
|
||||
|
||||
memset( Vio, 0, vio_Height * vio_ScanLineWidth );
|
||||
|
||||
#endif /* DJGPP1 */
|
||||
|
||||
#endif /* DJGPP2 */
|
||||
|
||||
if ( line > vio_Height )
|
||||
line = vio_Height;
|
||||
if ( col > vio_ScanLineWidth )
|
||||
used_col = vio_ScanLineWidth;
|
||||
else
|
||||
used_col = col;
|
||||
|
||||
target = Vio + ( line - 1 ) * vio_ScanLineWidth;
|
||||
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
#ifdef DJGPP2
|
||||
dosmemput( buffer, used_col, (unsigned long)target );
|
||||
#else
|
||||
memcpy( target, buffer, used_col );
|
||||
#endif
|
||||
target -= vio_ScanLineWidth;
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
#ifdef DJGPP1
|
||||
__djgpp_nearptr_disable();
|
||||
Vio -= __djgpp_conventional_base;
|
||||
#endif
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
|
||||
c = getch();
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
event->what = trans[i].event_class;
|
||||
event->info = trans[i].event_info;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
|
||||
event->what = event_Keyboard;
|
||||
event->info = (int)c;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
22
test/arch/msdos/makedep
Normal file
22
test/arch/msdos/makedep
Normal file
@@ -0,0 +1,22 @@
|
||||
# makedep
|
||||
#
|
||||
# This shell script creates a dependency file necessary for older compilers
|
||||
# on the MS-DOS platform.
|
||||
|
||||
echo "\
|
||||
# This dependency file to be used with various MS-DOS compilers
|
||||
# has been generated automatically with the script \`makedep' on
|
||||
# `date +%d-%b-%Y`.
|
||||
" > depend.dos
|
||||
|
||||
(cd ../..
|
||||
gcc -MM -I../lib/arch/msdos -I../lib -I../lib/extend -I. *.c | \
|
||||
sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.dos
|
||||
|
||||
(cd ../..
|
||||
gcc -MM -I../lib/arch/win16 -I../lib -I../lib/extend -I. \
|
||||
-Dreg_ax -Dint86 arch/msdos/*.c | \
|
||||
sed -e "s/^\(.*\)\.o:/arch\\\\msdos\\\\\1.obj:/" \
|
||||
-e "s:/:\\\\:g") >> depend.dos
|
||||
|
||||
# eof
|
||||
124
test/arch/msdos/time_tc.h
Normal file
124
test/arch/msdos/time_tc.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* time.h Replacement for buggy <time.h> of old Turbo C compilers
|
||||
*
|
||||
* This file is a hack! It replaces <time.h> when compiling with
|
||||
* old versions of Borland Turbo C compilers that lack clock(),
|
||||
* and provide its own version.
|
||||
*
|
||||
* Written by Antoine Leca
|
||||
* Copyright 1999 Antoine Leca, David Turner, Robert Wilhelm
|
||||
* and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#if !defined __TURBOC__ || !defined __MSDOS__ || __TURBOC__>0x200
|
||||
/*
|
||||
* We are not running on a Borland compiler, or either on
|
||||
* a recent version that does not need the hack.
|
||||
* Certainly the user does not clean up the directory.
|
||||
* Stop the compilation.
|
||||
*/
|
||||
#error Remove the file time.h in directory test
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _TIME_H_DEFINED
|
||||
#define _TIME_H_DEFINED
|
||||
|
||||
#if defined _TM_DEFINED || defined _TIME_T
|
||||
#error Another version of <time.h> seems to have been already included
|
||||
#endif
|
||||
|
||||
#ifndef __TIME_T
|
||||
#define __TIME_T
|
||||
typedef long time_t;
|
||||
#endif
|
||||
|
||||
#ifndef __CLOCK_T
|
||||
#define __CLOCK_T
|
||||
typedef long clock_t;
|
||||
#define CLK_TCK 18.2
|
||||
#endif
|
||||
|
||||
#define CLOCKS_PER_SEC CLK_TCK
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
};
|
||||
|
||||
|
||||
clock_t clock (void);
|
||||
double difftime(time_t time2, time_t time1);
|
||||
time_t time (time_t *timer);
|
||||
|
||||
char *asctime (const struct tm *tblock);
|
||||
char *ctime (const time_t *time);
|
||||
struct tm *gmtime (const time_t *timer);
|
||||
struct tm *localtime(const time_t *timer);
|
||||
|
||||
|
||||
#if __TURBOC__ <= 0x0150
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* Function : clock
|
||||
*
|
||||
* Description : Turbo C v.1.x lacks the clock() function that is
|
||||
* needed for at least fttimer.
|
||||
* So this is a replacement that does more or less
|
||||
* the functionnality of clock(), using the BIOS.
|
||||
* Since we do not know exactly when the process
|
||||
* started (as clock() is supposed to do), we cheat
|
||||
* a little here.
|
||||
*
|
||||
* Input : None
|
||||
*
|
||||
* Output : None
|
||||
*
|
||||
* Notes : Use two static objects.
|
||||
* NEED_CLOCK_HERE is a macro that should be defined
|
||||
* in only ONE module (otherwise, the linker will complain).
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
extern long biostime(int cmd, long newtime);
|
||||
|
||||
static long CountOfTicks;
|
||||
static long DateOfReference = 0;
|
||||
|
||||
clock_t clock (void)
|
||||
{
|
||||
|
||||
if (DateOfReference == 0) /* this is the first call */
|
||||
{
|
||||
DateOfReference = time(NULL) / 86400L;
|
||||
CountOfTicks = biostime(0,0L) - CLOCKS_PER_SEC;
|
||||
/* pretend we start one second ago */
|
||||
return CLOCKS_PER_SEC; /* to avoid returning 0 */
|
||||
}
|
||||
|
||||
return (time(NULL) / 86400L - DateOfReference) * 0x1800B0L
|
||||
+ biostime(0,0L) - CountOfTicks;
|
||||
}
|
||||
|
||||
#endif /* Turbo C v.1.x */
|
||||
|
||||
#endif /* defined __TIME_H_DEFINED */
|
||||
|
||||
|
||||
/* End */
|
||||
143
test/arch/os2/Makefile.dm
Normal file
143
test/arch/os2/Makefile.dm
Normal file
@@ -0,0 +1,143 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for emx-gcc under OS/2
|
||||
#
|
||||
# You will need dmake.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# dmake -r -f arch/os2/Makefile.dm
|
||||
|
||||
ARCH = arch/os2
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.dm
|
||||
FT_MAKE = dmake -r
|
||||
|
||||
.IMPORT: COMSPEC
|
||||
SHELL := $(COMSPEC)
|
||||
SHELLFLAGS := /c
|
||||
GROUPSHELL := $(SHELL)
|
||||
GROUPFLAGS := $(SHELLFLAGS)
|
||||
GROUPSUFFIX := .cmd
|
||||
SHELLMETAS := *"?<>&|
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
LIBDIR_OS2 = $(subst,/,\ $(LIBDIR))
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/$(ARCH) -I. -I$(LIBDIR)/extend
|
||||
|
||||
# CFLAGS = -Wall -ansi -O2 -g $(INCDIRS)
|
||||
CFLAGS = -ansi -Wall -O2 -s -Zcrtdll $(INCDIRS)
|
||||
|
||||
# full-screen MSDOS driver
|
||||
GFSDRIVER = $(ARCH)/gfs_os2.c
|
||||
GPMDRIVER = $(ARCH)/gpm_os2.c
|
||||
GPM_DEF = $(ARCH)/gpm_os2.def
|
||||
|
||||
DISPLAY = display.c
|
||||
|
||||
SRC = ftlint.c fttimer.c ftview.c ftzoom.c ftdump.c ftstring.c ftstrpnm.c \
|
||||
ftsbit.c common.c blitter.c ftmetric.c ftstrtto.c arabic.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c
|
||||
GFSSRC = $(GSRC) $(GFSDRIVER)
|
||||
GPMSRC = $(GSRC) $(GPMDRIVER)
|
||||
|
||||
GFSOBJ = $(GFSSRC:.c=.o)
|
||||
GPMOBJ = $(GPMSRC:.c=.o)
|
||||
|
||||
ALLSRC = $(SRC) $(GSRC) $(GFSDRIVER) $(GPMDRIVER)
|
||||
ALLOBJ = $(ALLSRC:.c=.o)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ @$(mktmp $(&:t"\n")\n)
|
||||
|
||||
|
||||
EXEFILES = ftview.exe ftviewfs.exe \
|
||||
ftlint.exe \
|
||||
fttimer.exe fttimefs.exe \
|
||||
ftdump.exe \
|
||||
ftstring.exe ftstrfs.exe \
|
||||
ftzoom.exe ftzoomfs.exe \
|
||||
ftstrpnm.exe \
|
||||
ftsbit.exe \
|
||||
ftmetric.exe \
|
||||
ftstrtto.exe ftstrtfs.exe
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean do_distclean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
|
||||
freetype:
|
||||
[
|
||||
cd $(LIBDIR_OS2)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) all
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
freetype_debug:
|
||||
[
|
||||
cd $(LIBDIR_OS2)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) debug
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
ftzoom.exe: $(GPMOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftzoomfs.exe: $(GFSOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview.exe: $(GPMOBJ) ftview.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftviewfs.exe: $(GFSOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring.exe: $(GPMOBJ) ftstring.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftstrfs.exe: $(GFSOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer.exe: $(GPMOBJ) fttimer.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
fttimefs.exe: $(GFSOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto.exe: $(GPMOBJ) ftstrtto.o common.o arabic.o \
|
||||
$(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftstrtfs.exe: $(GFSOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
[
|
||||
cd $(LIBDIR_OS2)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) clean
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
distclean: do_clean do_distclean
|
||||
[
|
||||
cd $(LIBDIR_OS2)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) distclean
|
||||
cd $(MAKEDIR)
|
||||
]
|
||||
|
||||
do_distclean:
|
||||
-+del dep.end $(EXEFILES) core
|
||||
|
||||
do_clean:
|
||||
-+del $(subst,/,\ $(ALLOBJ))
|
||||
|
||||
# depend: $(ALLSRC)
|
||||
#[
|
||||
# cd $(LIBDIR_OS2)
|
||||
# $(FT_MAKE) -f $(FT_MAKEFILE) depend
|
||||
# cd $(MAKEDIR)
|
||||
# $(CC) -E -M $(INCDIRS) @$(mktmp $(<:t"\n")\n) > dep.end
|
||||
#]
|
||||
#
|
||||
# ifeq (dep.end,$(wildcard dep.end))
|
||||
# include dep.end
|
||||
# endif
|
||||
|
||||
# end of Makefile.dm
|
||||
108
test/arch/os2/Makefile.emx
Normal file
108
test/arch/os2/Makefile.emx
Normal file
@@ -0,0 +1,108 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for emx-gcc under OS/2.
|
||||
#
|
||||
# You will need GNU make.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -f arch/os2/Makefile.emx
|
||||
|
||||
ARCH = arch/os2
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.emx
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/extend -I$(LIBDIR)/$(ARCH) -I.
|
||||
|
||||
CFLAGS = -Wall -ansi -O0 -g $(INCDIRS)
|
||||
# CFLAGS = -ansi -Wall -O2 -s -Zcrtdll $(INCDIRS)
|
||||
|
||||
GFSDRIVER = $(ARCH)/gfs_os2.c
|
||||
GPMDRIVER = $(ARCH)/gpm_os2.c
|
||||
GPM_DEF = $(ARCH)/gpm_os2.def
|
||||
|
||||
SRC = fttimer.c ftview.c ftlint.c ftzoom.c ftdump.c ftstring.c ftstrpnm.c \
|
||||
ftsbit.c common.c blitter.c ftmetric.c ftstrtto.c arabic.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c
|
||||
GFSSRC = $(GSRC) $(GFSDRIVER)
|
||||
GPMSRC = $(GSRC) $(GPMDRIVER)
|
||||
GFSOBJ = $(GFSSRC:.c=.o)
|
||||
GPMOBJ = $(GPMSRC:.c=.o)
|
||||
|
||||
ALLSRC = $(SRC) $(GSRC) $(GFSDRIVER) $(GPMDRIVER)
|
||||
ALLOBJ = $(ALLSRC:.c=.o)
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
|
||||
EXEFILES = ftview.exe ftviewfs.exe \
|
||||
fttimer.exe fttimefs.exe \
|
||||
ftlint.exe \
|
||||
ftstring.exe ftstrfs.exe \
|
||||
ftstrpnm.exe \
|
||||
ftzoom.exe ftzoomfs.exe \
|
||||
ftsbit.exe \
|
||||
ftdump.exe \
|
||||
ftmetric.exe \
|
||||
ftstrtto.exe ftstrtfs.exe
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all
|
||||
|
||||
freetype_debug:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug
|
||||
|
||||
ftzoom.exe: $(GPMOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftzoomfs.exe: $(GFSOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview.exe: $(GPMOBJ) ftview.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftviewfs.exe: $(GFSOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring.exe: $(GPMOBJ) ftstring.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftstrfs.exe: $(GFSOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer.exe: $(GPMOBJ) fttimer.o common.o $(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
fttimefs.exe: $(GFSOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto.exe: $(GPMOBJ) ftstrtto.o common.o arabic.o \
|
||||
$(LIBDIR)/libttf.a $(GPM_DEF)
|
||||
ftstrtfs.exe: $(GFSOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean
|
||||
|
||||
distclean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
|
||||
-del dep.end $(EXEFILES) core
|
||||
|
||||
do_clean:
|
||||
-del $(subst /,\,$(ALLOBJ))
|
||||
|
||||
|
||||
depend: $(ALLSRC)
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
|
||||
$(CC) -E -M $(INCDIRS) $^ > dep.end
|
||||
|
||||
ifeq (dep.end,$(wildcard dep.end))
|
||||
include dep.end
|
||||
endif
|
||||
|
||||
# end of Makefile.emx
|
||||
145
test/arch/os2/Makefile.icc
Normal file
145
test/arch/os2/Makefile.icc
Normal file
@@ -0,0 +1,145 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for IBM VisualAge C++ under OS/2.
|
||||
#
|
||||
# You will need nmake.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# nmake -f arch\os2\Makefile.icc
|
||||
|
||||
ARCH = arch\os2
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.icc
|
||||
FT_MAKE = $(MAKE) -nologo
|
||||
|
||||
CC = icc
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\extend -I$(LIBDIR)\$(ARCH) -I.
|
||||
CFLAGS = -O+ -Gd+ -Gn+ -Gl+ -Ti- -Tm- -Q+ -Wpro- -Wcnd- $(INCDIRS)
|
||||
|
||||
# Fullscreen OS/2 driver
|
||||
GFSDRIVER_SRC = $(ARCH)\gfs_os2.c
|
||||
GFSDRIVER = $(ARCH)\gfs_os2.obj
|
||||
|
||||
# PM OS/2 Driver
|
||||
GPMDRIVER = $(ARCH)\gpm_os2.obj
|
||||
GPMDRIVER_SRC = $(ARCH)\gpm_os2.c
|
||||
GPM_DEF = $(ARCH)\gpm_os2.def
|
||||
|
||||
SRC = gmain.c display.c common.c arabic.c \
|
||||
ftzoom.c ftview.c fttimer.c ftlint.c ftdump.c ftstring.c \
|
||||
ftstrpnm.c ftsbit.c ftmetric.c ftstrtto.c \
|
||||
$(GFSDRIVER_SRC)
|
||||
|
||||
COMMON = common.obj
|
||||
GFSOBJS = gmain.obj display.obj $(GFSDRIVER) $(COMMON) blitter.obj
|
||||
GPMOBJS = gmain.obj display.obj $(GPMDRIVER) $(COMMON) blitter.obj
|
||||
OBJ1 = ftzoom.obj
|
||||
OBJ2 = fttimer.obj
|
||||
OBJ3 = ftview.obj
|
||||
OBJ4 = ftlint.obj
|
||||
OBJ5 = ftdump.obj
|
||||
OBJ6 = ftstring.obj
|
||||
OBJ7 = ftstrpnm.obj
|
||||
OBJ8 = ftsbit.obj
|
||||
OBJ9 = ftmetric.obj
|
||||
OBJ10 = ftstrtto.obj
|
||||
|
||||
|
||||
EXEFILES = fttimefs.exe fttimer.exe \
|
||||
ftzoom.exe ftzoomfs.exe \
|
||||
ftviewfs.exe ftview.exe \
|
||||
ftlint.exe \
|
||||
ftdump.exe \
|
||||
ftstring.exe ftstrfs.exe \
|
||||
ftstrpnm.exe \
|
||||
ftsbit.exe \
|
||||
ftmetric.exe \
|
||||
ftstrtto.exe ftstrtfs.exe
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) debug
|
||||
cd ..\test
|
||||
|
||||
$(GFSDRIVER): $(GFSDRIVER_SRC)
|
||||
$(CC) $(CFLAGS) /c /Fo$@ $** -I.
|
||||
|
||||
$(GPMDRIVER): $(GPMDRIVER_SRC)
|
||||
$(CC) $(CFLAGS) /c /Fo$@ $** -I.
|
||||
|
||||
ftzoomfs.exe: $(GFSOBJS) $(OBJ1) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftzoom.exe: $(GPMOBJS) $(OBJ1) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) $(GPM_DEF) /Fe$@ $**
|
||||
|
||||
fttimefs.exe: $(GFSOBJS) $(OBJ2) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
fttimer.exe: $(GPMOBJS) $(OBJ2) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) $(GPM_DEF) /Fe$@ $**
|
||||
|
||||
ftviewfs.exe: $(GFSOBJS) $(OBJ3) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftview.exe: $(GPMOBJS) $(OBJ3) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) $(GPM_DEF) /Fe$@ $**
|
||||
|
||||
ftlint.exe: $(OBJ4) $(LIBDIR)\libttf.lib $(COMMON)
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftdump.exe: $(OBJ5) $(LIBDIR)\libttf.lib $(COMMON)
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftstrfs.exe: $(GFSOBJS) $(OBJ6) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftstring.exe: $(GPMOBJS) $(OBJ6) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) $(GPM_DEF) /Fe$@ $**
|
||||
|
||||
ftstrpnm.exe: $(OBJ7) $(LIBDIR)\libttf.lib $(COMMON)
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftsbit.exe: $(OBJ8) $(LIBDIR)\libttf.lib $(COMMON)
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftmetric.exe: $(OBJ9) $(LIBDIR)\libttf.lib $(COMMON)
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftstrtfs.exe: $(GFSOBJS) $(OBJ10) $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) /Fe$@ $**
|
||||
|
||||
ftstrtto.exe: $(GPMOBJS) $(OBJ10) arabic.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(CFLAGS) $(GPM_DEF) /Fe$@ $**
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(GFSDRIVER)
|
||||
-del $(GPMDRIVER)
|
||||
|
||||
# end of Makefile.icc
|
||||
155
test/arch/os2/Makefile.wat
Normal file
155
test/arch/os2/Makefile.wat
Normal file
@@ -0,0 +1,155 @@
|
||||
# This file is part of the FreeType project
|
||||
#
|
||||
# This builds the test programs with the Watcom compiler
|
||||
#
|
||||
# You'll need Watcom's wmake
|
||||
#
|
||||
# Invoke by "wmake -f arch\os2\Makefile.wat" when in the "test" directory
|
||||
|
||||
ARCH = arch\os2
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.wat
|
||||
FT_MAKE = wmake -h
|
||||
|
||||
.EXTENSIONS:
|
||||
.EXTENSIONS: .exe .obj .c .h
|
||||
.obj:.
|
||||
.c:.
|
||||
.h:.;..\lib
|
||||
|
||||
CC = wcl386
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\$(ARCH) -I$(LIBDIR)\extend
|
||||
LIBFILE = $(LIBDIR)\libttf.lib
|
||||
|
||||
LINK_OPTS =
|
||||
|
||||
OBJ_CFLAGS = /c /otexanl+ /s /w4 /zq $(INCDIRS)
|
||||
|
||||
CCFLAGS = /otexanl+ /s /w4 /zq $(INCDIRS)
|
||||
|
||||
GFSDRIVER = $(ARCH)\gfs_os2.obj
|
||||
GFSDRIVER_SRC = $(ARCH)\gfs_os2.c
|
||||
|
||||
GPMDRIVER = $(ARCH)\gpm_os2.obj
|
||||
GPMDRIVER_SRC = $(ARCH)\gpm_os2.c
|
||||
GPMDRIVER_DEF = $(ARCH)\gpm_os2.def
|
||||
|
||||
SRC = gmain.c display.c blitter.c &
|
||||
fttimer.c ftview.c ftlint.c ftzoom.c ftdump.c ftstring.c &
|
||||
ftstrpnm.c ftsbit.c ftmetric.c ftstrtto.c &
|
||||
$(GPMDRIVER_SRC) $(GFSDRIVER_SRC)
|
||||
|
||||
GFSOBJ = gmain.obj $(GFSDRIVER) blitter.obj display.obj
|
||||
GPMOBJ = gmain.obj $(GPMDRIVER) blitter.obj display.obj
|
||||
|
||||
PM = $(LIBFILE) $(GPMOBJ) common.obj
|
||||
FS = $(LIBFILE) $(GFSOBJ) common.obj
|
||||
|
||||
|
||||
# graphics utility and test driver
|
||||
|
||||
EXEFILES = ftview.exe ftviewfs.exe &
|
||||
fttimer.exe fttimefs.exe &
|
||||
ftlint.exe &
|
||||
ftdump.exe &
|
||||
ftstring.exe ftstrfs.exe &
|
||||
ftzoom.exe ftzoomfs.exe &
|
||||
ftstrpnm.exe &
|
||||
ftsbit.exe &
|
||||
ftmetric.exe &
|
||||
ftstrtto.exe ftstrtfs.exe
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
|
||||
freetype: .symbolic
|
||||
cd ..\lib
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug: .symbolic
|
||||
cd ..\lib
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) debug
|
||||
cd ..\test
|
||||
|
||||
# implicit rules
|
||||
#
|
||||
.c.obj :
|
||||
$(CC) $(OBJ_CFLAGS) $[* /fo=$[*.obj
|
||||
|
||||
|
||||
# the full-screen graphics driver
|
||||
#
|
||||
$(GFSDRIVER): $(GFSDRIVER_SRC)
|
||||
$(CC) $(OBJ_CFLAGS) $[*.c /fo=$[*.obj
|
||||
|
||||
# the pm graphics driver
|
||||
#
|
||||
$(GPMDRIVER): $(GPMDRIVER_SRC)
|
||||
$(CC) $(OBJ_CFLAGS) $[*.c /fo=$[*.obj
|
||||
|
||||
ftzoom.exe : ftzoom.obj $(LIBFILE) $(PM) $(GPMDRIVER_DEF)
|
||||
$(CC) $(CCFLAGS) -l=os2v2_pm $(PM) $[*.c /fe=$[*.exe
|
||||
|
||||
ftzoomfs.exe : ftzoom.obj $(LIBFILE) $(FS)
|
||||
$(CC) $(CCFLAGS) $(FS) $[@ /fe=ftzoomfs.exe
|
||||
|
||||
ftview.exe : ftview.obj $(LIBFILE) $(PM) $(GPMDRIVER_DEF)
|
||||
$(CC) $(CCFLAGS) -l=os2v2_pm $(PM) $[*.c /fe=$[*.exe
|
||||
|
||||
ftviewfs.exe : ftview.obj $(LIBFILE) $(FS)
|
||||
$(CC) $(CCFLAGS) $(FS) $[*.c /fe=ftviewfs.exe
|
||||
|
||||
ftstring.exe : ftstring.obj $(LIBFILE) $(PM) $(GPMDRIVER_DEF)
|
||||
$(CC) $(CCFLAGS) -l=os2v2_pm $(PM) $[*.c /fe=$[*.exe
|
||||
|
||||
ftstrfs.exe : ftstring.obj $(LIBFILE) $(FS)
|
||||
$(CC) $(CCFLAGS) $(FS) $[*.c /fe=ftstrfs.exe
|
||||
|
||||
fttimer.exe: fttimer.obj $(LIBFILE) $(PM) $(GPMDRIVER_DEF)
|
||||
$(CC) $(CCFLAGS) -l=os2v2_pm $(PM) $[*.c /fe=$[*.exe
|
||||
|
||||
fttimefs.exe: fttimer.obj $(LIBFILE) $(FS)
|
||||
$(CC) $(CCFLAGS) $(FS) $[*.c /fe=fttimefs.exe
|
||||
|
||||
ftlint.exe: ftlint.obj $(LIBFILE)
|
||||
$(CC) $(CCFLAGS) $(LIBFILE) common.obj $[*.c /fe=$[*.exe
|
||||
|
||||
ftdump.exe: ftdump.obj $(LIBFILE)
|
||||
$(CC) $(CCFLAGS) $(LIBFILE) common.obj $[*.c /fe=$[*.exe
|
||||
|
||||
ftstrpnm.exe: ftstrpnm.obj $(LIBFILE)
|
||||
$(CC) $(CCFLAGS) $(LIBFILE) common.obj $[*.c /fe=$[*.exe
|
||||
|
||||
ftsbit.exe: ftsbit.obj $(LIBFILE)
|
||||
$(CC) $(CCFLAGS) $(LIBFILE) common.obj $[*.c /fe=$[*.exe
|
||||
|
||||
ftmetric.exe: ftmetric.obj $(LIBFILE)
|
||||
$(CC) $(CCFLAGS) $(LIBFILE) common.obj $[*.c /fe=$[*.exe
|
||||
|
||||
ftstrtto.exe : ftstrtto.obj arabic.obj $(LIBFILE) $(PM) $(GPMDRIVER_DEF)
|
||||
$(CC) $(CCFLAGS) -l=os2v2_pm $(PM) $[*.c /fe=$[*.exe
|
||||
|
||||
ftstrtfs.exe : ftstrtto.obj arabic.obj $(LIBFILE) $(FS)
|
||||
$(CC) $(CCFLAGS) $(FS) $[*.c /fe=ftstrtfs.exe
|
||||
|
||||
|
||||
clean: .symbolic
|
||||
@-erase *.obj
|
||||
@-erase $(ARCH)\*.obj
|
||||
|
||||
distclean: .symbolic clean
|
||||
@-erase *.exe
|
||||
@-erase *.err
|
||||
cd ..\lib
|
||||
$(FT_MAKE) -f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
|
||||
new: .symbolic
|
||||
@-wtouch *.c
|
||||
|
||||
# end of Makefile.wat
|
||||
219
test/arch/os2/gfs_os2.c
Normal file
219
test/arch/os2/gfs_os2.c
Normal file
@@ -0,0 +1,219 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gfs_os2.c graphics utility fullscreen OS/2 driver. 1.0
|
||||
*
|
||||
* This is the driver for fullscreen OS/2 display, used by the
|
||||
* graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define INCL_SUB
|
||||
#include <os2.h>
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <os2thunk.h>
|
||||
#endif
|
||||
|
||||
#if defined(__EMX__)||defined(__IBMC__)
|
||||
#include <conio.h> /* for getch */
|
||||
extern _read_kbd(); /* to avoid an ANSI warning during compilation */
|
||||
#endif
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
|
||||
static VIOMODEINFO OrgMode;
|
||||
static long VioBufOfs;
|
||||
|
||||
|
||||
/* BIOS video modes */
|
||||
|
||||
static VIOMODEINFO VioMode_640x480x16 =
|
||||
{
|
||||
sizeof ( VIOMODEINFO ),
|
||||
VGMT_OTHER + VGMT_GRAPHICS,
|
||||
COLORS_16,
|
||||
80,
|
||||
35,
|
||||
640,
|
||||
480
|
||||
};
|
||||
|
||||
static VIOMODEINFO VioMode_320x200x256 =
|
||||
{
|
||||
sizeof ( VIOMODEINFO ),
|
||||
VGMT_OTHER + VGMT_GRAPHICS,
|
||||
8,
|
||||
40,
|
||||
25,
|
||||
320,
|
||||
200
|
||||
};
|
||||
|
||||
static VIOPHYSBUF VioBuf =
|
||||
{
|
||||
(void*)0xA0000L,
|
||||
64*1024
|
||||
};
|
||||
|
||||
|
||||
/* Restores screen to its original state */
|
||||
|
||||
int Driver_Restore_Mode()
|
||||
{
|
||||
VioSetMode( &OrgMode, 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Sets graphics mode */
|
||||
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
OrgMode.cb = sizeof ( VIOMODEINFO );
|
||||
VioGetMode( &OrgMode, 0 );
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono:
|
||||
rc = VioSetMode( &VioMode_640x480x16, 0 );
|
||||
vio_ScanLineWidth = 80;
|
||||
vio_Width = 640;
|
||||
vio_Height = 480;
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray:
|
||||
rc = VioSetMode( &VioMode_320x200x256, 0 );
|
||||
vio_ScanLineWidth = 320;
|
||||
vio_Width = 320;
|
||||
vio_Height = 200;
|
||||
|
||||
/* default gray_palette takes the gray levels of the standard VGA */
|
||||
/* 256 colors mode */
|
||||
|
||||
gray_palette[0] = 0;
|
||||
gray_palette[1] = 23;
|
||||
gray_palette[2] = 27;
|
||||
gray_palette[3] = 29;
|
||||
gray_palette[4] = 31;
|
||||
break;
|
||||
|
||||
default:
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( rc ) return 0; /* failure */
|
||||
|
||||
if ( VioGetPhysBuf( &VioBuf, 0 ) ) return 0; /* Could not access VRAM */
|
||||
|
||||
VioBufOfs = (long)MAKEP( VioBuf.asel[0], 0 );
|
||||
|
||||
memset( (void*)VioBufOfs, 0, 64 * 1024 );
|
||||
|
||||
Vio = (char*)VioBufOfs;
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col )
|
||||
{
|
||||
int y;
|
||||
char* target;
|
||||
|
||||
target = Vio + ( line - 1 ) * vio_ScanLineWidth;
|
||||
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
memcpy( target, buffer, col );
|
||||
target -= vio_ScanLineWidth;
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
|
||||
c = getch();
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
event->what = trans[i].event_class;
|
||||
event->info = trans[i].event_info;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
|
||||
event->what = event_Keyboard;
|
||||
event->info = (int)c;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
654
test/arch/os2/gpm_os2.c
Normal file
654
test/arch/os2/gpm_os2.c
Normal file
@@ -0,0 +1,654 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gpm_os2.c graphics OS/2 Presentation Manager Window driver. 0.2
|
||||
*
|
||||
* This is the driver for windowed OS/2 display, used by the
|
||||
* graphics utility of the FreeType test suite.
|
||||
*
|
||||
* written by Eric Olson (eolson@imag.net)
|
||||
*
|
||||
* Borrowing liberally from the other FreeType drivers.
|
||||
* Some bitmap manipulations are derived from fastgpi.c,
|
||||
* a sample program written by Donald Graft (dgraft@gate.net).
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define INCL_DOS
|
||||
#define INCL_WIN
|
||||
#define INCL_GPI
|
||||
#define INCL_SUB
|
||||
|
||||
#include <os2.h>
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
#define VIO_WIDTH 640u /* these can be changed but VIO_WIDTH should remain */
|
||||
#define VIO_HEIGHT 360u /* for now a multiple of 32 to avoid padding issues */
|
||||
#define MAG_WIDTH VIO_WIDTH
|
||||
#define MAG_HEIGHT 120u
|
||||
#define MAX_MAG 16 /* should be less than Min(MAG_WIDTH, MAG_HEIGHT) */
|
||||
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
|
||||
static HAB habt;
|
||||
static HAB hab;
|
||||
static HWND hwndFrame, hwndClient;
|
||||
static HWND hwndTitle;
|
||||
static HDC hdcMemory;
|
||||
static HPS hpsMemory = (HPS) NULL;
|
||||
|
||||
/* Threads and semaphores */
|
||||
TID MessageThread;
|
||||
HMTX hmtxPSMemoryLock;
|
||||
HEV hevKeyLock;
|
||||
|
||||
/* Bitmap information */
|
||||
static PBITMAPINFO2 pbmi;
|
||||
static HBITMAP hbm;
|
||||
BYTE Bitmap[VIO_WIDTH * VIO_HEIGHT];
|
||||
BOOL ready = FALSE;
|
||||
|
||||
/* Coordinates for the bitblt of whole graphic area */
|
||||
POINTL aptlFull[4] = {{ 0u, MAG_HEIGHT },
|
||||
{ VIO_WIDTH, VIO_HEIGHT + MAG_HEIGHT },
|
||||
{ 0u, 0u },
|
||||
{ VIO_WIDTH, VIO_HEIGHT }};
|
||||
|
||||
/* Coordinates for the magnification bitblt */
|
||||
POINTL aptlMagd[4] = {{ 0u, 0u },
|
||||
{ MAG_WIDTH, MAG_HEIGHT }, /* target */
|
||||
{ 0u, 0u },
|
||||
{ VIO_WIDTH, VIO_HEIGHT }}; /* source */
|
||||
|
||||
/* level of magnification and center of magnification window */
|
||||
static int magnification=1;
|
||||
static POINTL view_target = {0, 0};
|
||||
static SIZEL mag_win_size;
|
||||
|
||||
/* local event to pass on */
|
||||
TEvent ourevent = { event_Rotate_Glyph, 0 };
|
||||
|
||||
/* grayscale vs b/w mode */
|
||||
int Colourmode;
|
||||
|
||||
/* array defined in the test programs */
|
||||
extern char Header[];
|
||||
|
||||
|
||||
void RunPMWindow( ULONG );
|
||||
MRESULT EXPENTRY Message_Process( HWND, ULONG, MPARAM, MPARAM );
|
||||
|
||||
|
||||
|
||||
/* restores screen to its original state */
|
||||
|
||||
int Driver_Restore_Mode()
|
||||
{
|
||||
/* PMWindow has probably already destroyed itself */
|
||||
if ( hwndFrame )
|
||||
WinDestroyWindow( hwndFrame );
|
||||
|
||||
WinReleasePS( hpsMemory );
|
||||
WinTerminate( habt );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* set graphics mode */
|
||||
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
LONG palette[5];
|
||||
int x;
|
||||
POINTL coords;
|
||||
SIZEL sizl = { 0, 0 };
|
||||
|
||||
PTIB thread_block;
|
||||
PPIB process_block;
|
||||
|
||||
/* XXX : This is a very nasty hack, it fools OS/2 and let the program */
|
||||
/* call PM functions, even though stdin/stdout/stderr are still */
|
||||
/* directed to the standard i/o streams.. */
|
||||
/* The program must be compiled with WINDOWCOMPAT */
|
||||
/* */
|
||||
/* Credits go to Michal for finding this !! */
|
||||
/* */
|
||||
DosGetInfoBlocks( &thread_block, &process_block );
|
||||
process_block->pib_ultype = 3;
|
||||
|
||||
/* save mono vs grayscale status */
|
||||
Colourmode = mode;
|
||||
|
||||
/* event semaphore to signal reraster event */
|
||||
DosCreateEventSem( NULL, &hevKeyLock, 0, TRUE );
|
||||
|
||||
/* mutex semaphore for access to the presentation space */
|
||||
DosCreateMutexSem( NULL, &hmtxPSMemoryLock, 0, FALSE );
|
||||
|
||||
/* Start thread with Presentation Manager window */
|
||||
DosCreateThread( &MessageThread, (PFNTHREAD)RunPMWindow, 0UL, 0UL, 32920 );
|
||||
|
||||
/* open anchor block to permit Gpi calls from this thread */
|
||||
habt = WinInitialize( 0 );
|
||||
|
||||
/* create device context and presentation space for our graphic */
|
||||
hdcMemory = DevOpenDC( hab, OD_MEMORY, (PSZ)"*", 0L, 0L, 0L );
|
||||
|
||||
DosRequestMutexSem( hmtxPSMemoryLock, SEM_INDEFINITE_WAIT );
|
||||
hpsMemory = GpiCreatePS(
|
||||
habt, hdcMemory, &sizl,
|
||||
PU_PELS | GPIT_MICRO | GPIA_ASSOC | GPIF_DEFAULT );
|
||||
GpiSetBackMix( hpsMemory, BM_OVERPAINT );
|
||||
|
||||
/* create bitmap for raster image of graphic */
|
||||
|
||||
/* find some memory for the bitmap header */
|
||||
DosAllocMem( (PPVOID)&pbmi,
|
||||
sizeof ( BITMAPINFO2 ) + sizeof ( RGB2 ) * 256,
|
||||
PAG_COMMIT | PAG_READ | PAG_WRITE);
|
||||
/* 256 should really be 2 if not grayscale */
|
||||
|
||||
/* initialize the header to appropriate values */
|
||||
memset( pbmi, 0, sizeof ( BITMAPINFO2 ) + sizeof ( RGB2 ) * 256 );
|
||||
|
||||
pbmi->cbFix = sizeof ( BITMAPINFOHEADER2 );
|
||||
pbmi->cx = VIO_WIDTH;
|
||||
pbmi->cy = VIO_HEIGHT;
|
||||
pbmi->cPlanes = 1;
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono:
|
||||
pbmi->cBitCount = 1;
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray:
|
||||
pbmi->cBitCount = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
hbm = GpiCreateBitmap( hpsMemory, (PBITMAPINFOHEADER2)pbmi,
|
||||
0L, NULL, NULL );
|
||||
|
||||
/* associate it with the presentation space */
|
||||
GpiSetBitmap( hpsMemory, hbm );
|
||||
pbmi->cbFix = sizeof ( BITMAPINFOHEADER2 );
|
||||
GpiQueryBitmapInfoHeader( hbm, (PBITMAPINFOHEADER2) pbmi );
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono:
|
||||
DosReleaseMutexSem( hmtxPSMemoryLock );
|
||||
|
||||
vio_ScanLineWidth = VIO_WIDTH / 8;
|
||||
vio_Width = VIO_WIDTH;
|
||||
vio_Height = VIO_HEIGHT;
|
||||
|
||||
gray_palette[0] = 0; /* to avoid testing for grayscale... */
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray:
|
||||
vio_ScanLineWidth = VIO_WIDTH;
|
||||
vio_Width = VIO_WIDTH;
|
||||
vio_Height = VIO_HEIGHT;
|
||||
|
||||
/* set gray_palette by convoluted procedure */
|
||||
|
||||
/* create logical color palette */
|
||||
palette[0] = 0xffffffL; /* White */
|
||||
palette[1] = 0xbbbbbbL;
|
||||
palette[2] = 0x777777L; /* Gray */
|
||||
palette[3] = 0x333333L;
|
||||
palette[4] = 0L; /* Black */
|
||||
|
||||
GpiCreateLogColorTable( hpsMemory, (ULONG)LCOL_PURECOLOR,
|
||||
(LONG)LCOLF_CONSECRGB, (LONG)0L,
|
||||
(LONG)5L, (PLONG)palette );
|
||||
|
||||
/* plot to presentation space in all five gray shades */
|
||||
for (x = 0 ; x < 5 ; x++)
|
||||
{
|
||||
GpiSetColor( hpsMemory, (LONG)x );
|
||||
coords.x = x;
|
||||
coords.y = 0;
|
||||
GpiSetPel( hpsMemory, &coords );
|
||||
}
|
||||
|
||||
/* retrieve the 5 pixels as gray_palette */
|
||||
GpiQueryBitmapInfoHeader( hbm, (PBITMAPINFOHEADER2) pbmi );
|
||||
GpiQueryBitmapBits( hpsMemory, 0L, (LONG)VIO_HEIGHT - 2,
|
||||
&Bitmap[0], pbmi );
|
||||
for ( x = 0; x < 5; x++ )
|
||||
{
|
||||
gray_palette[x] = Bitmap[x];
|
||||
}
|
||||
|
||||
/* initialization in case we paint before Driver_Display is called */
|
||||
memset( &Bitmap[0], gray_palette[0], vio_Height * vio_ScanLineWidth );
|
||||
DosReleaseMutexSem( hmtxPSMemoryLock );
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0; /* Unknown mode */
|
||||
}
|
||||
|
||||
return 1; /* success even if windows were not setup right */
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap( char* buffer, int lines, int cols )
|
||||
{
|
||||
int y, target;
|
||||
|
||||
|
||||
/* copy the bitmap and blt to presentation space */
|
||||
if ( (lines == vio_Height) & (cols == vio_ScanLineWidth) )
|
||||
memcpy( &Bitmap[0], buffer, lines * cols );
|
||||
else
|
||||
{
|
||||
memset( &Bitmap[0], gray_palette[0], vio_Height * vio_ScanLineWidth );
|
||||
/* temporary hack to center any bitmap */
|
||||
target = ( vio_Height - lines ) / 2 * vio_ScanLineWidth +
|
||||
( vio_ScanLineWidth - cols ) / 2;
|
||||
|
||||
for ( y = 0 ; y < lines ; y++ )
|
||||
{
|
||||
memcpy( &Bitmap[target], buffer, cols );
|
||||
target += vio_ScanLineWidth;
|
||||
buffer += cols;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get permission and write to in-memory ps */
|
||||
DosRequestMutexSem( hmtxPSMemoryLock, SEM_INDEFINITE_WAIT );
|
||||
GpiSetBitmapBits( hpsMemory, 0L, (LONG)VIO_HEIGHT - 2, &Bitmap[0], pbmi );
|
||||
DosReleaseMutexSem( hmtxPSMemoryLock );
|
||||
ready = TRUE;
|
||||
|
||||
/* Invalidate and ask for redraw now */
|
||||
WinInvalidateRect( hwndClient, NULL, FALSE );
|
||||
WinUpdateWindow( hwndFrame );
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
ULONG ulRequestCount;
|
||||
|
||||
|
||||
/* the Get_Event function blocks until there is an event to process */
|
||||
DosWaitEventSem( hevKeyLock, SEM_INDEFINITE_WAIT );
|
||||
DosQueryEventSem( hevKeyLock, &ulRequestCount );
|
||||
DosResetEventSem( hevKeyLock, &ulRequestCount );
|
||||
event->what = ourevent.what;
|
||||
event->info = ourevent.info;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void RunPMWindow( ULONG dummy )
|
||||
{
|
||||
unsigned char classname[] = "DisplayClass";
|
||||
ULONG flClassFlags;
|
||||
static HMQ hmq;
|
||||
QMSG qmsg;
|
||||
|
||||
|
||||
if ( (hab = WinInitialize( 0 )) == 0 )
|
||||
{
|
||||
printf( "Error doing WinInitialize()\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (hmq = WinCreateMsgQueue( hab, 0 )) == (HMQ)NULL )
|
||||
{
|
||||
printf( "Error doing WinCreateMsgQueue()\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !WinRegisterClass( hab, (PSZ)classname, (PFNWP)Message_Process,
|
||||
CS_SIZEREDRAW, 0 ) )
|
||||
{
|
||||
printf( "Error doing WinRegisterClass()\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
flClassFlags = FCF_TITLEBAR | FCF_MINBUTTON | FCF_DLGBORDER |
|
||||
FCF_TASKLIST | FCF_SYSMENU;
|
||||
if ( (hwndFrame = WinCreateStdWindow( HWND_DESKTOP,
|
||||
WS_VISIBLE,
|
||||
&flClassFlags,
|
||||
(PSZ)classname,
|
||||
(PSZ)"FreeType PM Graphics",
|
||||
WS_VISIBLE,
|
||||
0, 0, &hwndClient )) == 0 )
|
||||
{
|
||||
printf( "Error doing WinCreateStdWindow()\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
/* find the title window handle */
|
||||
hwndTitle = WinWindowFromID( hwndFrame, FID_TITLEBAR );
|
||||
|
||||
/* set Window size and position */
|
||||
WinSetWindowPos(
|
||||
hwndFrame, 0L,
|
||||
(SHORT)60,
|
||||
(SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) -
|
||||
( VIO_HEIGHT + MAG_HEIGHT + 100 ),
|
||||
(SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYDLGFRAME ) * 2 +
|
||||
VIO_WIDTH,
|
||||
(SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) +
|
||||
WinQuerySysValue( HWND_DESKTOP, SV_CYDLGFRAME ) * 2 +
|
||||
VIO_HEIGHT + MAG_HEIGHT,
|
||||
SWP_SIZE | SWP_MOVE ) ;
|
||||
|
||||
/* run the message queue till the end */
|
||||
while ( WinGetMsg( hab, &qmsg, (HWND)NULL, 0, 0 ) )
|
||||
WinDispatchMsg( hab, &qmsg );
|
||||
|
||||
/* clean-up */
|
||||
WinDestroyWindow( hwndFrame );
|
||||
hwndFrame = (HWND)NULL;
|
||||
WinDestroyMsgQueue( hmq );
|
||||
WinTerminate( hab );
|
||||
|
||||
/* await death... */
|
||||
while ( 1 )
|
||||
DosSleep( 100 );
|
||||
}
|
||||
|
||||
|
||||
void Adjust_Mag_Rectangle( void )
|
||||
{
|
||||
SIZEL source,
|
||||
target;
|
||||
|
||||
|
||||
/* Step 1, find optimal source size for this mag and window size */
|
||||
source.cx = mag_win_size.cx / magnification;
|
||||
if (source.cx > vio_Width) source.cx = vio_Width;
|
||||
source.cy = mag_win_size.cy / magnification;
|
||||
if (source.cy > vio_Height) source.cy = vio_Height;
|
||||
|
||||
target.cx = source.cx * magnification;
|
||||
target.cy = source.cy * magnification;
|
||||
|
||||
aptlMagd[0].x = (mag_win_size.cx - target.cx) / 2;
|
||||
aptlMagd[0].y = (mag_win_size.cy - target.cy) / 2;
|
||||
aptlMagd[1].x = aptlMagd[0].x + target.cx - 1;
|
||||
aptlMagd[1].y = aptlMagd[0].x + target.cy - 1;
|
||||
|
||||
/* Step 2, try crosshairs point dependent coordinates */
|
||||
aptlMagd[2].x = view_target.x - source.cx / 2;
|
||||
aptlMagd[2].y = view_target.y - source.cy / 2;
|
||||
if (aptlMagd[2].x < 0 ) aptlMagd[2].x = 0;
|
||||
if (aptlMagd[2].y < 0 ) aptlMagd[2].y = 0;
|
||||
if (aptlMagd[2].x > vio_Width - source.cx)
|
||||
aptlMagd[2].x = vio_Width - source.cx;
|
||||
if (aptlMagd[2].y > vio_Height - source.cy)
|
||||
aptlMagd[2].y = vio_Height - source.cy;
|
||||
|
||||
aptlMagd[3].x = aptlMagd[2].x + source.cx - 1;
|
||||
aptlMagd[3].y = aptlMagd[2].y + source.cy - 1;
|
||||
|
||||
} /* End of Adjust_Mag_Rectangle; */
|
||||
|
||||
|
||||
/* Message processing for our PM Window class */
|
||||
MRESULT EXPENTRY Message_Process( HWND handle, ULONG mess,
|
||||
MPARAM parm1, MPARAM parm2 )
|
||||
{
|
||||
static HDC hdc;
|
||||
static HPS hps;
|
||||
static BOOL minimized;
|
||||
|
||||
POINTL top_corner, bottom_corner;
|
||||
SWP swp;
|
||||
int i;
|
||||
|
||||
|
||||
switch( mess )
|
||||
{
|
||||
case WM_DESTROY:
|
||||
/* warn the main thread to quit if it didn't know */
|
||||
ourevent.what = event_Quit;
|
||||
ourevent.info = 0;
|
||||
DosPostEventSem( hevKeyLock );
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
/* set original magnification */
|
||||
magnification = 4;
|
||||
minimized = FALSE;
|
||||
|
||||
/* create Device Context and Presentation Space for screen. */
|
||||
/* could we use a cached one ? */
|
||||
hdc = WinOpenWindowDC( handle );
|
||||
mag_win_size.cx = 0;
|
||||
mag_win_size.cy = 0;
|
||||
hps = GpiCreatePS( hab, hdc, &mag_win_size,
|
||||
PU_PELS | GPIT_MICRO | GPIA_ASSOC | GPIF_DEFAULT );
|
||||
|
||||
/* Set to size of magnifier window */
|
||||
mag_win_size.cx = MAG_WIDTH;
|
||||
mag_win_size.cy = MAG_HEIGHT;
|
||||
Adjust_Mag_Rectangle();
|
||||
|
||||
/* take the input focus */
|
||||
WinFocusChange( HWND_DESKTOP, handle, 0L );
|
||||
break;
|
||||
|
||||
case WM_BUTTON1DOWN:
|
||||
if ( MOUSEMSG( &mess )->y >= MAG_HEIGHT )
|
||||
{
|
||||
view_target.x = MOUSEMSG( &mess )->x;
|
||||
view_target.y = MOUSEMSG( &mess )->y - MAG_HEIGHT;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( hwndClient, NULL, FALSE );
|
||||
}
|
||||
|
||||
return WinDefWindowProc( handle, mess, parm1, parm2 );
|
||||
break;
|
||||
|
||||
case WM_MINMAXFRAME:
|
||||
/* to update minimized if changed */
|
||||
swp = *((PSWP) parm1);
|
||||
if ( swp.fl & SWP_MINIMIZE )
|
||||
minimized = TRUE;
|
||||
if ( swp.fl & SWP_RESTORE )
|
||||
minimized = FALSE;
|
||||
return WinDefWindowProc( handle, mess, parm1, parm2 );
|
||||
break;
|
||||
|
||||
case WM_ERASEBACKGROUND:
|
||||
case WM_PAINT:
|
||||
/* reset the window title only if not minimized */
|
||||
if ( !minimized )
|
||||
WinSetWindowText( hwndTitle, Header );
|
||||
|
||||
/* copy the memory image of the screen out to the real screen */
|
||||
DosRequestMutexSem( hmtxPSMemoryLock, SEM_INDEFINITE_WAIT );
|
||||
WinBeginPaint( handle, hps, NULL );
|
||||
|
||||
/* main image and magnified picture */
|
||||
GpiBitBlt( hps, hpsMemory, 4L, aptlFull, ROP_SRCCOPY, BBO_AND );
|
||||
GpiBitBlt( hps, hpsMemory, 4L, aptlMagd, ROP_SRCCOPY, BBO_AND );
|
||||
|
||||
/* double-dash the magnifing bounding box. Paint the mag liner? */
|
||||
if ( magnification != 1 )
|
||||
{
|
||||
GpiSetLineType( hps, LINETYPE_LONGDASH );
|
||||
|
||||
bottom_corner.x = aptlMagd[2].x - 1;
|
||||
bottom_corner.y = aptlMagd[2].y + MAG_HEIGHT - 1;
|
||||
top_corner.x = aptlMagd[3].x ;
|
||||
top_corner.y = aptlMagd[3].y + MAG_HEIGHT;
|
||||
|
||||
GpiMove( hps, &bottom_corner );
|
||||
GpiBox( hps, DRO_OUTLINE, &top_corner, 0L, 0L );
|
||||
|
||||
#if 0
|
||||
GpiSetClipRegion();
|
||||
GpiErase();
|
||||
#endif
|
||||
}
|
||||
|
||||
WinEndPaint( hps );
|
||||
DosReleaseMutexSem( hmtxPSMemoryLock );
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
if ( CHARMSG( &mess )->fs & KC_KEYUP )
|
||||
break;
|
||||
|
||||
switch ( CHARMSG( &mess )->vkey )
|
||||
{
|
||||
case VK_ESC:
|
||||
ourevent.what = event_Quit;
|
||||
ourevent.info = 0;
|
||||
DosPostEventSem( hevKeyLock );
|
||||
break;
|
||||
|
||||
case VK_PAGEDOWN:
|
||||
if ( magnification < MAX_MAG )
|
||||
{
|
||||
magnification += 1;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( handle, NULL, FALSE );
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_PAGEUP:
|
||||
if ( magnification > 1 )
|
||||
{
|
||||
magnification -= 1;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( handle, NULL, FALSE );
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_LEFT:
|
||||
if ( view_target.x > 0 )
|
||||
{
|
||||
view_target.x -= 1;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( handle, NULL, FALSE );
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_RIGHT:
|
||||
if ( view_target.x < VIO_WIDTH - 1 )
|
||||
{
|
||||
view_target.x += 1;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( handle, NULL, FALSE );
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DOWN:
|
||||
if ( view_target.y > 0 )
|
||||
{
|
||||
view_target.y -= 1;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( handle, NULL, FALSE );
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_UP:
|
||||
if ( view_target.y < VIO_HEIGHT - 1 )
|
||||
{
|
||||
view_target.y += 1;
|
||||
Adjust_Mag_Rectangle();
|
||||
WinInvalidateRect( handle, NULL, FALSE );
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_F1: /* bring up help and about dialog window */
|
||||
break;
|
||||
}
|
||||
|
||||
if ( CHARMSG( &mess )->fs & KC_CHAR )
|
||||
{
|
||||
char c = (CHAR)CHARMSG( &mess )->chr ;
|
||||
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
ourevent.what = trans[i].event_class;
|
||||
ourevent.info = trans[i].event_info;
|
||||
DosPostEventSem( hevKeyLock );
|
||||
return (MRESULT)TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
ourevent.what = event_Keyboard;
|
||||
ourevent.info = (int)c;
|
||||
DosPostEventSem( hevKeyLock );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return WinDefWindowProc( handle, mess, parm1, parm2 );
|
||||
}
|
||||
|
||||
return (MRESULT) FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
5
test/arch/os2/gpm_os2.def
Normal file
5
test/arch/os2/gpm_os2.def
Normal file
@@ -0,0 +1,5 @@
|
||||
NAME WINDOWCOMPAT
|
||||
|
||||
DESCRIPTION 'FreeType Graphics'
|
||||
HEAPSIZE 8192
|
||||
STACKSIZE 40888
|
||||
1
test/arch/unix/.cvsignore
Normal file
1
test/arch/unix/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
Makefile
|
||||
170
test/arch/unix/Makefile.in
Normal file
170
test/arch/unix/Makefile.in
Normal file
@@ -0,0 +1,170 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# test/arch/unix/Makefile.in
|
||||
|
||||
ARCH = arch/unix
|
||||
|
||||
top_builddir=..
|
||||
|
||||
VPATH = @srcdir@/../..
|
||||
srcdir = @srcdir@/../..
|
||||
|
||||
RM = @RM@
|
||||
RMF = @RM@ -f
|
||||
RMDIR = @RMDIR@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
|
||||
LIBTOOL = $(top_builddir)/libtool
|
||||
MKINSTALLDIRS = $(srcdir)/../mkinstalldirs
|
||||
|
||||
include $(top_builddir)/MakeSub
|
||||
|
||||
FT_LIBDIR = $(srcdir)/../lib
|
||||
INCDIRS = -I. -I$(srcdir) -I$(top_builddir) \
|
||||
-I$(FT_LIBDIR) -I$(FT_LIBDIR)/extend
|
||||
|
||||
CFLAGS = @CFLAGS@ @X_CFLAGS@ @XX_CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
FT_CFLAGS = $(INCDIRS) $(CFLAGS) $(CPPFLAGS) -DX11 -DLOCALEDIR='"@LOCALEDIR@"'
|
||||
|
||||
FT_LIBS = @X_LIBS@ @X_PRE_LIBS@ @X_EXTRA_LIBS@ @LIBS@
|
||||
|
||||
SRC = $(srcdir)/arabic.c \
|
||||
$(srcdir)/common.c \
|
||||
$(srcdir)/ftdump.c \
|
||||
$(srcdir)/fterror.c \
|
||||
$(srcdir)/ftlint.c \
|
||||
$(srcdir)/ftmetric.c \
|
||||
$(srcdir)/ftsbit.c \
|
||||
$(srcdir)/ftstring.c \
|
||||
$(srcdir)/ftstrpnm.c \
|
||||
$(srcdir)/fttimer.c \
|
||||
$(srcdir)/ftview.c \
|
||||
$(srcdir)/ftzoom.c \
|
||||
$(srcdir)/ftstrtto.c \
|
||||
$(srcdir)/gmain.c \
|
||||
$(srcdir)/$(ARCH)/gwin_x11.c
|
||||
|
||||
DISPOBJS = common.o gmain.o display.o gwin_x11.o blitter.o
|
||||
|
||||
PROGRAMS = ftview fttimer ftlint ftdump ftzoom ftsbit \
|
||||
ftstring ftstrpnm fterror ftmetric ftstrtto
|
||||
|
||||
# set this variable to nil if you don't need to use Electric-Fence
|
||||
EFENCE =
|
||||
#EFENCE = -lefence
|
||||
|
||||
|
||||
# variables used to compile either with libtool or not
|
||||
#
|
||||
PROCESS = $(LIBTOOL) --mode=link $(CC) $(FT_CFLAGS)
|
||||
#PROCESS = $(CC) $(FT_CFLAGS)
|
||||
|
||||
LIBTTF = $(top_builddir)/lib/libttf.la
|
||||
#LIBTTF =$(top_builddir)/lib/libttf.a
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(FT_CFLAGS) $<
|
||||
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
|
||||
gwin_x11.o: $(srcdir)/$(ARCH)/gwin_x11.c
|
||||
$(CC) -c $(FT_CFLAGS) $(srcdir)/$(ARCH)/gwin_x11.c
|
||||
|
||||
ftzoom: ftzoom.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o ftzoom ftzoom.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
fttimer: fttimer.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o fttimer fttimer.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
ftview: ftview.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o ftview ftview.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
ftlint: ftlint.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftlint ftlint.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftdump: ftdump.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftdump ftdump.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftmetric: ftmetric.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftmetric ftmetric.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftsbit: ftsbit.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftsbit ftsbit.o common.o \
|
||||
$(EFENCE) $(LIBTTF)
|
||||
|
||||
ftstring: ftstring.o $(DISPOBJS) $(LIBTTF)
|
||||
$(PROCESS) -o ftstring ftstring.o $(DISPOBJS) \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
# ftstrpnm does not need any extra libraries
|
||||
ftstrpnm: ftstrpnm.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o ftstrpnm ftstrpnm.o common.o \
|
||||
$(EFENCE) $(LIBTTF)
|
||||
|
||||
fterror: fterror.o common.o $(LIBTTF)
|
||||
$(PROCESS) -o fterror fterror.o common.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS)
|
||||
|
||||
ftstrtto: ftstrtto.o $(DISPOBJS) arabic.o $(LIBTTF)
|
||||
$(PROCESS) -o ftstrtto ftstrtto.o $(DISPOBJS) arabic.o \
|
||||
$(EFENCE) $(LIBTTF) $(FT_LIBS) -lX11
|
||||
|
||||
|
||||
install: $(PROGRAMS)
|
||||
$(MKINSTALLDIRS) $(bindir)
|
||||
for P in $(PROGRAMS) ; do \
|
||||
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$P $(bindir)/$$P ; \
|
||||
done
|
||||
|
||||
uninstall:
|
||||
-for P in $(PROGRAMS) ; do \
|
||||
$(LIBTOOL) --mode=uninstall $(RM) $(bindir)/$$P ; \
|
||||
done
|
||||
|
||||
clean: do_clean
|
||||
|
||||
distclean: do_clean
|
||||
-$(RMF) $(PROGRAMS)
|
||||
-$(RMF) *~ *.orig core *.core
|
||||
-$(RMF) config.cache config.log config.status
|
||||
-$(RMF) $(ARCH)/Makefile
|
||||
-$(RMF) .libs/*
|
||||
-$(RMDIR) .libs
|
||||
|
||||
do_clean:
|
||||
-$(RMF) *.o
|
||||
|
||||
depend:
|
||||
(echo '/^#.* PUT NO STUFF BELOW/,$$d' ; echo w ; echo q) | \
|
||||
ed - $(ARCH)/Makefile
|
||||
echo '# Dependencies generated by make depend: PUT NO STUFF BELOW' \
|
||||
>> $(ARCH)/Makefile
|
||||
for file in $(SRC) ; do \
|
||||
$(CPP) $(CPPFLAGS) $(INCDIRS) $$file | \
|
||||
sed -n -e 's|^# [1-9][0-9]* "\([^/].*\.h\)".*|\1|p' \
|
||||
-e 's|^# [1-9][0-9]* "\($(srcdir)/.*\.h\)".*|\1|p' | \
|
||||
sed -e 's|/\./|.|g' -e "s/^/`basename $$file .c`.o: /" ; \
|
||||
done | \
|
||||
sort -u | \
|
||||
awk '{ if (LINE == 1) \
|
||||
{ line = last = $$1 } \
|
||||
else if ($$1 != last) \
|
||||
{ print line ; line = last = $$1 } \
|
||||
line = line " " $$2 } \
|
||||
END { print line }' >> $(ARCH)/Makefile
|
||||
|
||||
# Dependencies generated by make depend: PUT NO STUFF BELOW
|
||||
451
test/arch/unix/gwin_x11.c
Normal file
451
test/arch/unix/gwin_x11.c
Normal file
@@ -0,0 +1,451 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gwin_x11.c graphics utility X-Window driver. 1.0
|
||||
*
|
||||
* This is the driver for windowed display under X11, used by the
|
||||
* graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#include "common.h" /* for Panic() */
|
||||
#include "freetype.h"
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
/* Translator added to ease changes to control keys */
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
/* End of translators addition. See Get_Event() below */
|
||||
|
||||
extern char Header[]; /* defined in the test programs */
|
||||
|
||||
static Window win;
|
||||
static GC gcblack;
|
||||
static XColor color[5];
|
||||
|
||||
Display* display;
|
||||
static char* displayname = "";
|
||||
|
||||
static XImage* image;
|
||||
|
||||
static Visual* visual;
|
||||
static Colormap colormap;
|
||||
static int depth;
|
||||
static Bool gray;
|
||||
|
||||
static Cursor idle;
|
||||
static Cursor busy;
|
||||
|
||||
static int win_origin_x, win_origin_y,
|
||||
win_width, win_height;
|
||||
static int image_width, image_height;
|
||||
|
||||
long vioBufOfs;
|
||||
|
||||
|
||||
|
||||
/* restore acreen to its original state */
|
||||
|
||||
int Driver_Restore_Mode( void )
|
||||
{
|
||||
XUnmapWindow( display, win );
|
||||
XCloseDisplay( display );
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
/* set graphics mode */
|
||||
|
||||
void x11init( void )
|
||||
{
|
||||
int screen_num, i;
|
||||
XTextProperty xtp;
|
||||
XSizeHints xsh;
|
||||
XSetWindowAttributes xswa;
|
||||
|
||||
#if 1
|
||||
unsigned short colors[5] = { 0, 16, 32, 48, 63 }; /* gamma = 1.0 */
|
||||
#else
|
||||
unsigned short colors[5] = { 0, 34, 46, 55, 63 }; /* gamma = 2.2 */
|
||||
#endif
|
||||
|
||||
|
||||
XrmInitialize();
|
||||
|
||||
if( !( display = XOpenDisplay( displayname ) ) )
|
||||
Panic( "ERROR: cannot open display\n" );
|
||||
|
||||
screen_num = DefaultScreen ( display );
|
||||
colormap = DefaultColormap( display, screen_num );
|
||||
depth = DefaultDepth ( display, screen_num );
|
||||
visual = DefaultVisual ( display, screen_num );
|
||||
|
||||
idle = XCreateFontCursor( display, XC_left_ptr );
|
||||
busy = XCreateFontCursor( display, XC_watch );
|
||||
|
||||
if ( gray )
|
||||
{
|
||||
int count;
|
||||
XPixmapFormatValues* formats;
|
||||
|
||||
|
||||
formats = XListPixmapFormats( display, &count );
|
||||
vio_ScanLineWidth = 0;
|
||||
|
||||
while ( count > 0 )
|
||||
{
|
||||
--count;
|
||||
if ( formats[count].depth == depth )
|
||||
{
|
||||
int bits;
|
||||
|
||||
bits = win_width * formats[count].bits_per_pixel;
|
||||
if ( bits % formats[count].scanline_pad )
|
||||
{
|
||||
bits -= bits % formats[count].scanline_pad;
|
||||
bits += formats[count].scanline_pad;
|
||||
}
|
||||
|
||||
vio_ScanLineWidth = bits / 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !vio_ScanLineWidth )
|
||||
Panic( "ERROR: the display doesn't offer a suitable pixmap format\n" );
|
||||
|
||||
XFree( formats );
|
||||
}
|
||||
|
||||
Vio = (char*)malloc( win_height * vio_ScanLineWidth );
|
||||
|
||||
if ( !Vio )
|
||||
Panic( "ERROR: cannot malloc display memory\n" );
|
||||
|
||||
xswa.border_pixel = BlackPixel( display, screen_num );
|
||||
xswa.background_pixel = WhitePixel( display, screen_num );
|
||||
xswa.cursor = busy;
|
||||
|
||||
xswa.event_mask = KeyPressMask | ExposureMask;
|
||||
|
||||
win = XCreateWindow( display,
|
||||
RootWindow( display, screen_num ),
|
||||
win_origin_x,
|
||||
win_origin_y,
|
||||
win_width,
|
||||
win_height,
|
||||
10,
|
||||
depth,
|
||||
InputOutput,
|
||||
visual,
|
||||
CWBackPixel | CWBorderPixel | CWEventMask | CWCursor,
|
||||
&xswa );
|
||||
|
||||
XMapWindow( display, win );
|
||||
|
||||
gcblack = XCreateGC( display, RootWindow( display, screen_num ),
|
||||
0L, NULL );
|
||||
XSetForeground( display, gcblack, BlackPixel( display, screen_num ) );
|
||||
XSetBackground( display, gcblack, WhitePixel( display, screen_num ) );
|
||||
|
||||
/* allocate colors */
|
||||
|
||||
if ( gray )
|
||||
for ( i = 0; i < 5; i++ )
|
||||
{
|
||||
gray_palette[i] = i;
|
||||
|
||||
color[i].red =
|
||||
color[i].green =
|
||||
color[i].blue = 65535 - ( colors[i] * 65535 ) / 63;
|
||||
|
||||
if ( !XAllocColor( display, colormap, &color[i] ) )
|
||||
Panic( "ERROR: cannot allocate Color\n" );
|
||||
}
|
||||
|
||||
image = XCreateImage( display,
|
||||
visual,
|
||||
gray ? depth : 1,
|
||||
gray ? ZPixmap : XYBitmap,
|
||||
0,
|
||||
(char*)Vio,
|
||||
win_width,
|
||||
win_height,
|
||||
8,
|
||||
0 );
|
||||
if ( !image )
|
||||
Panic( "ERROR: cannot create image\n" );
|
||||
|
||||
if ( !gray )
|
||||
{
|
||||
image->byte_order = MSBFirst;
|
||||
image->bitmap_bit_order = MSBFirst;
|
||||
}
|
||||
|
||||
/* make window manager happy :-) */
|
||||
xtp.value = (unsigned char*)"FreeType";
|
||||
xtp.encoding = 31;
|
||||
xtp.format = 8;
|
||||
xtp.nitems = strlen( (char*)xtp.value );
|
||||
|
||||
xsh.x = win_origin_x;
|
||||
xsh.y = win_origin_y;
|
||||
|
||||
xsh.width = win_width;
|
||||
xsh.height = win_height;
|
||||
xsh.flags = (PPosition | PSize);
|
||||
xsh.flags = 0;
|
||||
|
||||
XSetWMProperties( display, win, &xtp, &xtp, NULL, 0, &xsh, NULL, NULL );
|
||||
}
|
||||
|
||||
|
||||
int Driver_Set_Graphics( int mode )
|
||||
{
|
||||
if ( mode == Graphics_Mode_Gray )
|
||||
{
|
||||
gray = 1;
|
||||
vio_ScanLineWidth = 320;
|
||||
|
||||
win_origin_x = 0;
|
||||
win_origin_y = 0;
|
||||
win_width = 320;
|
||||
win_height = 200;
|
||||
}
|
||||
else if ( mode == Graphics_Mode_Mono )
|
||||
{
|
||||
gray = 0;
|
||||
vio_ScanLineWidth = 80;
|
||||
|
||||
win_origin_x = 0;
|
||||
win_origin_y = 0;
|
||||
win_width = 640;
|
||||
win_height = 450;
|
||||
}
|
||||
else
|
||||
Panic( "ERROR: mode %d not supported\n", mode );
|
||||
|
||||
vio_Width = win_width;
|
||||
vio_Height = win_height;
|
||||
|
||||
x11init();
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Put_Image( int x, int y, int w, int h )
|
||||
{
|
||||
XPutImage( display, win, gcblack, image, x, y, x, y, w, h );
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col )
|
||||
{
|
||||
int z, y, used_col;
|
||||
char* target;
|
||||
|
||||
|
||||
XClearWindow( display, win );
|
||||
|
||||
/* this displays the Header string in the window title */
|
||||
XStoreName( display, win, Header );
|
||||
|
||||
if ( line > win_height )
|
||||
line = win_height;
|
||||
|
||||
if ( !gray )
|
||||
{
|
||||
if ( col > vio_ScanLineWidth )
|
||||
used_col = vio_ScanLineWidth;
|
||||
else
|
||||
used_col = col;
|
||||
|
||||
target = Vio + ( line - 1 ) * vio_ScanLineWidth;
|
||||
|
||||
for ( y = 0; y < line; y++ )
|
||||
{
|
||||
memcpy( (char*)target, buffer, used_col );
|
||||
target -= vio_ScanLineWidth;
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
Put_Image( 0, 0, used_col * 8, line );
|
||||
image_width = used_col * 8;
|
||||
image_height = line;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( col > win_width )
|
||||
used_col = win_width;
|
||||
else
|
||||
used_col = col;
|
||||
|
||||
for ( y = line - 1; y >= 0; y-- )
|
||||
{
|
||||
char* bufp;
|
||||
|
||||
|
||||
bufp = buffer;
|
||||
|
||||
for ( z = 0; z < used_col; z++ )
|
||||
{
|
||||
int c;
|
||||
|
||||
|
||||
c = *bufp++;
|
||||
|
||||
if ( c < 0 || c >= 5 ) /* security check */
|
||||
{
|
||||
/* Message( "weird grayshade: %d\n", c ); */
|
||||
c = 0;
|
||||
}
|
||||
XPutPixel( image, z, y, color[c].pixel );
|
||||
}
|
||||
|
||||
buffer += col;
|
||||
}
|
||||
|
||||
Put_Image( 0, 0, used_col, line );
|
||||
image_width = used_col;
|
||||
image_height = line;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* This function maps X keystrokes into GEvents. Note that */
|
||||
/* currently only keystrokes events exit this function. */
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
static char key_buffer[10];
|
||||
static int key_cursor = 0;
|
||||
static int key_number = 0;
|
||||
static XEvent x_event;
|
||||
KeySym key;
|
||||
|
||||
int i, bool_exit;
|
||||
char c;
|
||||
|
||||
XComposeStatus compose;
|
||||
|
||||
|
||||
bool_exit = key_cursor < key_number;
|
||||
|
||||
XDefineCursor( display, win, idle );
|
||||
|
||||
while ( !bool_exit )
|
||||
{
|
||||
XNextEvent( display, &x_event );
|
||||
|
||||
switch ( x_event.type )
|
||||
{
|
||||
case KeyPress:
|
||||
key_number = XLookupString( &x_event.xkey,
|
||||
key_buffer,
|
||||
sizeof ( key_buffer ),
|
||||
&key,
|
||||
&compose );
|
||||
key_cursor = 0;
|
||||
|
||||
if ( key_number > 0 )
|
||||
bool_exit = 1;
|
||||
break;
|
||||
|
||||
case MappingNotify:
|
||||
XRefreshKeyboardMapping( &x_event.xmapping );
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
#if 0
|
||||
Put_Image( x_event.xexpose.x,
|
||||
x_event.xexpose.y,
|
||||
x_event.xexpose.width,
|
||||
x_event.xexpose.height );
|
||||
#else
|
||||
/* we always redraw the whole image */
|
||||
Put_Image( 0, 0, image_width, image_height );
|
||||
#endif
|
||||
break;
|
||||
|
||||
/* You should add more cases to handle mouse events, etc. */
|
||||
}
|
||||
}
|
||||
|
||||
XDefineCursor( display, win, busy );
|
||||
XFlush ( display );
|
||||
|
||||
c = key_buffer[key_cursor++];
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
event->what = trans[i].event_class;
|
||||
event->info = trans[i].event_info;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event->what = event_Keyboard;
|
||||
event->info = (int)c;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
212
test/arch/win16/Makefile.BC
Normal file
212
test/arch/win16/Makefile.BC
Normal file
@@ -0,0 +1,212 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for BC++ for 16-bit Windows,
|
||||
# using large model, and using Easy-Win to display console outputs.
|
||||
#
|
||||
# Tested with Borland C++ v.4.02, 5.0
|
||||
# You will need Borland MAKE (v.3.6 and above should be OK, for oldest
|
||||
# versions refer to the instructions below).
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -farch\win16\Makefile.BC
|
||||
#
|
||||
#
|
||||
# A DLL version of the library can be built and then used with
|
||||
#
|
||||
# make -DDLL -farch/win16/Makefile.BC dll
|
||||
#
|
||||
# (do not forget to define DLL, otherwise the link phase will fail).
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained with
|
||||
#
|
||||
# make -DDEBUG -farch\win16\Makefile.BC
|
||||
#
|
||||
# Special versions enabled to handle big fonts (with more than 16,384
|
||||
# glyphs) can be obtained with
|
||||
#
|
||||
# make -DBIGFONTS -farch\msdos\Makefile.BC
|
||||
|
||||
ARCH = arch\win16
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.BC
|
||||
FT_DLL = ft13_16.dll
|
||||
|
||||
CC = bcc
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR);$(LIBDIR)\$(ARCH);.;$(LIBDIR)\extend
|
||||
SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -w-pia
|
||||
|
||||
# Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern
|
||||
# Borland compilers (from BC++ 3.1 on) can increase the limit of
|
||||
# the length of identifiers.
|
||||
CFLAGS = -WSE -ml -A -i40 $(INCDIRS) $(SPURIOUS_WARNINGS)
|
||||
|
||||
!if ! $d(DEBUG)
|
||||
CFLAGS = $(CFLAGS) -O2 -3
|
||||
LDFLAGS = -ml -W -lC
|
||||
!else
|
||||
CFLAGS = $(CFLAGS) -v -N
|
||||
LDFLAGS = -v -ml -W -lC
|
||||
!endif
|
||||
|
||||
!if $d(DLL)
|
||||
CFLAGS = $(CFLAGS) -DFREETYPE_DLL
|
||||
!endif
|
||||
|
||||
|
||||
# Windows graphic driver
|
||||
GDRIVER = $(ARCH)\gw_win16.c
|
||||
|
||||
DISPLAY = display.c
|
||||
|
||||
G1SRC = gmain.c blitter.c $(GDRIVER)
|
||||
GSRC = $(DISPLAY) $(G1SRC)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
G1OBJ = $(G1SRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
$(CC) -c -o$* @&&|
|
||||
$(CFLAGS) $<
|
||||
|
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!if !$d(DEBUG)
|
||||
# Skipped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
dll: the_dll $(EXEFILES)
|
||||
|
||||
!else
|
||||
# Skipped if non-DEBUG build
|
||||
default_target: debug
|
||||
dll: the_debug_dll $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
|
||||
!if $d(BIGFONTS)
|
||||
MAKEBIG = -DBIGFONTS
|
||||
!endif
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) $(MAKEBIG) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDEBUG $(MAKEBIG) debug
|
||||
cd ..\test
|
||||
|
||||
the_dll:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDLL $(MAKEBIG) dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
the_debug_dll:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDEBUG -DDLL $(MAKEBIG) dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
|
||||
# C compilers are unable to include 16-bit <windows.h> in ANSI mode.
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER:.c=.obj):
|
||||
$(CC) -c -o$* @&&|
|
||||
$(CFLAGS) -A- $*.c
|
||||
|
|
||||
|
||||
|
||||
# Borland versions of make are unable to use the $** variable inside
|
||||
# implicit rules (like .obj.exe:). The job have to be done by hand. :-(
|
||||
ftzoom.exe: $(G1OBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftzoom.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftview.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstring.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrtto.obj $(GOBJ) common.obj arabic.obj \
|
||||
$(LIBDIR)\libttf.lib
|
||||
|
||||
fttimer.exe: $(G1OBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fttimer.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
-del *.dll
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
|
||||
!include "$(ARCH)\depend.win"
|
||||
|
||||
# end of Makefile
|
||||
145
test/arch/win16/Makefile.MS
Normal file
145
test/arch/win16/Makefile.MS
Normal file
@@ -0,0 +1,145 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for Microsoft C compilers
|
||||
# for 16-bit Windows, large model, using QuickWin to display console
|
||||
# outputs. It also works for Visual C++ 1.x 16-bits compiler, but
|
||||
# you should instead use the Makefile customized for it, Makefile.VC.
|
||||
#
|
||||
# You will need NMAKE.
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# nmake /f arch\win16\Makefile.MS
|
||||
#
|
||||
#
|
||||
# A debug version can be obtained with
|
||||
#
|
||||
# nmake DEBUG=1 /f arch\win16\Makefile.MS
|
||||
|
||||
ARCH = arch\win16
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.MS
|
||||
FT_MAKE = $(MAKE) /nologo
|
||||
|
||||
CC = cl /nologo
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\$(ARCH) -I. -I$(LIBDIR)\extend
|
||||
|
||||
!ifndef DEBUG
|
||||
CFLAGS = /Ox /AL /Za /W2 /G2 $(INCDIRS)
|
||||
LDFLAGS = /AL
|
||||
!else
|
||||
CFLAGS = /Zi /AL /Za /W2 /G2 $(INCDIRS)
|
||||
LDFLAGS = /Zi /AL
|
||||
!endif
|
||||
|
||||
CFLAGS = $(CFLAGS) /GA /Mq
|
||||
LDFLAGS = $(LDFLAGS) /GA /Mq
|
||||
|
||||
|
||||
# Windows graphic driver
|
||||
GDRIVER = $(ARCH)\gw_win16.c
|
||||
|
||||
GSRC = display.c gmain.c blitter.c $(GDRIVER)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) $<
|
||||
<<
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!ifndef DEBUG
|
||||
# Skiped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 debug
|
||||
cd ..\test
|
||||
|
||||
|
||||
# C compilers are unable to include 16-bit <windows.h> in ANSI mode.
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER:.c=.obj):
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) /Ze $(GDRIVER)
|
||||
<<
|
||||
|
||||
.obj.exe:
|
||||
$(CC) /Fe$* @<<
|
||||
$(LDFLAGS) $**
|
||||
<<
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
fttimer.exe: $(GOBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
|
||||
|
||||
!include "$(ARCH)\depend.win"
|
||||
|
||||
# end of Makefile.MS
|
||||
187
test/arch/win16/Makefile.VC
Normal file
187
test/arch/win16/Makefile.VC
Normal file
@@ -0,0 +1,187 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for Microsoft Visual C++ 1.x
|
||||
# and Microsoft C/C++ v.7.0 compilers for 16-bit Windows, large model,
|
||||
# using QuickWin to display console outputs.
|
||||
#
|
||||
# You will need NMAKE.
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# nmake /f arch\win16\Makefile.VC
|
||||
#
|
||||
# A DLL version of the library can be built and then used with
|
||||
#
|
||||
# nmake DLL=1 /f arch\win16\Makefile.VC dll
|
||||
#
|
||||
# (do not forget to define DLL, otherwise the link phase will fail).
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained with
|
||||
#
|
||||
# nmake DEBUG=1 /f arch\win16\Makefile.VC
|
||||
#
|
||||
# Special versions enabled to handle big fonts (with more than 16,384
|
||||
# glyphs) can be obtained with
|
||||
#
|
||||
# nmake BIGFONTS=1 /f arch\win16\Makefile.VC
|
||||
|
||||
ARCH = arch\win16
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.VC
|
||||
FT_MAKE = $(MAKE) /nologo
|
||||
FT_DLL = ft13_16.dll
|
||||
|
||||
CC = cl /nologo
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\$(ARCH) -I. -I$(LIBDIR)\extend
|
||||
|
||||
# One can also consider using "set MSC_CMD_FLAGS=/Gr /Op- /Gy /YX".
|
||||
# With Microsoft C/C++ 7.0, use /G2 instead of /G3.
|
||||
!ifndef DEBUG
|
||||
CFLAGS = /Ox /AL /Za /W2 /G3 $(INCDIRS)
|
||||
LDFLAGS = /AL
|
||||
!else
|
||||
CFLAGS = /Zi /Ge /AL /Za /W2 /G3 $(INCDIRS)
|
||||
LDFLAGS = /Zi /AL
|
||||
!endif
|
||||
|
||||
CFLAGS = $(CFLAGS) /Mq
|
||||
LDFLAGS = $(LDFLAGS) /Mq
|
||||
|
||||
!ifdef DLL
|
||||
CFLAGS = $(CFLAGS) /DFREETYPE_DLL
|
||||
!endif
|
||||
|
||||
|
||||
# Windows graphic driver
|
||||
GDRIVER = $(ARCH)\gw_win16.c
|
||||
|
||||
GSRC = display.c gmain.c blitter.c $(GDRIVER)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) $<
|
||||
<<
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!ifndef DEBUG
|
||||
# Skiped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
dll: the_dll $(EXEFILES)
|
||||
|
||||
!else
|
||||
# Skipped if non-DEBUG build
|
||||
default_target: debug
|
||||
dll: the_debug_dll $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
!ifdef BIGFONTS
|
||||
MAKEBIG = BIGFONTS=1
|
||||
!endif
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) $(MAKEBIG) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 $(MAKEBIG) debug
|
||||
cd ..\test
|
||||
|
||||
the_dll:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DLL=1 $(MAKEBIG) dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
the_debug_dll:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 DLL=1 $(MAKEBIG) dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
|
||||
# C compilers are unable to include 16-bit <windows.h> in ANSI mode.
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER:.c=.obj):
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) /Ze $(GDRIVER)
|
||||
<<
|
||||
|
||||
.obj.exe:
|
||||
$(CC) /Fe$* @<<
|
||||
$(LDFLAGS) $**
|
||||
<<
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
fttimer.exe: $(GOBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
-del *.dll
|
||||
-del *.pdb
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
|
||||
|
||||
!include "$(ARCH)\depend.win"
|
||||
|
||||
# end of Makefile.VC
|
||||
52
test/arch/win16/depend.win
Normal file
52
test/arch/win16/depend.win
Normal file
@@ -0,0 +1,52 @@
|
||||
# This dependency file to be used with various Windows compilers
|
||||
# has been generated automatically with the script `makedep' on
|
||||
# 02-Sep-1999.
|
||||
|
||||
arabic.obj: arabic.c arabic.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxopen.h ..\lib\extend\ftxgdef.h \
|
||||
..\lib\extend\ftxgsub.h ..\lib\extend\ftxgpos.h
|
||||
blitter.obj: blitter.c blitter.h
|
||||
common.obj: common.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h
|
||||
display.obj: display.c display.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h gmain.h
|
||||
fdebug.obj: fdebug.c ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\tttypes.h ..\lib\ttconfig.h \
|
||||
..\lib\arch\win16\ft_conf.h ..\lib\ttdebug.h ..\lib\ttobjs.h \
|
||||
..\lib\ttengine.h ..\lib\ttmutex.h ..\lib\ttcache.h ..\lib\tttables.h \
|
||||
..\lib\ttcmap.h
|
||||
ftdump.obj: ftdump.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxcmap.h ..\lib\extend\ftxopen.h \
|
||||
..\lib\extend\ftxgdef.h ..\lib\extend\ftxgsub.h \
|
||||
..\lib\extend\ftxgpos.h ..\lib\extend\ftxsbit.h ..\lib\ttobjs.h \
|
||||
..\lib\ttconfig.h ..\lib\arch\win16\ft_conf.h ..\lib\ttengine.h \
|
||||
..\lib\tttypes.h ..\lib\ttmutex.h ..\lib\ttcache.h ..\lib\tttables.h \
|
||||
..\lib\ttcmap.h
|
||||
fterror.obj: fterror.c ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxerr18.h \
|
||||
..\lib\arch\win16\ft_conf.h
|
||||
ftlint.obj: ftlint.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\arch\win16\ft_conf.h
|
||||
ftmetric.obj: ftmetric.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxsbit.h ..\lib\arch\win16\ft_conf.h
|
||||
ftsbit.obj: ftsbit.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxsbit.h ..\lib\arch\win16\ft_conf.h
|
||||
ftstring.obj: ftstring.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h display.h gevents.h gdriver.h gmain.h
|
||||
ftstrpnm.obj: ftstrpnm.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h
|
||||
ftstrtto.obj: ftstrtto.c arabic.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxopen.h ..\lib\extend\ftxgdef.h \
|
||||
..\lib\extend\ftxgsub.h ..\lib\extend\ftxgpos.h blitter.h common.h \
|
||||
display.h ..\lib\extend\ftxkern.h ..\lib\extend\ftxsbit.h gdriver.h \
|
||||
gevents.h gmain.h
|
||||
fttimer.obj: fttimer.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h gdriver.h gevents.h gmain.h
|
||||
ftview.obj: ftview.c blitter.h common.h display.h \
|
||||
..\lib\extend\ftxsbit.h gdriver.h gevents.h gmain.h
|
||||
ftzoom.obj: ftzoom.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxpost.h gdriver.h gevents.h gmain.h
|
||||
gmain.obj: gmain.c gdriver.h gmain.h
|
||||
!ifndef __MAKE__
|
||||
arch\win16\gw_win16.obj: arch\win16\gw_win16.c gdriver.h gevents.h gmain.h
|
||||
!endif
|
||||
430
test/arch/win16/gw_win16.c
Normal file
430
test/arch/win16/gw_win16.c
Normal file
@@ -0,0 +1,430 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gw_win16.c graphics driver for 16-bit Windows platform. 0.1
|
||||
*
|
||||
* This is the driver for displaying inside a window under 16-bit
|
||||
* Microsoft Windows, used by the graphics utility of the
|
||||
* FreeType test suite.
|
||||
*
|
||||
* Written by Antoine Leca.
|
||||
* Copyright 1999 by Antoine Leca,
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* Borrowing liberally from the other FreeType drivers.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
/* The following #ifdef are used to define the following macros : */
|
||||
/* */
|
||||
/* - hInst : variable containing the handle of the current instance. */
|
||||
/* - hPrev : variable containing the handle of the previous instance. */
|
||||
/* */
|
||||
|
||||
/* ---- Microsoft C compilers support ------------------------------------ */
|
||||
|
||||
#if defined( M_I86 ) || defined( _M_I86 )
|
||||
|
||||
extern HINSTANCE _hInstance, _hPrevInstance;
|
||||
#define hInst _hInstance
|
||||
#define hPrev _hPrevInstance
|
||||
|
||||
#endif
|
||||
|
||||
/* ---- Borland C compiler support --------------------------------------- */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
|
||||
#pragma option -A-
|
||||
|
||||
extern HINSTANCE _hInstance, _hPrev;
|
||||
#define hInst _hInstance
|
||||
#define hPrev _hPrev
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined ( hInst ) || !defined ( hPrev )
|
||||
#error Your compiler is not (yet) supported. Check the source file!
|
||||
#endif
|
||||
|
||||
/* ---- Common initialisations ------------------------------------------- */
|
||||
|
||||
/* Size of the window. */
|
||||
#define WIN_WIDTH 640u
|
||||
#define WIN_HEIGHT 400u
|
||||
/* The values will be divided by 2 for gray-scale rendering. */
|
||||
|
||||
/* These values can be changed, but WIN_WIDTH should remain for now a */
|
||||
/* multiple of 32 to avoid padding issues. */
|
||||
|
||||
/* Also, to avoid 16-bit overflowing issues, the product */
|
||||
/* WIN_WIDTH * WIN_HEIGHT should not excess 512K for monochrome */
|
||||
/* rendering, and 256K for gray-scale rendering. */
|
||||
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
/* handle of the window. */
|
||||
static HWND hwndGraphic;
|
||||
|
||||
/* bitmap information */
|
||||
static LPBITMAPINFO pbmi;
|
||||
static HBITMAP hbm;
|
||||
|
||||
/* local event to pass on */
|
||||
static TEvent ourevent = { event_Quit, 0 };
|
||||
static int eventToProcess = 0;
|
||||
|
||||
/* array defined in the test programs */
|
||||
extern char Header[];
|
||||
|
||||
|
||||
/* restores screen to its original state */
|
||||
|
||||
int Driver_Restore_Mode()
|
||||
{
|
||||
/* The graphical window has perhaps already destroyed itself */
|
||||
if ( hwndGraphic ) {
|
||||
DestroyWindow ( hwndGraphic );
|
||||
PostMessage ( hwndGraphic, WM_QUIT, 0, 0 );
|
||||
}
|
||||
|
||||
if ( pbmi ) free ( pbmi );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* set graphics mode
|
||||
* and create the window class and the message handling.
|
||||
*/
|
||||
|
||||
/* Declarations of the Windows-specific functions that are below. */
|
||||
static BOOL RegisterTheClass ( void );
|
||||
static BOOL CreateTheWindow ( int width, int height );
|
||||
|
||||
|
||||
int Driver_Set_Graphics ( int mode )
|
||||
{
|
||||
int i;
|
||||
static const RGBQUAD gray_scale[5] = {
|
||||
{ 0xFF, 0xFF, 0xFF, 0 }, /* white */
|
||||
{ 0xC0, 0xC0, 0xC0, 0 },
|
||||
{ 0x80, 0x80, 0x80, 0 },
|
||||
{ 0x40, 0x40, 0x40, 0 },
|
||||
{ 0, 0, 0, 0 } }; /* black */
|
||||
|
||||
if( ! RegisterTheClass() ) return 0; /* if already running, fails. */
|
||||
|
||||
/* find some memory for the bitmap header */
|
||||
if ( (pbmi = malloc ( sizeof ( BITMAPINFO ) + sizeof ( RGBQUAD ) * 256 ) )
|
||||
/* 256 should really be 2 if not grayscale */
|
||||
== NULL )
|
||||
/* lack of memory; fails the process */
|
||||
return 0;
|
||||
|
||||
/* initialize the header to appropriate values */
|
||||
memset( pbmi, 0, sizeof ( BITMAPINFO ) + sizeof ( RGBQUAD ) * 256 );
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono:
|
||||
pbmi->bmiHeader.biBitCount = 1;
|
||||
pbmi->bmiColors[0] = gray_scale[0];
|
||||
pbmi->bmiColors[1] = gray_scale[4];
|
||||
|
||||
vio_ScanLineWidth = WIN_WIDTH / 8;
|
||||
vio_Width = WIN_WIDTH;
|
||||
vio_Height = WIN_HEIGHT;
|
||||
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray:
|
||||
pbmi->bmiHeader.biBitCount = 8;
|
||||
pbmi->bmiHeader.biClrUsed = 5;
|
||||
|
||||
memcpy ( &pbmi->bmiColors[0], gray_scale, sizeof gray_scale );
|
||||
|
||||
vio_ScanLineWidth = WIN_WIDTH / 2;
|
||||
vio_Width = WIN_WIDTH / 2;
|
||||
vio_Height = WIN_HEIGHT/ 2;
|
||||
|
||||
for ( i = 0; i < 5; ++i )
|
||||
gray_palette[i] = i;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
free ( pbmi );
|
||||
return 0; /* Unknown mode */
|
||||
}
|
||||
|
||||
pbmi->bmiHeader.biSize = sizeof ( BITMAPINFOHEADER );
|
||||
pbmi->bmiHeader.biWidth = vio_Width;
|
||||
pbmi->bmiHeader.biHeight = vio_Height;
|
||||
pbmi->bmiHeader.biPlanes = 1;
|
||||
|
||||
if ( (long) vio_Height * vio_ScanLineWidth > 0xFFE0ul )
|
||||
/* too big to work on 16-bit; fails the process */
|
||||
{
|
||||
free ( pbmi );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( ! CreateTheWindow ( vio_Width, vio_Height ) )
|
||||
{
|
||||
free ( pbmi );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1; /* success even if the window was not built. */
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap ( char* buffer, int lines, int cols )
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
if ( cols * 8 != pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biBitCount )
|
||||
pbmi->bmiHeader.biWidth = cols * 8 / pbmi->bmiHeader.biBitCount;
|
||||
|
||||
hDC = GetDC ( hwndGraphic );
|
||||
SetDIBits ( hDC, hbm, 0, lines, buffer, pbmi, DIB_RGB_COLORS );
|
||||
ReleaseDC ( hwndGraphic, hDC );
|
||||
|
||||
ShowWindow( hwndGraphic, SW_SHOW );
|
||||
InvalidateRect ( hwndGraphic, NULL, FALSE );
|
||||
UpdateWindow ( hwndGraphic );
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
if ( hwndGraphic )
|
||||
{
|
||||
SetWindowText ( hwndGraphic, Header );
|
||||
}
|
||||
|
||||
do {
|
||||
while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) {
|
||||
TranslateMessage ( &msg );
|
||||
DispatchMessage ( &msg );
|
||||
}
|
||||
if ( ! eventToProcess )
|
||||
WaitMessage();
|
||||
} while ( ! eventToProcess );
|
||||
|
||||
event->what = ourevent.what;
|
||||
event->info = ourevent.info;
|
||||
eventToProcess = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* ---- Windows-specific stuff ------------------------------------------- */
|
||||
|
||||
LRESULT CALLBACK Message_Process( HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
static
|
||||
BOOL RegisterTheClass ( void )
|
||||
{
|
||||
WNDCLASS ourClass = {
|
||||
/* UINT style */ 0,
|
||||
/* WNDPROC lpfnWndProc */ Message_Process,
|
||||
/* int cbClsExtra */ 0,
|
||||
/* int cbWndExtra */ 0,
|
||||
/* HANDLE hInstance */ 0,
|
||||
/* HICON hIcon */ 0,
|
||||
/* HCURSOR hCursor */ 0,
|
||||
/* HBRUSH hbrBackground*/ 0,
|
||||
/* LPCTSTR lpszMenuName */ NULL,
|
||||
/* LPCTSTR lpszClassName*/ "FreeTypeTestGraphicDriver16"
|
||||
};
|
||||
|
||||
if( hPrev )
|
||||
/* There is another instance of the same program. */
|
||||
/* No need to register the class. */
|
||||
return 1;
|
||||
|
||||
ourClass.hInstance = hInst;
|
||||
ourClass.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
ourClass.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
ourClass.hbrBackground= GetStockObject(BLACK_BRUSH);
|
||||
|
||||
return RegisterClass(&ourClass) != 0; /* return False if it fails. */
|
||||
}
|
||||
|
||||
static
|
||||
BOOL CreateTheWindow ( int width, int height )
|
||||
{
|
||||
if ( ! (hwndGraphic = CreateWindow(
|
||||
/* LPCSTR lpszClassName; */ "FreeTypeTestGraphicDriver16",
|
||||
/* LPCSTR lpszWindowName; */ "FreeType Test Graphic Driver",
|
||||
/* DWORD dwStyle; */ WS_OVERLAPPED | WS_SYSMENU,
|
||||
/* int x; */ CW_USEDEFAULT,
|
||||
/* int y; */ CW_USEDEFAULT,
|
||||
/* int nWidth; */ width + 2*GetSystemMetrics(SM_CXBORDER),
|
||||
/* int nHeight; */ height+ GetSystemMetrics(SM_CYBORDER)
|
||||
+ GetSystemMetrics(SM_CYCAPTION),
|
||||
/* HWND hwndParent; */ HWND_DESKTOP,
|
||||
/* HMENU hmenu; */ 0,
|
||||
/* HINSTANCE hinst; */ hInst,
|
||||
/* void FAR* lpvParam; */ NULL))
|
||||
)
|
||||
/* creation failed... */
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Message processing for our Windows class */
|
||||
LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
|
||||
WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
|
||||
switch( mess )
|
||||
{
|
||||
case WM_DESTROY:
|
||||
/* warn the main thread to quit if it didn't know */
|
||||
ourevent.what = event_Quit;
|
||||
ourevent.info = 0;
|
||||
eventToProcess = 1;
|
||||
hwndGraphic = 0;
|
||||
PostQuitMessage ( 0 );
|
||||
DeleteObject ( hbm );
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
hDC = GetDC ( handle );
|
||||
hbm = CreateDIBitmap (
|
||||
/* HDC hdc; handle of device context */ hDC,
|
||||
/* BITMAPINFOHEADER FAR* lpbmih; addr.of header*/ &pbmi->bmiHeader,
|
||||
/* DWORD dwInit; CBM_INIT to initialize bitmap */ 0,
|
||||
/* const void FAR* lpvBits; address of values */ NULL,
|
||||
/* BITMAPINFO FAR* lpbmi; addr.of bitmap data */ pbmi,
|
||||
/* UINT fnColorUse; RGB or palette indices */ DIB_RGB_COLORS);
|
||||
ReleaseDC ( handle, hDC );
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
HDC hDC, memDC;
|
||||
HANDLE oldbm;
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
hDC = BeginPaint ( handle, &ps );
|
||||
memDC = CreateCompatibleDC(hDC);
|
||||
oldbm = SelectObject(memDC, hbm);
|
||||
BitBlt ( hDC, 0, 0, vio_Width, vio_Height, memDC, 0, 0, SRCCOPY);
|
||||
ReleaseDC ( handle, hDC );
|
||||
SelectObject ( memDC, oldbm );
|
||||
DeleteObject ( memDC );
|
||||
EndPaint ( handle, &ps );
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
ourevent.what = event_Quit;
|
||||
ourevent.info = 0;
|
||||
eventToProcess = 1;
|
||||
break;
|
||||
|
||||
case VK_F1: /* bring up help and about dialog window */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
{
|
||||
char c = wParam ;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
ourevent.what = trans[i].event_class;
|
||||
ourevent.info = trans[i].event_info;
|
||||
eventToProcess = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
ourevent.what = event_Keyboard;
|
||||
ourevent.info = (int)c;
|
||||
eventToProcess = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc( handle, mess, wParam, lParam );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* End */
|
||||
30
test/arch/win16/makedep
Normal file
30
test/arch/win16/makedep
Normal file
@@ -0,0 +1,30 @@
|
||||
# makedep
|
||||
#
|
||||
# This shell script creates a dependency file necessary for older compilers
|
||||
# on the Windows 16-bit platform.
|
||||
#
|
||||
# If you run this script under non-Windows operating systems, expect
|
||||
# warnings that `windows.h' can't be found.
|
||||
|
||||
echo "\
|
||||
# This dependency file to be used with various Windows compilers
|
||||
# has been generated automatically with the script \`makedep' on
|
||||
# `date +%d-%b-%Y`.
|
||||
" > depend.win
|
||||
|
||||
(cd ../..
|
||||
gcc -MM -I../lib/arch/win16 -I../lib -I../lib/extend -I. \
|
||||
*.c | \
|
||||
sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.win
|
||||
|
||||
echo "!ifndef __MAKE__" >> depend.win
|
||||
|
||||
(cd ../..
|
||||
gcc -MM -I../lib/arch/win16 -I../lib -I../lib/extend -I. \
|
||||
-DhInst -DhPrev arch/win16/*.c | \
|
||||
sed -e "s/^\(.*\)\.o:/arch\\\\win16\\\\\1.obj:/" \
|
||||
-e "s:/:\\\\:g") >> depend.win
|
||||
|
||||
echo "!endif" >> depend.win
|
||||
|
||||
# eof
|
||||
197
test/arch/win32/Makefile.BC
Normal file
197
test/arch/win32/Makefile.BC
Normal file
@@ -0,0 +1,197 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for BC++ for Win32.
|
||||
#
|
||||
# Tested with Borland C++ v.4.02, 5.0, and Borland C++ builder 4.
|
||||
# You will need Borland MAKE.
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -farch\win32\Makefile.BC
|
||||
#
|
||||
#
|
||||
# A DLL version of the library can be built and then used with
|
||||
#
|
||||
# make -DDLL -farch/win16/Makefile.BC dll
|
||||
#
|
||||
# (do not forget to define DLL, otherwise the link phase will fail).
|
||||
#
|
||||
#
|
||||
# A debug version can be obtained with
|
||||
#
|
||||
# make -DDEBUG -farch\win32\Makefile.BC
|
||||
|
||||
ARCH = arch\win32
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.BC
|
||||
FT_DLL = ft13_32.dll
|
||||
|
||||
CC = bcc32
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR);$(LIBDIR)\$(ARCH);.;$(LIBDIR)\extend
|
||||
SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -w-pia
|
||||
CFLAGS = -i48 $(INCDIRS) $(SPURIOUS_WARNINGS)
|
||||
|
||||
!ifndef DEBUG
|
||||
CFLAGS = $(CFLAGS) -O2 -A
|
||||
LDFLAGS = -WC
|
||||
!else
|
||||
CFLAGS = $(CFLAGS) -v
|
||||
LDFLAGS = -v -WC
|
||||
!endif
|
||||
|
||||
!ifdef DLL
|
||||
CFLAGS = $(CFLAGS) -DFREETYPE_DLL
|
||||
!endif
|
||||
|
||||
# Windows graphic driver
|
||||
GDRIVER = $(ARCH)\gw_win32.c
|
||||
|
||||
DISPLAY = display.c
|
||||
|
||||
G1SRC = gmain.c blitter.c $(GDRIVER)
|
||||
GSRC = $(DISPLAY) $(G1SRC)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
G1OBJ = $(G1SRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
$(CC) -c -o$* @&&|
|
||||
$(CFLAGS) $<
|
||||
|
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!ifndef DEBUG
|
||||
# Skipped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
dll: the_dll $(EXEFILES)
|
||||
|
||||
!else
|
||||
# Skipped if non-DEBUG build
|
||||
default_target: debug
|
||||
dll: the_debug_dll $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDEBUG debug
|
||||
cd ..\test
|
||||
|
||||
the_dll:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDLL dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
the_debug_dll:
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) -DDEBUG -DDLL dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
|
||||
# C compilers are unable to include <windows.h> in ANSI mode,
|
||||
# because of the // comments...
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER:.c=.obj):
|
||||
$(CC) -c -o$* @&&|
|
||||
$(CFLAGS) -A- $*.c
|
||||
|
|
||||
|
||||
|
||||
# Borland versions of make are unable to use the $** variable inside
|
||||
# implicit rules (like .obj.exe:). The job have to be done by hand. :-(
|
||||
ftzoom.exe: $(G1OBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftzoom.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftview.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstring.obj $(GOBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrtto.obj $(GOBJ) common.obj arabic.obj \
|
||||
$(LIBDIR)\libttf.lib
|
||||
|
||||
fttimer.exe: $(G1OBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fttimer.obj $(G1OBJ) common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
$(CC) $(LDFLAGS) fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
make -f$(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
-del *.dll
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
-del *.tds
|
||||
|
||||
!include "$(ARCH)\depend.win"
|
||||
|
||||
# end of Makefile
|
||||
175
test/arch/win32/Makefile.CL
Normal file
175
test/arch/win32/Makefile.CL
Normal file
@@ -0,0 +1,175 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for Microsoft Visual C++.
|
||||
#
|
||||
# You will need NMAKE.
|
||||
#
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# nmake /f arch\win32\Makefile.CL
|
||||
#
|
||||
# A DLL version of the library can be built and then used with
|
||||
#
|
||||
# nmake DLL=1 /f arch\win32\Makefile.CL dll
|
||||
#
|
||||
# (do not forget to define DLL, otherwise the link phase will fail).
|
||||
#
|
||||
#
|
||||
# Debug versions can be obtained with
|
||||
#
|
||||
# nmake DEBUG=1 /f arch\win32\Makefile.CL
|
||||
|
||||
ARCH = arch\win32
|
||||
FT_MAKEFILE = $(ARCH)\Makefile.CL
|
||||
FT_MAKE = $(MAKE) /nologo
|
||||
FT_DLL = ft13_32.dll
|
||||
|
||||
CC = cl /nologo
|
||||
|
||||
LIBDIR = ..\lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)\$(ARCH) -I. -I$(LIBDIR)\extend
|
||||
|
||||
CFLAGS_ANSI = /Za
|
||||
!ifndef DEBUG
|
||||
CFLAGS = /Ox /W2 $(INCDIRS)
|
||||
LDFLAGS =
|
||||
!else
|
||||
CFLAGS = /Zi /Ge /W2 $(INCDIRS)
|
||||
LDFLAGS = /Zi
|
||||
!endif
|
||||
|
||||
!ifdef DLL
|
||||
CFLAGS = $(CFLAGS) /DEXPORT_DEF=__declspec(dllexport) /DFREETYPE_DLL
|
||||
!endif
|
||||
|
||||
|
||||
# Windows graphic driver
|
||||
GDRIVER = $(ARCH)\gw_win32.c
|
||||
|
||||
GSRC = display.c gmain.c blitter.c $(GDRIVER)
|
||||
|
||||
GOBJ = $(GSRC:.c=.obj)
|
||||
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
OBJ = $(SRC:.c=.obj)
|
||||
|
||||
|
||||
.c.obj:
|
||||
@$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) $(CFLAGS_ANSI) $<
|
||||
<<
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
!ifndef DEBUG
|
||||
# Skiped if DEBUG build
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
dll: the_dll $(EXEFILES)
|
||||
|
||||
!else
|
||||
# Skipped if non-DEBUG build
|
||||
default_target: debug
|
||||
dll: the_debug_dll $(EXEFILES)
|
||||
|
||||
!endif
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) all
|
||||
cd ..\test
|
||||
|
||||
freetype_debug:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 debug
|
||||
cd ..\test
|
||||
|
||||
the_dll:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DLL=1 dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
the_debug_dll:
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) DEBUG=1 DLL=1 dll
|
||||
cd ..\test
|
||||
-copy $(LIBDIR)\$(FT_DLL)
|
||||
|
||||
|
||||
# C compilers are unable to include 32-bit <windows.h> in ANSI mode.
|
||||
# So we have a special rule for this file, to build it outside ANSI.
|
||||
$(GDRIVER:.c=.obj):
|
||||
$(CC) /c /Fo$* @<<
|
||||
$(CFLAGS) /Ze $(GDRIVER)
|
||||
<<
|
||||
|
||||
.obj.exe:
|
||||
$(CC) /Fe$* @<<
|
||||
$(LDFLAGS) $** GDI32.LIB USER32.LIB
|
||||
<<
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftview.exe: $(GOBJ) ftview.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstring.exe: $(GOBJ) ftstring.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.obj common.obj arabic.obj $(LIBDIR)\libttf.lib
|
||||
fttimer.exe: $(GOBJ) fttimer.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftlint.exe: ftlint.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftdump.exe: ftdump.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftstrpnm.exe: ftstrpnm.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftsbit.exe: ftsbit.obj common.obj $(LIBDIR)\libttf.lib
|
||||
ftmetric.exe: ftmetric.obj common.obj $(LIBDIR)\libttf.lib
|
||||
fterror.exe: fterror.obj common.obj $(LIBDIR)\libttf.lib
|
||||
|
||||
|
||||
clean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) clean
|
||||
cd ..\test
|
||||
|
||||
distclean: do_clean
|
||||
cd $(LIBDIR)
|
||||
$(FT_MAKE) /f $(FT_MAKEFILE) distclean
|
||||
cd ..\test
|
||||
-del *.exe
|
||||
-del *.dll
|
||||
-del *.pdb
|
||||
|
||||
do_clean:
|
||||
-del *.obj
|
||||
-del $(ARCH)\*.obj
|
||||
-del *.ilk
|
||||
-del *.pch
|
||||
-del *.exp
|
||||
|
||||
|
||||
!include "$(ARCH)\depend.win"
|
||||
|
||||
# end of Makefile.CL
|
||||
122
test/arch/win32/Makefile.Min
Normal file
122
test/arch/win32/Makefile.Min
Normal file
@@ -0,0 +1,122 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for MinGW32 gcc under Win9x.
|
||||
#
|
||||
# You will need a port of GNU make; the MingW32 port works.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -f arch/win32/Makefile.min
|
||||
|
||||
ARCH = arch/win32
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.min
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/$(ARCH) -I. -I$(LIBDIR)/extend
|
||||
|
||||
ifdef DEBUG
|
||||
|
||||
CFLAGS = -ansi -pedantic -Wall -O2 -g $(INCDIRS)
|
||||
LDFLAGS = -g -luser32 -lgdi32
|
||||
|
||||
else
|
||||
|
||||
CFLAGS = -ansi -pedantic -Wall -O2 -s $(INCDIRS)
|
||||
LDFLAGS = -s -luser32 -lgdi32
|
||||
|
||||
endif
|
||||
|
||||
|
||||
# graphic Windows driver
|
||||
GDRIVER = $(ARCH)/gw_win32.c
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c $(GDRIVER)
|
||||
GOBJ = $(GSRC:.c=.o)
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
%.exe:
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
freetype:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all
|
||||
|
||||
freetype_debug:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview.exe: $(GOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
fterror.exe: fterror.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring.exe: $(GOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer.exe: $(GOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean
|
||||
|
||||
distclean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
|
||||
-del dep.end
|
||||
-del *.exe
|
||||
-del core
|
||||
|
||||
do_clean:
|
||||
-del *.o
|
||||
-del response
|
||||
-del $(subst /,\,$(GDRIVER:.c=.o))
|
||||
|
||||
depend: $(SRC) $(GSRC)
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
|
||||
$(CC) -E -M $(INCDIRS) $^ > dep.end
|
||||
|
||||
ifeq (dep.end,$(wildcard dep.end))
|
||||
include dep.end
|
||||
endif
|
||||
|
||||
# end of Makefile.gcc
|
||||
131
test/arch/win32/Makefile.gcc
Normal file
131
test/arch/win32/Makefile.gcc
Normal file
@@ -0,0 +1,131 @@
|
||||
# This file is part of the FreeType project.
|
||||
#
|
||||
# It builds the library and test programs for gcc under Win32.
|
||||
#
|
||||
# You will need GNU make.
|
||||
#
|
||||
# Use this file while in the 'test' directory with the following statement:
|
||||
#
|
||||
# make -f arch/win32/Makefile.gcc
|
||||
#
|
||||
#
|
||||
# If you have the GNU gettext package installed, you can also try
|
||||
#
|
||||
# make -f arch/win32/Makefile.gcc HAVE_GETTEXT
|
||||
|
||||
ARCH = arch/win32
|
||||
FT_MAKEFILE = $(ARCH)/Makefile.gcc
|
||||
|
||||
CC = gcc
|
||||
|
||||
LIBDIR = ../lib
|
||||
INCDIRS = -I$(LIBDIR) -I$(LIBDIR)/$(ARCH) -I. -I$(LIBDIR)/extend
|
||||
|
||||
ifndef GETTEXT
|
||||
GETTEXT=NO_GETTEXT
|
||||
endif
|
||||
|
||||
CFLAGS = -Wall -ansi -O2 -g $(INCDIRS)
|
||||
# -D$(GETTEXT)
|
||||
# CFLAGS = -ansi -Wall -O2 -s $(INCDIRS) -D$(GETTEXT)
|
||||
|
||||
|
||||
# graphic Windows driver
|
||||
GDRIVER = $(ARCH)/gw_win32.c
|
||||
|
||||
SRC = arabic.c \
|
||||
common.c \
|
||||
ftdump.c \
|
||||
fterror.c \
|
||||
ftlint.c \
|
||||
ftmetric.c \
|
||||
ftsbit.c \
|
||||
ftstring.c \
|
||||
ftstrpnm.c \
|
||||
ftstrtto.c \
|
||||
fttimer.c \
|
||||
ftview.c \
|
||||
ftzoom.c
|
||||
|
||||
GSRC = gmain.c display.c blitter.c $(GDRIVER)
|
||||
GOBJ = $(GSRC:.c=.o)
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
ifeq ($(GETTEXT),HAVE_GETTEXT)
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ $^ -lintl
|
||||
else
|
||||
%.exe:
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
endif
|
||||
|
||||
|
||||
EXEFILES = ftdump.exe \
|
||||
fterror.exe \
|
||||
ftlint.exe \
|
||||
ftmetric.exe \
|
||||
ftsbit.exe \
|
||||
ftstring.exe \
|
||||
ftstrpnm.exe \
|
||||
ftstrtto.exe \
|
||||
fttimer.exe \
|
||||
ftview.exe \
|
||||
ftzoom.exe
|
||||
|
||||
.PHONY: all debug freetype freetype_debug \
|
||||
clean distclean do_clean depend
|
||||
|
||||
|
||||
all: freetype $(EXEFILES)
|
||||
|
||||
debug: freetype_debug $(EXEFILES)
|
||||
|
||||
HAVE_GETTEXT:
|
||||
$(MAKE) -f $(FT_MAKEFILE) GETTEXT=HAVE_GETTEXT all
|
||||
|
||||
freetype:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) all
|
||||
|
||||
freetype_debug:
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) debug
|
||||
|
||||
ftzoom.exe: $(GOBJ) ftzoom.o common.o $(LIBDIR)/libttf.a
|
||||
ftview.exe: $(GOBJ) ftview.o common.o $(LIBDIR)/libttf.a
|
||||
ftlint.exe: ftlint.o common.o $(LIBDIR)/libttf.a
|
||||
ftdump.exe: ftdump.o common.o $(LIBDIR)/libttf.a
|
||||
fterror.exe: fterror.o common.o $(LIBDIR)/libttf.a
|
||||
ftstring.exe: $(GOBJ) ftstring.o common.o $(LIBDIR)/libttf.a
|
||||
fttimer.exe: $(GOBJ) fttimer.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrpnm.exe: ftstrpnm.o common.o $(LIBDIR)/libttf.a
|
||||
ftsbit.exe: ftsbit.o common.o $(LIBDIR)/libttf.a
|
||||
ftmetric.exe: ftmetric.o common.o $(LIBDIR)/libttf.a
|
||||
ftstrtto.exe: $(GOBJ) ftstrtto.o common.o arabic.o $(LIBDIR)/libttf.a
|
||||
|
||||
|
||||
clean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) clean
|
||||
|
||||
distclean: do_clean
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) distclean
|
||||
-del dep.end
|
||||
-del *.exe
|
||||
-del core
|
||||
|
||||
do_clean:
|
||||
-del *.o
|
||||
-del response
|
||||
-del $(GDRIVER:.c=.o)
|
||||
|
||||
depend: $(SRC) $(GSRC)
|
||||
$(MAKE) -C $(LIBDIR) -f $(FT_MAKEFILE) depend
|
||||
$(CC) -E -M $(INCDIRS) $^ > dep.end
|
||||
|
||||
ifeq (dep.end,$(wildcard dep.end))
|
||||
include dep.end
|
||||
endif
|
||||
|
||||
# end of Makefile.gcc
|
||||
52
test/arch/win32/depend.win
Normal file
52
test/arch/win32/depend.win
Normal file
@@ -0,0 +1,52 @@
|
||||
# This dependency file to be used with various Windows compilers
|
||||
# has been generated automatically with the script `makedep' on
|
||||
# 03-Sep-1999.
|
||||
|
||||
arabic.obj: arabic.c arabic.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxopen.h ..\lib\extend\ftxgdef.h \
|
||||
..\lib\extend\ftxgsub.h ..\lib\extend\ftxgpos.h
|
||||
blitter.obj: blitter.c blitter.h
|
||||
common.obj: common.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h
|
||||
display.obj: display.c display.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h gmain.h
|
||||
fdebug.obj: fdebug.c ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\tttypes.h ..\lib\ttconfig.h \
|
||||
..\lib\arch\win32\ft_conf.h ..\lib\ttdebug.h ..\lib\ttobjs.h \
|
||||
..\lib\ttengine.h ..\lib\ttmutex.h ..\lib\ttcache.h ..\lib\tttables.h \
|
||||
..\lib\ttcmap.h
|
||||
ftdump.obj: ftdump.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxcmap.h ..\lib\extend\ftxopen.h \
|
||||
..\lib\extend\ftxgdef.h ..\lib\extend\ftxgsub.h \
|
||||
..\lib\extend\ftxgpos.h ..\lib\extend\ftxsbit.h ..\lib\ttobjs.h \
|
||||
..\lib\ttconfig.h ..\lib\arch\win32\ft_conf.h ..\lib\ttengine.h \
|
||||
..\lib\tttypes.h ..\lib\ttmutex.h ..\lib\ttcache.h ..\lib\tttables.h \
|
||||
..\lib\ttcmap.h
|
||||
fterror.obj: fterror.c ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxerr18.h \
|
||||
..\lib\arch\win32\ft_conf.h
|
||||
ftlint.obj: ftlint.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\arch\win32\ft_conf.h
|
||||
ftmetric.obj: ftmetric.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxsbit.h ..\lib\arch\win32\ft_conf.h
|
||||
ftsbit.obj: ftsbit.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxsbit.h ..\lib\arch\win32\ft_conf.h
|
||||
ftstring.obj: ftstring.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h display.h gevents.h gdriver.h gmain.h
|
||||
ftstrpnm.obj: ftstrpnm.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h
|
||||
ftstrtto.obj: ftstrtto.c arabic.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxopen.h ..\lib\extend\ftxgdef.h \
|
||||
..\lib\extend\ftxgsub.h ..\lib\extend\ftxgpos.h blitter.h common.h \
|
||||
display.h ..\lib\extend\ftxkern.h ..\lib\extend\ftxsbit.h gdriver.h \
|
||||
gevents.h gmain.h
|
||||
fttimer.obj: fttimer.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h gdriver.h gevents.h gmain.h
|
||||
ftview.obj: ftview.c blitter.h common.h display.h \
|
||||
..\lib\extend\ftxsbit.h gdriver.h gevents.h gmain.h
|
||||
ftzoom.obj: ftzoom.c common.h ..\lib\freetype.h ..\lib\fterrid.h \
|
||||
..\lib\ftnameid.h ..\lib\extend\ftxpost.h gdriver.h gevents.h gmain.h
|
||||
gmain.obj: gmain.c gdriver.h gmain.h
|
||||
!ifndef __MAKE__
|
||||
arch\win32\gw_win32.obj: arch\win32\gw_win32.c gdriver.h gevents.h gmain.h
|
||||
!endif
|
||||
378
test/arch/win32/gw_win32.c
Normal file
378
test/arch/win32/gw_win32.c
Normal file
@@ -0,0 +1,378 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gw_win32.c graphics driver for Win32 platform. 0.1
|
||||
*
|
||||
* This is the driver for displaying inside a window under Win32,
|
||||
* used by the graphics utility of the FreeType test suite.
|
||||
*
|
||||
* Written by Antoine Leca.
|
||||
* Copyright 1999 by Antoine Leca,
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* Borrowing liberally from the other FreeType drivers.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
|
||||
/* Size of the window. */
|
||||
#define WIN_WIDTH 640u
|
||||
#define WIN_HEIGHT 450u
|
||||
|
||||
/* These values can be changed, but WIN_WIDTH should remain for now a */
|
||||
/* multiple of 32 to avoid padding issues. */
|
||||
|
||||
|
||||
typedef struct _Translator
|
||||
{
|
||||
char key;
|
||||
GEvent event_class;
|
||||
int event_info;
|
||||
} Translator;
|
||||
|
||||
#define NUM_Translators 20
|
||||
|
||||
static const Translator trans[NUM_Translators] =
|
||||
{
|
||||
{ (char)27, event_Quit, 0 },
|
||||
{ 'q', event_Quit, 0 },
|
||||
|
||||
{ 'x', event_Rotate_Glyph, -1 },
|
||||
{ 'c', event_Rotate_Glyph, 1 },
|
||||
{ 'v', event_Rotate_Glyph, -16 },
|
||||
{ 'b', event_Rotate_Glyph, 16 },
|
||||
|
||||
{ '{', event_Change_Glyph, -10000 },
|
||||
{ '}', event_Change_Glyph, 10000 },
|
||||
{ '(', event_Change_Glyph, -1000 },
|
||||
{ ')', event_Change_Glyph, 1000 },
|
||||
{ '9', event_Change_Glyph, -100 },
|
||||
{ '0', event_Change_Glyph, 100 },
|
||||
{ 'i', event_Change_Glyph, -10 },
|
||||
{ 'o', event_Change_Glyph, 10 },
|
||||
{ 'k', event_Change_Glyph, -1 },
|
||||
{ 'l', event_Change_Glyph, 1 },
|
||||
|
||||
{ '+', event_Scale_Glyph, 10 },
|
||||
{ '-', event_Scale_Glyph, -10 },
|
||||
{ 'u', event_Scale_Glyph, 1 },
|
||||
{ 'j', event_Scale_Glyph, -1 }
|
||||
};
|
||||
|
||||
/* handle of the window. */
|
||||
static HWND hwndGraphic;
|
||||
|
||||
/* bitmap information */
|
||||
static LPBITMAPINFO pbmi;
|
||||
static HBITMAP hbm;
|
||||
|
||||
/* local event to pass on */
|
||||
static TEvent ourevent = { event_Quit, 0 };
|
||||
static int eventToProcess = 0;
|
||||
|
||||
/* array defined in the test programs */
|
||||
extern char Header[];
|
||||
|
||||
|
||||
/* restores screen to its original state */
|
||||
|
||||
int Driver_Restore_Mode()
|
||||
{
|
||||
/* The graphical window has perhaps already destroyed itself */
|
||||
if ( hwndGraphic ) {
|
||||
DestroyWindow ( hwndGraphic );
|
||||
PostMessage( hwndGraphic, WM_QUIT, 0, 0 );
|
||||
}
|
||||
|
||||
if ( pbmi ) free ( pbmi );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* set graphics mode
|
||||
* and create the window class and the message handling.
|
||||
*/
|
||||
|
||||
/* Declarations of the Windows-specific functions that are below. */
|
||||
static BOOL RegisterTheClass ( void );
|
||||
static BOOL CreateTheWindow ( int width, int height );
|
||||
|
||||
|
||||
int Driver_Set_Graphics ( int mode )
|
||||
{
|
||||
int i;
|
||||
static RGBQUAD gray_scale[5] = {
|
||||
{ 0xFF, 0xFF, 0xFF, 0 }, /* white */
|
||||
{ 0xC0, 0xC0, 0xC0, 0 },
|
||||
{ 0x80, 0x80, 0x80, 0 },
|
||||
{ 0x40, 0x40, 0x40, 0 },
|
||||
{ 0, 0, 0, 0 } }; /* black */
|
||||
|
||||
if( ! RegisterTheClass() ) return 0; /* if already running, fails. */
|
||||
|
||||
/* find some memory for the bitmap header */
|
||||
if ( (pbmi = malloc ( sizeof ( BITMAPINFO ) + sizeof ( RGBQUAD ) * 256 ) )
|
||||
/* 256 should really be 2 if not grayscale */
|
||||
== NULL )
|
||||
/* lack of memory; fails the process */
|
||||
return 0;
|
||||
|
||||
/* initialize the header to appropriate values */
|
||||
memset( pbmi, 0, sizeof ( BITMAPINFO ) + sizeof ( RGBQUAD ) * 256 );
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono:
|
||||
pbmi->bmiHeader.biBitCount = 1;
|
||||
pbmi->bmiColors[0] = gray_scale[0];
|
||||
pbmi->bmiColors[1] = gray_scale[4];
|
||||
|
||||
vio_ScanLineWidth = WIN_WIDTH / 8;
|
||||
vio_Width = WIN_WIDTH;
|
||||
vio_Height = WIN_HEIGHT;
|
||||
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray:
|
||||
pbmi->bmiHeader.biBitCount = 8;
|
||||
pbmi->bmiHeader.biClrUsed = 5;
|
||||
|
||||
memcpy ( &pbmi->bmiColors[0], gray_scale, sizeof gray_scale );
|
||||
|
||||
vio_ScanLineWidth = WIN_WIDTH;
|
||||
vio_Width = WIN_WIDTH;
|
||||
vio_Height = WIN_HEIGHT;
|
||||
|
||||
for ( i = 0; i < 5; ++i )
|
||||
gray_palette[i] = i;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
free ( pbmi );
|
||||
return 0; /* Unknown mode */
|
||||
}
|
||||
|
||||
pbmi->bmiHeader.biSize = sizeof ( BITMAPINFOHEADER );
|
||||
pbmi->bmiHeader.biWidth = vio_Width;
|
||||
pbmi->bmiHeader.biHeight = vio_Height;
|
||||
pbmi->bmiHeader.biPlanes = 1;
|
||||
|
||||
if( ! CreateTheWindow(vio_Width, vio_Height) )
|
||||
{
|
||||
free ( pbmi );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1; /* success even if the window was not built. */
|
||||
}
|
||||
|
||||
|
||||
int Driver_Display_Bitmap ( char* buffer, int lines, int cols )
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
if ( cols * 8 != pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biBitCount )
|
||||
pbmi->bmiHeader.biWidth = cols * 8 / pbmi->bmiHeader.biBitCount;
|
||||
|
||||
hDC = GetDC ( hwndGraphic );
|
||||
SetDIBits ( hDC, hbm, 0, lines, buffer, pbmi, DIB_RGB_COLORS );
|
||||
ReleaseDC ( hwndGraphic, hDC );
|
||||
|
||||
ShowWindow( hwndGraphic, SW_SHOW );
|
||||
InvalidateRect ( hwndGraphic, NULL, FALSE );
|
||||
UpdateWindow ( hwndGraphic );
|
||||
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
|
||||
void Get_Event( TEvent* event )
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
if ( hwndGraphic )
|
||||
{
|
||||
SetWindowText ( hwndGraphic, Header );
|
||||
}
|
||||
|
||||
do {
|
||||
while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) {
|
||||
TranslateMessage ( &msg );
|
||||
DispatchMessage ( &msg );
|
||||
}
|
||||
if ( ! eventToProcess )
|
||||
WaitMessage();
|
||||
} while ( ! eventToProcess );
|
||||
|
||||
event->what = ourevent.what;
|
||||
event->info = ourevent.info;
|
||||
eventToProcess = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* ---- Windows-specific stuff ------------------------------------------- */
|
||||
|
||||
LRESULT CALLBACK Message_Process( HWND, UINT, WPARAM, LPARAM );
|
||||
|
||||
static
|
||||
BOOL RegisterTheClass ( void )
|
||||
{
|
||||
WNDCLASS ourClass = {
|
||||
/* UINT style */ 0,
|
||||
/* WNDPROC lpfnWndProc */ Message_Process,
|
||||
/* int cbClsExtra */ 0,
|
||||
/* int cbWndExtra */ 0,
|
||||
/* HANDLE hInstance */ 0,
|
||||
/* HICON hIcon */ 0,
|
||||
/* HCURSOR hCursor */ 0,
|
||||
/* HBRUSH hbrBackground*/ 0,
|
||||
/* LPCTSTR lpszMenuName */ NULL,
|
||||
/* LPCTSTR lpszClassName*/ "FreeTypeTestGraphicDriver"
|
||||
};
|
||||
|
||||
ourClass.hInstance = GetModuleHandle( NULL );
|
||||
ourClass.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
ourClass.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
ourClass.hbrBackground= GetStockObject(BLACK_BRUSH);
|
||||
|
||||
return RegisterClass(&ourClass) != 0; /* return False if it fails. */
|
||||
}
|
||||
|
||||
static
|
||||
BOOL CreateTheWindow ( int width, int height )
|
||||
{
|
||||
|
||||
if ( ! (hwndGraphic = CreateWindow(
|
||||
/* LPCSTR lpszClassName; */ "FreeTypeTestGraphicDriver",
|
||||
/* LPCSTR lpszWindowName; */ "FreeType Test Graphic Driver",
|
||||
/* DWORD dwStyle; */ WS_OVERLAPPED | WS_SYSMENU,
|
||||
/* int x; */ CW_USEDEFAULT,
|
||||
/* int y; */ CW_USEDEFAULT,
|
||||
/* int nWidth; */ width + 2*GetSystemMetrics(SM_CXBORDER),
|
||||
/* int nHeight; */ height+ GetSystemMetrics(SM_CYBORDER)
|
||||
+ GetSystemMetrics(SM_CYCAPTION),
|
||||
/* HWND hwndParent; */ HWND_DESKTOP,
|
||||
/* HMENU hmenu; */ 0,
|
||||
/* HINSTANCE hinst; */ GetModuleHandle( NULL ),
|
||||
/* void FAR* lpvParam; */ NULL))
|
||||
)
|
||||
/* creation failed... */
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Message processing for our Windows class */
|
||||
LRESULT CALLBACK Message_Process( HWND handle, UINT mess,
|
||||
WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
|
||||
switch( mess )
|
||||
{
|
||||
case WM_DESTROY:
|
||||
/* warn the main thread to quit if it didn't know */
|
||||
ourevent.what = event_Quit;
|
||||
ourevent.info = 0;
|
||||
eventToProcess = 1;
|
||||
hwndGraphic = 0;
|
||||
PostQuitMessage ( 0 );
|
||||
DeleteObject ( hbm );
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
HDC hDC;
|
||||
|
||||
hDC = GetDC ( handle );
|
||||
hbm = CreateDIBitmap (
|
||||
/* HDC hdc; handle of device context */ hDC,
|
||||
/* BITMAPINFOHEADER FAR* lpbmih; addr.of header*/ &pbmi->bmiHeader,
|
||||
/* DWORD dwInit; CBM_INIT to initialize bitmap */ 0,
|
||||
/* const void FAR* lpvBits; address of values */ NULL,
|
||||
/* BITMAPINFO FAR* lpbmi; addr.of bitmap data */ pbmi,
|
||||
/* UINT fnColorUse; RGB or palette indices */ DIB_RGB_COLORS);
|
||||
ReleaseDC ( handle, hDC );
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
HDC hDC, memDC;
|
||||
HANDLE oldbm;
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
hDC = BeginPaint ( handle, &ps );
|
||||
memDC = CreateCompatibleDC(hDC);
|
||||
oldbm = SelectObject(memDC, hbm);
|
||||
BitBlt ( hDC, 0, 0, vio_Width, vio_Height, memDC, 0, 0, SRCCOPY);
|
||||
ReleaseDC ( handle, hDC );
|
||||
SelectObject ( memDC, oldbm );
|
||||
DeleteObject ( memDC );
|
||||
EndPaint ( handle, &ps );
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
ourevent.what = event_Quit;
|
||||
ourevent.info = 0;
|
||||
eventToProcess = 1;
|
||||
break;
|
||||
|
||||
case VK_F1: /* bring up help and about dialog window */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CHAR:
|
||||
{
|
||||
char c = wParam ;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < NUM_Translators; i++ )
|
||||
{
|
||||
if ( c == trans[i].key )
|
||||
{
|
||||
ourevent.what = trans[i].event_class;
|
||||
ourevent.info = trans[i].event_info;
|
||||
eventToProcess = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* unrecognized keystroke */
|
||||
ourevent.what = event_Keyboard;
|
||||
ourevent.info = (int)c;
|
||||
eventToProcess = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc( handle, mess, wParam, lParam );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* End */
|
||||
29
test/arch/win32/makedep
Normal file
29
test/arch/win32/makedep
Normal file
@@ -0,0 +1,29 @@
|
||||
# makedep
|
||||
#
|
||||
# This shell script creates a dependency file necessary for some compilers
|
||||
# on the Windows 32-bit platform.
|
||||
#
|
||||
# If you run this script under non-Windows operating systems, expect
|
||||
# warnings that `windows.h' can't be found.
|
||||
|
||||
echo "\
|
||||
# This dependency file to be used with various Windows compilers
|
||||
# has been generated automatically with the script \`makedep' on
|
||||
# `date +%d-%b-%Y`.
|
||||
" > depend.win
|
||||
|
||||
(cd ../..
|
||||
gcc -MM -I../lib/arch/win32 -I../lib -I../lib/extend -I. *.c | \
|
||||
sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.win
|
||||
|
||||
echo "!ifndef __MAKE__" >> depend.win
|
||||
|
||||
(cd ../..
|
||||
gcc -MM -I../lib/arch/win32 -I../lib -I../lib/extend -I. \
|
||||
arch/win32/*.c | \
|
||||
sed -e "s/^\(.*\)\.o:/arch\\\\win32\\\\\1.obj:/" \
|
||||
-e "s:/:\\\\:g") >> depend.win
|
||||
|
||||
echo "!endif" >> depend.win
|
||||
|
||||
# eof
|
||||
492
test/blitter.c
Normal file
492
test/blitter.c
Normal file
@@ -0,0 +1,492 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* blitter.c: Support for blitting of bitmaps with various depth. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include "blitter.h"
|
||||
|
||||
|
||||
typedef struct TBlitter_
|
||||
{
|
||||
int width; /* width in pixels of the written area */
|
||||
int height; /* height in pixels of the written area */
|
||||
|
||||
int xread; /* x position of start point in read area */
|
||||
int yread; /* y position of start point in read area */
|
||||
|
||||
int xwrite; /* x position of start point in write area */
|
||||
int ywrite; /* y position of start point in write area */
|
||||
|
||||
int right_clip; /* amount of right clip */
|
||||
|
||||
char* read; /* top left corner of source map */
|
||||
char* write; /* top left corner of target map */
|
||||
|
||||
int read_line; /* byte increment to go down one row in read area */
|
||||
int write_line; /* byte increment to go down one row in write area */
|
||||
|
||||
TT_Raster_Map source;
|
||||
TT_Raster_Map target;
|
||||
|
||||
int source_depth;
|
||||
int target_depth;
|
||||
|
||||
} TBlitter;
|
||||
|
||||
|
||||
static
|
||||
int compute_clips( TBlitter* blit,
|
||||
int x_offset,
|
||||
int y_offset )
|
||||
{
|
||||
int xmin, ymin, xmax, ymax, width, height, target_width;
|
||||
|
||||
|
||||
/* perform clipping and setup variables */
|
||||
width = blit->source.width;
|
||||
height = blit->source.rows;
|
||||
|
||||
switch ( blit->source_depth )
|
||||
{
|
||||
case 1:
|
||||
width = (width + 7) & -8;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
width = (width + 1) & -2;
|
||||
break;
|
||||
}
|
||||
|
||||
xmin = x_offset;
|
||||
ymin = y_offset;
|
||||
xmax = xmin + width-1;
|
||||
ymax = ymin + height-1;
|
||||
|
||||
/* clip if necessary */
|
||||
if ( width == 0 || height == 0 ||
|
||||
xmax < 0 || xmin >= blit->target.width ||
|
||||
ymax < 0 || ymin >= blit->target.rows )
|
||||
return 1;
|
||||
|
||||
/* set up clipping and cursors */
|
||||
blit->yread = 0;
|
||||
if ( ymin < 0 )
|
||||
{
|
||||
blit->yread -= ymin;
|
||||
height += ymin;
|
||||
blit->ywrite = 0;
|
||||
}
|
||||
else
|
||||
blit->ywrite = ymin;
|
||||
|
||||
if ( ymax >= blit->target.rows )
|
||||
height -= ymax - blit->target.rows + 1;
|
||||
|
||||
blit->xread = 0;
|
||||
if ( xmin < 0 )
|
||||
{
|
||||
blit->xread -= xmin;
|
||||
width += xmin;
|
||||
blit->xwrite = 0;
|
||||
}
|
||||
else
|
||||
blit->xwrite = xmin;
|
||||
|
||||
target_width = blit->target.width;
|
||||
|
||||
switch ( blit->target_depth )
|
||||
{
|
||||
case 1:
|
||||
target_width = (target_width + 7) & -8;
|
||||
break;
|
||||
case 4:
|
||||
target_width = (target_width + 1) & -2;
|
||||
break;
|
||||
}
|
||||
|
||||
blit->right_clip = xmax - target_width + 1;
|
||||
if ( blit->right_clip > 0 )
|
||||
width -= blit->right_clip;
|
||||
else
|
||||
blit->right_clip = 0;
|
||||
|
||||
blit->width = width;
|
||||
blit->height = height;
|
||||
|
||||
/* set read and write to the top-left corner of the the read */
|
||||
/* and write area before clipping. */
|
||||
|
||||
blit->read = (char*)blit->source.bitmap;
|
||||
blit->write = (char*)blit->target.bitmap;
|
||||
|
||||
if ( blit->source.flow == TT_Flow_Up )
|
||||
{
|
||||
blit->read_line = -blit->source.cols;
|
||||
blit->read += (blit->source.rows-1) * blit->source.cols;
|
||||
}
|
||||
else
|
||||
blit->read_line = blit->source.cols;
|
||||
|
||||
if ( blit->target.flow == TT_Flow_Up )
|
||||
{
|
||||
blit->write_line = -blit->target.cols;
|
||||
blit->write += (blit->target.rows-1) * blit->target.cols;
|
||||
}
|
||||
else
|
||||
blit->write_line = blit->target.cols;
|
||||
|
||||
/* now go to the start line. Note that we do not move the */
|
||||
/* x position yet, as this is dependent on the pixel format */
|
||||
blit->read += blit->yread * blit->read_line;
|
||||
blit->write += blit->ywrite * blit->write_line;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* <Function> blit_bitmap_to_bitmap */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
static
|
||||
void blit_bitmap_to_bitmap( TBlitter* blit )
|
||||
{
|
||||
int shift, left_clip, x, y;
|
||||
unsigned char* read;
|
||||
unsigned char* write;
|
||||
|
||||
|
||||
left_clip = ( blit->xread > 0 );
|
||||
shift = ( blit->xwrite - blit->xread ) & 7;
|
||||
|
||||
read = (unsigned char*)blit->read + (blit->xread >> 3);
|
||||
write = (unsigned char*)blit->write + (blit->xwrite >> 3);
|
||||
|
||||
if ( shift == 0 )
|
||||
{
|
||||
y = blit->height;
|
||||
do
|
||||
{
|
||||
unsigned char* _read = read;
|
||||
unsigned char* _write = write;
|
||||
|
||||
|
||||
x = blit->width;
|
||||
|
||||
do
|
||||
{
|
||||
*_write++ |= *_read++;
|
||||
x -= 8;
|
||||
} while ( x > 0 );
|
||||
|
||||
read += blit->read_line;
|
||||
write += blit->write_line;
|
||||
y--;
|
||||
} while ( y > 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int first, last, count;
|
||||
|
||||
|
||||
first = blit->xwrite >> 3;
|
||||
last = (blit->xwrite + blit->width-1) >> 3;
|
||||
|
||||
count = last - first;
|
||||
|
||||
if ( blit->right_clip )
|
||||
count++;
|
||||
|
||||
y = blit->height;
|
||||
|
||||
do
|
||||
{
|
||||
unsigned char* _read = read;
|
||||
unsigned char* _write = write;
|
||||
unsigned char old;
|
||||
int shift2 = (8-shift);
|
||||
|
||||
|
||||
if ( left_clip )
|
||||
old = (*_read++) << shift2;
|
||||
else
|
||||
old = 0;
|
||||
|
||||
x = count;
|
||||
while ( x > 0 )
|
||||
{
|
||||
unsigned char val;
|
||||
|
||||
|
||||
val = *_read++;
|
||||
*_write++ |= ( (val >> shift) | old );
|
||||
old = val << shift2;
|
||||
x--;
|
||||
}
|
||||
|
||||
if ( !blit->right_clip )
|
||||
*_write |= old;
|
||||
|
||||
read += blit->read_line;
|
||||
write += blit->write_line;
|
||||
y--;
|
||||
|
||||
} while ( y > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* <Function> blit_bitmap_to_pixmap8 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
static
|
||||
void blit_bitmap_to_pixmap8( TBlitter* blit,
|
||||
unsigned char color )
|
||||
{
|
||||
int x, y;
|
||||
unsigned int left_mask;
|
||||
unsigned char* read;
|
||||
unsigned char* write;
|
||||
|
||||
|
||||
read = (unsigned char*)blit->read + (blit->xread >> 3);
|
||||
write = (unsigned char*)blit->write + blit->xwrite;
|
||||
|
||||
left_mask = 0x80 >> (blit->xread & 7);
|
||||
|
||||
y = blit->height;
|
||||
do
|
||||
{
|
||||
unsigned char* _read = read;
|
||||
unsigned char* _write = write;
|
||||
unsigned int mask = left_mask;
|
||||
unsigned int val = 0;
|
||||
|
||||
|
||||
x = blit->width;
|
||||
do
|
||||
{
|
||||
if ( mask == 0x80 )
|
||||
val = *_read++;
|
||||
|
||||
if ( val & mask )
|
||||
*_write = (unsigned char)color;
|
||||
|
||||
mask >>= 1;
|
||||
if ( mask == 0 )
|
||||
mask = 0x80;
|
||||
|
||||
_write++;
|
||||
x--;
|
||||
} while ( x > 0 );
|
||||
|
||||
read += blit->read_line;
|
||||
write += blit->write_line;
|
||||
y--;
|
||||
} while ( y > 0 );
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* <Function> blit_bitmap_to_pixmap4 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
static
|
||||
void blit_bitmap_to_pixmap4( TBlitter* blit,
|
||||
unsigned char color )
|
||||
{
|
||||
int x, y, phase;
|
||||
unsigned int left_mask;
|
||||
unsigned char* read;
|
||||
unsigned char* write;
|
||||
|
||||
|
||||
color = color & 15;
|
||||
|
||||
read = (unsigned char*)blit->read + (blit->xread >> 3);
|
||||
write = (unsigned char*)blit->write + (blit->xwrite >> 1);
|
||||
|
||||
/* now begin blit */
|
||||
left_mask = 0x80 >> (blit->xread & 7);
|
||||
phase = blit->xwrite & 1;
|
||||
|
||||
y = blit->height;
|
||||
do
|
||||
{
|
||||
unsigned char* _read = read;
|
||||
unsigned char* _write = write;
|
||||
unsigned int mask = left_mask;
|
||||
int _phase = phase;
|
||||
unsigned int val = 0;
|
||||
|
||||
x = blit->width;
|
||||
do
|
||||
{
|
||||
if ( mask == 0x80 )
|
||||
val = *_read++;
|
||||
|
||||
if ( val & mask )
|
||||
{
|
||||
if ( _phase )
|
||||
*_write = (*_write & 0xF0) | color;
|
||||
else
|
||||
*_write = (*_write & 0x0F) | (color << 4);
|
||||
}
|
||||
|
||||
mask >>= 1;
|
||||
if ( mask == 0 )
|
||||
mask = 0x80;
|
||||
|
||||
_write += _phase;
|
||||
_phase ^= 1;
|
||||
x--;
|
||||
} while ( x > 0 );
|
||||
|
||||
read += blit->read_line;
|
||||
write += blit->write_line;
|
||||
y--;
|
||||
} while ( y > 0 );
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* <Function> blit_bitmap_to_pixmap16 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
static
|
||||
void blit_bitmap_to_pixmap16( TBlitter* blit,
|
||||
unsigned short color )
|
||||
{
|
||||
int x, y;
|
||||
unsigned int left_mask;
|
||||
unsigned char* read;
|
||||
unsigned short* write;
|
||||
|
||||
|
||||
read = (unsigned char*)blit->read + (blit->xread >> 3);
|
||||
write = (unsigned short*)(blit->write + blit->xwrite*2);
|
||||
|
||||
left_mask = 0x80 >> (blit->xread & 7);
|
||||
|
||||
y = blit->height;
|
||||
do
|
||||
{
|
||||
unsigned char* _read = read;
|
||||
unsigned short* _write = write;
|
||||
unsigned int mask = left_mask;
|
||||
unsigned int val = 0;
|
||||
|
||||
x = blit->width;
|
||||
do
|
||||
{
|
||||
if ( mask == 0x80 )
|
||||
val = *_read++;
|
||||
|
||||
if ( val & mask )
|
||||
*_write = color;
|
||||
|
||||
mask >>= 1;
|
||||
if ( mask == 0 )
|
||||
mask = 0x80;
|
||||
|
||||
_write++;
|
||||
x--;
|
||||
} while ( x > 0 );
|
||||
|
||||
read += blit->read_line;
|
||||
write += blit->write_line;
|
||||
y--;
|
||||
} while ( y > 0 );
|
||||
}
|
||||
|
||||
|
||||
/* <Function> */
|
||||
/* Blit_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* blit a source bitmap to a target bitmap or pixmap */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* target :: target bitmap or pixmap */
|
||||
/* source :: source bitmap (depth must be 1) */
|
||||
/* target_depth :: pixel bit depth of target map */
|
||||
/* x_offset :: horizontal offset of source in target */
|
||||
/* y_offset :: vertical offset of source in target */
|
||||
/* color :: color to use when blitting to color pixmap */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* error code. 0 means success */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* an error occurs when the target bit depth isn't supported, or */
|
||||
/* if the source's bit depth isn't 1. */
|
||||
/* */
|
||||
/* the offsets are relative to the top-left corner of the target */
|
||||
/* map. Positive y are downwards. */
|
||||
/* */
|
||||
extern
|
||||
int Blit_Bitmap( TT_Raster_Map* target,
|
||||
TT_Raster_Map* source,
|
||||
int target_depth,
|
||||
int x_offset,
|
||||
int y_offset,
|
||||
int color )
|
||||
{
|
||||
TBlitter blit;
|
||||
|
||||
|
||||
if ( !target || !source )
|
||||
return -1;
|
||||
|
||||
blit.source = *source;
|
||||
blit.target = *target;
|
||||
blit.source_depth = 1;
|
||||
blit.target_depth = target_depth;
|
||||
|
||||
/* set up blitter and compute clipping. Return immediately if needed */
|
||||
if ( compute_clips( &blit, x_offset, y_offset ) )
|
||||
return 0;
|
||||
|
||||
/* now perform the blit */
|
||||
switch ( target_depth )
|
||||
{
|
||||
case 1:
|
||||
blit_bitmap_to_bitmap( &blit );
|
||||
break;
|
||||
|
||||
case 4:
|
||||
blit_bitmap_to_pixmap4( &blit, (unsigned char)color );
|
||||
break;
|
||||
|
||||
case 8:
|
||||
blit_bitmap_to_pixmap8( &blit, (unsigned char)color );
|
||||
break;
|
||||
|
||||
case 16:
|
||||
blit_bitmap_to_pixmap16( &blit, (unsigned short)color );
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
52
test/blitter.h
Normal file
52
test/blitter.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* blitter.h: Support for blitting of bitmaps with various depth. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef BLITTER_H
|
||||
#define BLITTER_H
|
||||
|
||||
#include <freetype.h>
|
||||
|
||||
/* <Function> */
|
||||
/* Blit_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* blit a source bitmap to a target bitmap or pixmap */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* target :: target bitmap or pixmap */
|
||||
/* source :: source bitmap (depth must be 1) */
|
||||
/* target_depth :: pixel bit depth of target map */
|
||||
/* x_offset :: horizontal offset of source in target */
|
||||
/* y_offset :: vertical offset of source in target */
|
||||
/* color :: color to use when blitting to color pixmap */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* error code. 0 means success */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* an error occurs when the target bit depth isn't supported, or */
|
||||
/* if the source's bit depth isn't 1. */
|
||||
/* */
|
||||
/* the offsets are relative to the top-left corner of the target */
|
||||
/* map. Positive y are downwards. */
|
||||
/* */
|
||||
extern
|
||||
int Blit_Bitmap( TT_Raster_Map* target,
|
||||
TT_Raster_Map* source,
|
||||
int target_depth,
|
||||
int x_offset,
|
||||
int y_offset,
|
||||
int color );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* End */
|
||||
310
test/common.c
Normal file
310
test/common.c
Normal file
@@ -0,0 +1,310 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* common.c: Various utility functions. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* This is a cheap replacement for getopt() because that routine is not
|
||||
* available on some platforms and behaves differently on other platforms.
|
||||
* This code was written from scratch without looking at any other
|
||||
* implementation.
|
||||
*
|
||||
* This code is hereby expressly placed in the public domain.
|
||||
* mleisher@crl.nmsu.edu (Mark Leisher)
|
||||
* 10 October 1997
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#ifdef __GNUC__
|
||||
static char rcsid[] __attribute__ ((unused)) = "$Id: common.c,v 1.14 1999/08/13 12:54:34 werner Exp $";
|
||||
#else
|
||||
static char rcsid[] = "$Id: common.c,v 1.14 1999/08/13 12:54:34 werner Exp $";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "freetype.h" /* TT_Raster_Map */
|
||||
|
||||
/*
|
||||
* Externals visible to programs.
|
||||
*/
|
||||
|
||||
int ft_opterr = 1;
|
||||
int ft_optind = 1;
|
||||
char* ft_optarg;
|
||||
|
||||
/*
|
||||
* Internal variables that are used to detect when the global values
|
||||
* need to be reset.
|
||||
*/
|
||||
|
||||
static int cmdac;
|
||||
#ifdef __STDC__
|
||||
static const char* cmdname;
|
||||
static char* const* cmdav;
|
||||
#else
|
||||
static char* cmdname;
|
||||
static char** cmdav;
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
#ifdef __STDC__
|
||||
ft_getopt( int ac, char* const* av, const char* pat )
|
||||
#else
|
||||
ft_getopt( ac, av, pat )
|
||||
int ac;
|
||||
char** av;
|
||||
char* pat;
|
||||
#endif
|
||||
{
|
||||
int opt;
|
||||
#ifdef __STDC__
|
||||
const char* p;
|
||||
const char* pp;
|
||||
#else
|
||||
char* p;
|
||||
char* pp;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* If there is no pattern, indicate the parsing is done.
|
||||
*/
|
||||
if ( pat == 0 || *pat == 0 )
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Always reset the option argument to NULL.
|
||||
*/
|
||||
ft_optarg = 0;
|
||||
|
||||
/*
|
||||
* If the number of arguments or argument list do not match the last
|
||||
* values seen, reset the internal pointers and the globals.
|
||||
*/
|
||||
if ( ac != cmdac || av != cmdav )
|
||||
{
|
||||
ft_optind = 1;
|
||||
cmdac = ac;
|
||||
cmdav = av;
|
||||
|
||||
/*
|
||||
* Determine the command name in case it is needed for warning
|
||||
* messages.
|
||||
*/
|
||||
for ( cmdname = 0, p = av[0]; *p; p++ )
|
||||
{
|
||||
if ( *p == '/' || *p == '\\' )
|
||||
cmdname = p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip the path separator if the name was assigned.
|
||||
*/
|
||||
if ( cmdname )
|
||||
cmdname++;
|
||||
else
|
||||
cmdname = av[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* If the next index is greater than or equal to the number of
|
||||
* arguments, then the command line is done.
|
||||
*/
|
||||
if ( ft_optind >= ac )
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Test the next argument for one of three cases:
|
||||
* 1. The next argument does not have an initial '-'.
|
||||
* 2. The next argument is '-'.
|
||||
* 3. The next argument is '--'.
|
||||
*
|
||||
* In either of these cases, command line processing is done.
|
||||
*/
|
||||
if ( av[ft_optind][0] != '-' ||
|
||||
strcmp( av[ft_optind], "-" ) == 0 ||
|
||||
strcmp( av[ft_optind], "--" ) == 0 )
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Point at the next command line argument and increment the
|
||||
* command line index.
|
||||
*/
|
||||
p = av[ft_optind++];
|
||||
|
||||
/*
|
||||
* Look for the first character of the command line option.
|
||||
*/
|
||||
for ( opt = *(p + 1), pp = pat; *pp && *pp != opt; pp++ )
|
||||
;
|
||||
|
||||
/*
|
||||
* If nothing in the pattern was recognized, then issue a warning
|
||||
* and return a '?'.
|
||||
*/
|
||||
if ( *pp == 0 )
|
||||
{
|
||||
if ( ft_opterr )
|
||||
fprintf( stderr, "%s: illegal option -- %c\n", cmdname, opt );
|
||||
return '?';
|
||||
}
|
||||
|
||||
/*
|
||||
* If the option expects an argument, get it.
|
||||
*/
|
||||
if ( *(pp + 1) == ':' && (ft_optarg = av[ft_optind]) == 0 )
|
||||
{
|
||||
/*
|
||||
* If the option argument is NULL, issue a warning and return a '?'.
|
||||
*/
|
||||
if ( ft_opterr )
|
||||
fprintf( stderr, "%s: option requires an argument -- %c\n",
|
||||
cmdname, opt );
|
||||
opt = '?';
|
||||
}
|
||||
else if ( ft_optarg )
|
||||
/*
|
||||
* Increment the option index past the argument.
|
||||
*/
|
||||
ft_optind++;
|
||||
|
||||
/*
|
||||
* Return the option character.
|
||||
*/
|
||||
return opt;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* ft_basename(): */
|
||||
/* */
|
||||
/* a stupid but useful function... */
|
||||
/* */
|
||||
/* rewritten by DavidT to get rid of GPLed programs in the FreeType engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
char*
|
||||
#ifdef __STDC__
|
||||
ft_basename( const char* name )
|
||||
#else
|
||||
ft_basename( name )
|
||||
char* name;
|
||||
#endif
|
||||
{
|
||||
#ifdef __STDC__
|
||||
const char* base;
|
||||
const char* current;
|
||||
#else
|
||||
char* base;
|
||||
char* current;
|
||||
#endif
|
||||
char c;
|
||||
|
||||
|
||||
base = name;
|
||||
current = name;
|
||||
|
||||
c = *current;
|
||||
|
||||
while ( c )
|
||||
{
|
||||
if ( c == '/' || c == '\\' )
|
||||
base = current + 1;
|
||||
|
||||
current++;
|
||||
c = *current;
|
||||
}
|
||||
|
||||
return (char*)base;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
Panic( const char* fmt, ... )
|
||||
#else
|
||||
Panic( fmt )
|
||||
const char* fmt;
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
va_start( ap, fmt );
|
||||
vprintf( fmt, ap );
|
||||
va_end( ap );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
Show_Single_Glyph( const TT_Raster_Map* map )
|
||||
#else
|
||||
Show_Single_Glyph( map )
|
||||
const TT_Raster_Map* map;
|
||||
#endif
|
||||
{
|
||||
int y;
|
||||
|
||||
unsigned char* line = map->bitmap;
|
||||
|
||||
|
||||
for ( y = 0; y < map->rows; y++, line += map->cols )
|
||||
{
|
||||
unsigned char* ptr = line;
|
||||
int x;
|
||||
unsigned char mask = 0x80;
|
||||
|
||||
|
||||
for ( x = 0; x < map->width; x++ )
|
||||
{
|
||||
printf( "%c", (ptr[0] & mask) ? '*' : '.' );
|
||||
mask >>= 1;
|
||||
if ( mask == 0 )
|
||||
{
|
||||
mask = 0x80;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
separator_line( FILE* out, const int length )
|
||||
#else
|
||||
separator_line( out, length )
|
||||
FILE* out;
|
||||
int length;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for ( i = 0; i < length; i++ )
|
||||
fputc( '-', out );
|
||||
fprintf( out, "\n\n" );
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
82
test/common.h
Normal file
82
test/common.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* common.h: Various utility functions. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "freetype.h" /* TT_Raster_Map */
|
||||
|
||||
/*
|
||||
* This is a cheap replacement for getopt() because that routine is not
|
||||
* available on some platforms and behaves differently on other platforms.
|
||||
*
|
||||
* This code is hereby expressly placed in the public domain.
|
||||
* mleisher@crl.nmsu.edu (Mark Leisher)
|
||||
* 10 October 1997
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int ft_opterr;
|
||||
extern int ft_optind;
|
||||
extern char* ft_optarg;
|
||||
|
||||
extern int ft_getopt(
|
||||
#ifdef __STDC__
|
||||
int argc,
|
||||
char* const* argv,
|
||||
const char* pattern
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
extern char* ft_basename(
|
||||
#ifdef __STDC__
|
||||
const char* name
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
/* print a message and exit */
|
||||
extern void Panic(
|
||||
#ifdef __STDC__
|
||||
const char* fmt, ...
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
extern void Show_Single_Glyph(
|
||||
#ifdef __STDC__
|
||||
const TT_Raster_Map* map
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
extern void separator_line(
|
||||
#ifdef __STDC__
|
||||
FILE* out,
|
||||
const int length
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_H */
|
||||
|
||||
|
||||
/* End */
|
||||
299
test/display.c
Normal file
299
test/display.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* display.c: Display component used by all test programs. */
|
||||
/* */
|
||||
/* This file is used to display glyphs and strings in a target window */
|
||||
/* using the graphics drivers provided by gmain.c, gevents.h, etc. */
|
||||
/* */
|
||||
/* Its role is to be shared and heavely commented to let people understand */
|
||||
/* how we do the job... */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdlib.h> /* malloc() and free() */
|
||||
#include <string.h> /* memset() */
|
||||
|
||||
#include "display.h"
|
||||
#include "freetype.h"
|
||||
#include "gmain.h"
|
||||
|
||||
/* The target bitmap or pixmap -- covering the full display window/screen */
|
||||
TT_Raster_Map Bit;
|
||||
|
||||
/* A smaller intermediate bitmap used to render individual glyphs when */
|
||||
/* font smoothing mode is activated. It is then or-ed to `Bit'. */
|
||||
TT_Raster_Map Small_Bit;
|
||||
|
||||
/* The magic of or-ing gray-levels: */
|
||||
/* */
|
||||
/* When gray-level mode (a.k.a. font-smoothing) is on, `Bit' is an 8-bit */
|
||||
/* pixmap of the size of the display window or screen. */
|
||||
/* */
|
||||
/* The gray-level palette to use for display is system-dependent, and */
|
||||
/* given by the "gray_palette" variable defined in 'gmain.c'. It is */
|
||||
/* set up by the graphics driver, and we cannot assume anything about its */
|
||||
/* values. */
|
||||
/* */
|
||||
/* The function TT_Get_Glyph_Pixmap() can use any palette to render each */
|
||||
/* individual glyph, however we'll later need to "or" the glyph to */
|
||||
/* the display pixmap `Bit' to be able to form strings of text by */
|
||||
/* juxtaposing several glyphs together. */
|
||||
/* */
|
||||
/* If we use the gray_palette directly, we'll encounter trouble doing */
|
||||
/* the "or". Example: */
|
||||
/* */
|
||||
/* Suppose that gray_palette = { 0, 32, 64, 128, 255 } */
|
||||
/* */
|
||||
/* Let's render a glyph with this palette and "or" it to */
|
||||
/* the `Bit' pixmap. If, by chance, we superpose two distinct non-zero */
|
||||
/* colors, we will get strange results, like 32+64 = 96, which isn't in */
|
||||
/* our gray palette! */
|
||||
/* */
|
||||
/* There are two ways to solve this problem: */
|
||||
/* */
|
||||
/* - perform a "slow or" where we check all possible combinations */
|
||||
/* and solve conflicts. */
|
||||
/* */
|
||||
/* - render all pixmaps using a special "virtual" palette that eases */
|
||||
/* the "oring" process, then convert the whole display pixmap to */
|
||||
/* "display" colors at once. */
|
||||
/* */
|
||||
/* We choose the second solution, of course; this means that: */
|
||||
/* */
|
||||
/* - the virtual palette used is simply = { 0, 1, 2, 3, 4 }, defined in */
|
||||
/* the variable "palette" below. The `Bit' and `Small_Bit' pixmaps will */
|
||||
/* always contain pixels within these values, with the exception of */
|
||||
/* post-render display, where `Bit' will be converted to display values */
|
||||
/* by the Convert_To_Display_Palette() function. */
|
||||
/* */
|
||||
/* - as or-ing values between 0 and 4 will give us values between */
|
||||
/* 0 and 7, we use a second palette, called "bounding_palette" */
|
||||
/* to maintain all values within the virtual palette. */
|
||||
/* */
|
||||
/* in effect bounding_palette = { 0, 1, 2, 3, 4, 4, 4, 4 } */
|
||||
/* */
|
||||
/* which means that (3|4) == 7 => 4 after bounding */
|
||||
/* */
|
||||
|
||||
/* the virtual palette */
|
||||
unsigned char virtual_palette[5] = { 0, 1, 2, 3, 4 };
|
||||
|
||||
/* Or-ing the possible palette values gets us from 0 to 7 */
|
||||
/* We must bound check these... */
|
||||
unsigned char bounded_palette[8] = { 0, 1, 2, 3, 4, 4, 4, 4 };
|
||||
|
||||
|
||||
/* Clears the Bit bitmap/pixmap */
|
||||
void Clear_Display( void )
|
||||
{
|
||||
memset( Bit.bitmap, 0, Bit.size );
|
||||
}
|
||||
|
||||
|
||||
/* Clears the Small_Bit pixmap */
|
||||
void Clear_Small( void )
|
||||
{
|
||||
memset( Small_Bit.bitmap, 0, Small_Bit.size );
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the display bitmap named Bit */
|
||||
int Init_Display( int font_smoothing )
|
||||
{
|
||||
Bit.rows = vio_Height; /* the whole window */
|
||||
Bit.width = vio_Width;
|
||||
Bit.flow = TT_Flow_Up;
|
||||
|
||||
if ( font_smoothing )
|
||||
Bit.cols = (Bit.width+3) & -4; /* must be 32-bits aligned */
|
||||
else
|
||||
Bit.cols = (Bit.width+7) >> 3;
|
||||
|
||||
Bit.size = (long)Bit.cols * Bit.rows;
|
||||
|
||||
if ( Bit.bitmap )
|
||||
free( Bit.bitmap );
|
||||
Bit.bitmap = malloc( (int)Bit.size );
|
||||
if ( !Bit.bitmap )
|
||||
return -1;
|
||||
|
||||
Clear_Display();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Convert the display pixmap from virtual to display palette */
|
||||
void Convert_To_Display_Palette( void )
|
||||
{
|
||||
unsigned char* p;
|
||||
long i;
|
||||
|
||||
p = Bit.bitmap;
|
||||
for ( i = 0; i < Bit.size; i++ )
|
||||
{
|
||||
*p = gray_palette[(int)*p];
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Init Small Bitmap */
|
||||
int Init_Small( int x_ppem, int y_ppem )
|
||||
{
|
||||
if ( Small_Bit.bitmap )
|
||||
free( Small_Bit.bitmap );
|
||||
|
||||
Small_Bit.rows = y_ppem + 32;
|
||||
Small_Bit.width = x_ppem + 32;
|
||||
Small_Bit.cols = ( Small_Bit.width+3 ) & -4; /* pad to 32-bits */
|
||||
Small_Bit.flow = TT_Flow_Up;
|
||||
Small_Bit.size = (long)Small_Bit.rows * Small_Bit.cols;
|
||||
|
||||
Small_Bit.bitmap = malloc( (int)Small_Bit.size );
|
||||
if ( Small_Bit.bitmap )
|
||||
return -1;
|
||||
|
||||
Clear_Small();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Render a single glyph into the display bit/pixmap */
|
||||
/* */
|
||||
/* Note that in b/w mode, we simply render the glyph directly into */
|
||||
/* the display map, as the scan-line converter or-es the glyph into */
|
||||
/* the target bitmap. */
|
||||
/* */
|
||||
/* In gray mode, however, the glyph is first rendered indivdually in */
|
||||
/* the Small_Bit map, then 'or-ed' with bounding into the display */
|
||||
/* pixmap. */
|
||||
/* */
|
||||
|
||||
TT_Error Render_Single_Glyph( int font_smoothing,
|
||||
TT_Glyph glyph,
|
||||
int x_offset,
|
||||
int y_offset )
|
||||
{
|
||||
if ( !font_smoothing )
|
||||
return TT_Get_Glyph_Bitmap( glyph, &Bit,
|
||||
(long)x_offset*64, (long)y_offset*64 );
|
||||
else
|
||||
{
|
||||
TT_Glyph_Metrics metrics;
|
||||
|
||||
TT_Error error;
|
||||
TT_F26Dot6 x, y, xmin, ymin, xmax, ymax;
|
||||
int ioff, iread;
|
||||
char *off, *read, *_off, *_read;
|
||||
|
||||
|
||||
/* font-smoothing mode */
|
||||
|
||||
/* we begin by grid-fitting the bounding box */
|
||||
TT_Get_Glyph_Metrics( glyph, &metrics );
|
||||
|
||||
xmin = metrics.bbox.xMin & -64;
|
||||
ymin = metrics.bbox.yMin & -64;
|
||||
xmax = (metrics.bbox.xMax+63) & -64;
|
||||
ymax = (metrics.bbox.yMax+63) & -64;
|
||||
|
||||
/* now render the glyph in the small pixmap */
|
||||
|
||||
/* IMPORTANT NOTE: the offset parameters passed to the function */
|
||||
/* TT_Get_Glyph_Bitmap() must be integer pixel values, i.e., */
|
||||
/* multiples of 64. HINTING WILL BE RUINED IF THIS ISN'T THE CASE! */
|
||||
/* This is why we _did_ grid-fit the bounding box, especially xmin */
|
||||
/* and ymin. */
|
||||
|
||||
Clear_Small();
|
||||
error = TT_Get_Glyph_Pixmap( glyph, &Small_Bit, -xmin, -ymin );
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
/* Blit-or the resulting small pixmap into the biggest one */
|
||||
/* We do that by hand, and provide also clipping. */
|
||||
|
||||
xmin = (xmin >> 6) + x_offset;
|
||||
ymin = (ymin >> 6) + y_offset;
|
||||
xmax = (xmax >> 6) + x_offset;
|
||||
ymax = (ymax >> 6) + y_offset;
|
||||
|
||||
/* Take care of comparing xmin and ymin with signed values! */
|
||||
/* This was the cause of strange misplacements when Bit.rows */
|
||||
/* was unsigned. */
|
||||
|
||||
if ( xmin >= (int)Bit.width ||
|
||||
ymin >= (int)Bit.rows ||
|
||||
xmax < 0 ||
|
||||
ymax < 0 )
|
||||
return TT_Err_Ok; /* nothing to do */
|
||||
|
||||
/* Note that the clipping check is performed _after_ rendering */
|
||||
/* the glyph in the small bitmap to let this function return */
|
||||
/* potential error codes for all glyphs, even hidden ones. */
|
||||
|
||||
/* In exotic glyphs, the bounding box may be larger than the */
|
||||
/* size of the small pixmap. Take care of that here. */
|
||||
|
||||
if ( xmax-xmin + 1 > Small_Bit.width )
|
||||
xmax = xmin + Small_Bit.width - 1;
|
||||
|
||||
if ( ymax-ymin + 1 > Small_Bit.rows )
|
||||
ymax = ymin + Small_Bit.rows - 1;
|
||||
|
||||
/* set up clipping and cursors */
|
||||
|
||||
iread = 0;
|
||||
if ( ymin < 0 )
|
||||
{
|
||||
iread -= ymin * Small_Bit.cols;
|
||||
ioff = 0;
|
||||
ymin = 0;
|
||||
}
|
||||
else
|
||||
ioff = ymin * Bit.cols;
|
||||
|
||||
if ( ymax >= Bit.rows )
|
||||
ymax = Bit.rows-1;
|
||||
|
||||
if ( xmin < 0 )
|
||||
{
|
||||
iread -= xmin;
|
||||
xmin = 0;
|
||||
}
|
||||
else
|
||||
ioff += xmin;
|
||||
|
||||
if ( xmax >= Bit.width )
|
||||
xmax = Bit.width - 1;
|
||||
|
||||
_read = (char*)Small_Bit.bitmap + iread;
|
||||
_off = (char*)Bit.bitmap + ioff;
|
||||
|
||||
for ( y = ymin; y <= ymax; y++ )
|
||||
{
|
||||
read = _read;
|
||||
off = _off;
|
||||
|
||||
for ( x = xmin; x <= xmax; x++ )
|
||||
{
|
||||
*off = bounded_palette[*off | *read];
|
||||
off++;
|
||||
read++;
|
||||
}
|
||||
_read += Small_Bit.cols;
|
||||
_off += Bit.cols;
|
||||
}
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End */
|
||||
73
test/display.h
Normal file
73
test/display.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* display.h: Display component interface used by test programs */
|
||||
/* */
|
||||
/* This file is used to display glyphs and strings in a target window */
|
||||
/* using the graphics drivers provided by gmain.c, gevents.h, etc. */
|
||||
/* */
|
||||
/* Its role is to be shared and heavely commented to let people understand */
|
||||
/* how we do the job... */
|
||||
/* */
|
||||
/* See comments in display.c for a full description! */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H
|
||||
|
||||
#include "freetype.h" /* TT_Raster_Map */
|
||||
|
||||
/* The target bitmap or pixmap -- covering the full display window/screen */
|
||||
extern TT_Raster_Map Bit;
|
||||
|
||||
/* A smaller intermediate bitmap used to render individual glyphs when */
|
||||
/* font smoothing mode is activated. It is then or-ed to `Bit'. */
|
||||
extern TT_Raster_Map Small_Bit;
|
||||
|
||||
/* the virtual palette */
|
||||
extern unsigned char virtual_palette[5];
|
||||
|
||||
/* Or-ing the possible palette values gets us from 0 to 7 */
|
||||
/* We must bound check these... */
|
||||
extern unsigned char bounded_palette[8];
|
||||
|
||||
|
||||
/* Clears the Bit bitmap/pixmap */
|
||||
void Clear_Display( void );
|
||||
|
||||
/* Clears the Small_Bit pixmap */
|
||||
void Clear_Small( void );
|
||||
|
||||
/* Initialize the display bitmap named Bit */
|
||||
int Init_Display( int font_smoothing );
|
||||
|
||||
/* Initialize Small Bitmap */
|
||||
int Init_Small( int x_ppem, int y_ppem );
|
||||
|
||||
/* Convert the display pixmap from virtual to display palette */
|
||||
void Convert_To_Display_Palette( void );
|
||||
|
||||
/* Render a single glyph into the display bit/pixmap. */
|
||||
/* */
|
||||
/* Note that in b/w mode, we simply render the glyph directly into */
|
||||
/* the display map, as the scan-line converter or-es the glyph into */
|
||||
/* the target bitmap. */
|
||||
/* */
|
||||
/* In gray mode, however, the glyph is first rendered individually in */
|
||||
/* the Small_Bit map, then 'or-ed' with bounding into the display */
|
||||
/* pixmap. */
|
||||
/* */
|
||||
TT_Error Render_Single_Glyph( int font_smoothing,
|
||||
TT_Glyph glyph,
|
||||
int x_offset,
|
||||
int y_offset );
|
||||
|
||||
#endif /* DISPLAY_H */
|
||||
|
||||
|
||||
/* End */
|
||||
285
test/fdebug.c
Normal file
285
test/fdebug.c
Normal file
@@ -0,0 +1,285 @@
|
||||
/****************************************************************************}
|
||||
{* *}
|
||||
{* The FreeType project - a Free and Portable Quality TrueType Renderer. *}
|
||||
{* *}
|
||||
{* Copyright 1996-1999 by *}
|
||||
{* D. Turner, R.Wilhelm, and W. Lemberg *}
|
||||
{* *}
|
||||
{* fdebug : A very simple TrueType bytecode debugger. *}
|
||||
{* *}
|
||||
{* NOTE : You must compile the interpreter with the DEBUG_INTERPRETER *}
|
||||
{* macro defined in order to link this program! *}
|
||||
{* *}
|
||||
{****************************************************************************/
|
||||
|
||||
#include <math.h> /* libc ANSI */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "freetype.h"
|
||||
#include "tttypes.h"
|
||||
#include "ttdebug.h"
|
||||
#include "ttobjs.h"
|
||||
|
||||
|
||||
#ifdef UNIX
|
||||
#ifndef HAVE_POSIX_TERMIOS
|
||||
#include <sys/ioctl.h>
|
||||
#include <termio.h>
|
||||
#else
|
||||
#ifndef HAVE_TCGETATTR
|
||||
#define HAVE_TCGETATTR
|
||||
#endif /* HAVE_TCGETATTR */
|
||||
#ifndef HAVE_TCSETATTR
|
||||
#define HAVE_TCSETATTR
|
||||
#endif /* HAVE_TCSETATTR */
|
||||
#include <termios.h>
|
||||
#endif /* HAVE_POSIX_TERMIOS */
|
||||
#endif
|
||||
|
||||
/* MAGIC: This variable is only defined in ttinterp.c if the */
|
||||
/* macro DEBUG_INTERPRETER is set. It specifies the code */
|
||||
/* range to debug. By default, it is TT_CodeRange_Glyph. */
|
||||
/* */
|
||||
extern
|
||||
int debug_coderange;
|
||||
|
||||
|
||||
#define Font_Buff_Size 256000 /* this buffer holds all */
|
||||
/* font specific data. */
|
||||
|
||||
TT_Engine engine;
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
TT_Error error;
|
||||
|
||||
TT_Face_Properties properties;
|
||||
|
||||
int num_glyphs;
|
||||
int ptsize;
|
||||
|
||||
Int Fail;
|
||||
Int Num;
|
||||
int mode = 2;
|
||||
unsigned char autorun;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Usage : print usage message
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
static
|
||||
void Usage( const char* execname )
|
||||
{
|
||||
TT_Message( "fdebug: a simple TrueType bytecode debugger - part of the FreeType project\n" );
|
||||
TT_Message( "--------------------------------------------------------------------------\n\n");
|
||||
TT_Message( "Usage: %s glyphnum ppem fontname[.ttf]\n", execname );
|
||||
TT_Message( " or %s --cvt ppem fontname[.ttf]\n", execname );
|
||||
TT_Message( " or %s --font fontname[.ttf]\n\n", execname );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Init_Keyboard : set the input file descriptor to char-by-char
|
||||
* mode on Unix..
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef UNIX
|
||||
|
||||
struct termios old_termio;
|
||||
|
||||
static
|
||||
void Init_Keyboard( void )
|
||||
{
|
||||
struct termios termio;
|
||||
|
||||
|
||||
#ifndef HAVE_TCGETATTR
|
||||
ioctl( 0, TCGETS, &old_termio );
|
||||
#else
|
||||
tcgetattr( 0, &old_termio );
|
||||
#endif
|
||||
|
||||
termio = old_termio;
|
||||
|
||||
termio.c_lflag &= ~(ICANON+ECHO+ECHOE+ECHOK+ECHONL+ECHOKE);
|
||||
|
||||
#ifndef HAVE_TCSETATTR
|
||||
ioctl( 0, TCSETS, &termio );
|
||||
#else
|
||||
tcsetattr( 0, TCSANOW, &termio );
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
void Reset_Keyboard( voi )
|
||||
{
|
||||
#ifndef HAVE_TCSETATTR
|
||||
ioctl( 0, TCSETS, &old_termio );
|
||||
#else
|
||||
tcsetattr( 0, TCSANOW, &old_termio );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static
|
||||
void Init_Keyboard( void )
|
||||
{
|
||||
}
|
||||
|
||||
static
|
||||
void Reset_Keyboard( voi )
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static
|
||||
void Print_Banner( void )
|
||||
{
|
||||
TT_Message( "fdebug - a simple TrueType bytecode debugger for FreeType\n" );
|
||||
TT_Message( "------------------------------------------------------------\n" );
|
||||
TT_Message( "type '?' for help - copyright 1996-1999 the FreeType Project\n\n" );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void Error( const char* message,
|
||||
const char* filename )
|
||||
{
|
||||
static char tempstr[256];
|
||||
|
||||
sprintf( tempstr, "ERROR (%s): %s\n", filename, message );
|
||||
TT_Message( tempstr );
|
||||
|
||||
sprintf( tempstr, " code = 0x%04lx\n", error );
|
||||
TT_Message( tempstr );
|
||||
|
||||
Reset_Keyboard();
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void Init_Face( const char* filename )
|
||||
{
|
||||
error = TT_Init_FreeType(&engine);
|
||||
if (error) Error( "could not initialise FreeType", filename );
|
||||
|
||||
/* open face object */
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
if (error) Error( "could not find or open file", filename );
|
||||
|
||||
/* get properties */
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
/* create instance */
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if (error) Error( "could not create instance", filename );
|
||||
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if (error) Error( "could not create glyph container", filename );
|
||||
|
||||
TT_Set_Instance_Resolutions( instance, 96, 96 );
|
||||
|
||||
error = TT_Set_Instance_CharSize( instance, ptsize << 6 );
|
||||
if (error) Error( "could not set text size", filename );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
int i;
|
||||
char filename[128+4];
|
||||
char* execname;
|
||||
|
||||
|
||||
execname = argv[0];
|
||||
if ( argc < 2 )
|
||||
Usage( execname );
|
||||
|
||||
if ( strcmp( argv[1], "--font" ) == 0 )
|
||||
{
|
||||
debug_coderange = TT_CodeRange_Font;
|
||||
mode = 0;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else if ( strcmp( argv[1], "--cvt" ) == 0 )
|
||||
{
|
||||
debug_coderange = TT_CodeRange_Cvt;
|
||||
argv++;
|
||||
argc--;
|
||||
mode = 1;
|
||||
}
|
||||
else if ( sscanf( argv[1], "%d", &Num ) == 1 )
|
||||
{
|
||||
mode = 2;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
else
|
||||
Usage( execname );
|
||||
|
||||
/* read the point size for cvt and glyph modes */
|
||||
if (mode > 0)
|
||||
{
|
||||
if ( sscanf( argv[1], "%d", &ptsize ) != 1 )
|
||||
Usage( execname );
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ( argc != 2 )
|
||||
Usage(execname);
|
||||
|
||||
i = strlen( argv[1] );
|
||||
while ( i > 0 && argv[1][i] != '\\' )
|
||||
{
|
||||
if ( argv[1][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = 0;
|
||||
|
||||
strncpy( filename, argv[1], 128 );
|
||||
if ( i >= 0 )
|
||||
strncpy( filename + strlen(filename), ".ttf", 4 );
|
||||
|
||||
Init_Keyboard();
|
||||
|
||||
if (mode == 2)
|
||||
{
|
||||
Init_Face( filename );
|
||||
Print_Banner();
|
||||
|
||||
error = TT_Load_Glyph( instance, glyph, Num, TTLOAD_DEFAULT );
|
||||
if (error) Error( "Error during bytecode execution", filename );
|
||||
}
|
||||
else
|
||||
{
|
||||
Print_Banner();
|
||||
Init_Face( filename );
|
||||
}
|
||||
|
||||
TT_Done_FreeType(engine);
|
||||
|
||||
Reset_Keyboard();
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
928
test/ftdump.c
Normal file
928
test/ftdump.c
Normal file
@@ -0,0 +1,928 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftdump: Simple TrueType font file resource profiler. */
|
||||
/* */
|
||||
/* This program dumps various properties of a given font file. */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h" /* for Panic() etc. */
|
||||
#include "freetype.h"
|
||||
#include "ftxcmap.h"
|
||||
#include "ftxopen.h" /* TrueType Open support */
|
||||
#include "ftxsbit.h" /* embedded bitmap support */
|
||||
|
||||
/*
|
||||
* The following comment should be ignored. The "ttobjs.h" file does
|
||||
* already include ft_conf.h.
|
||||
*
|
||||
* ------------------------------------------------------------------
|
||||
*
|
||||
* IGNORE> Basically, an external program using FreeType shouldn't depend on an
|
||||
* IGNORE> internal file of the FreeType library, especially not on ft_conf.h -- but
|
||||
* IGNORE> to avoid another configure script which tests for the existence of the
|
||||
* IGNORE> i18n stuff we include ft_conf.h here since we can be sure that our test
|
||||
* IGNORE> programs use the same configuration options as the library itself.
|
||||
*/
|
||||
|
||||
#include "ttobjs.h" /* We're going to access internal tables directly */
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include "ftxerr18.h"
|
||||
#include <libintl.h>
|
||||
#else
|
||||
#define gettext( x ) ( x )
|
||||
#endif
|
||||
|
||||
|
||||
TT_Error error;
|
||||
|
||||
TT_Engine engine;
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
|
||||
TT_Instance_Metrics imetrics;
|
||||
TT_Outline outline;
|
||||
TT_Glyph_Metrics metrics;
|
||||
|
||||
TT_Face_Properties properties;
|
||||
|
||||
int num_glyphs;
|
||||
int ptsize;
|
||||
|
||||
int Fail;
|
||||
int Num;
|
||||
|
||||
int flag_memory = 1;
|
||||
int flag_names = 1;
|
||||
int flag_encodings = 1;
|
||||
int flag_cmap = 1;
|
||||
int flag_sbits = 1;
|
||||
int flag_ttopen = 1;
|
||||
|
||||
#ifdef FREETYPE_DLL
|
||||
|
||||
/* If the library is linked as a DLL, TTMemory_Allocated() */
|
||||
/* (which is not exported) cannot be accessed. */
|
||||
/* In this case, some compilers report an error because */
|
||||
/* they try to link against a non-existing symbol. */
|
||||
/* */
|
||||
/* We thus avoid the external reference on these compilers. */
|
||||
|
||||
#define TTMemory_Allocated 0L
|
||||
|
||||
#else
|
||||
extern long TTMemory_Allocated;
|
||||
#endif
|
||||
|
||||
long org_memory, old_memory, cur_memory;
|
||||
|
||||
const char* Apple_Encodings[33] =
|
||||
{
|
||||
"Roman", "Japanese", "Chinese", "Korean", "Arabic", "Hebrew",
|
||||
"Greek", "Russian", "RSymbol", "Devanagari", "Gurmukhi",
|
||||
"Gujarati", "Oriya", "Bengali", "Tamil", "Telugu", "Kannada",
|
||||
"Malayalam", "Sinhalese", "Burmese", "Khmer", "Tai", "Laotian",
|
||||
"Georgian", "Armenian", "Maldivian/Simplif. Chinese", "Tibetan",
|
||||
"Mongolian", "Geez", "Slavic", "Vietnamese", "Sindhi", "Uninterpreted"
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
long initial_overhead;
|
||||
long face_object;
|
||||
long glyph_object;
|
||||
long first_instance;
|
||||
long second_instance;
|
||||
|
||||
} memory_footprint;
|
||||
|
||||
|
||||
/* We ignore error message strings with this function */
|
||||
|
||||
#ifndef HAVE_LIBINTL_H
|
||||
static char*
|
||||
TT_ErrToString18( TT_Error error )
|
||||
{
|
||||
static char temp[32];
|
||||
|
||||
|
||||
sprintf( temp, "0x%04lx", error );
|
||||
return temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
Save_Memory( long* var )
|
||||
{
|
||||
*var = TTMemory_Allocated - old_memory;
|
||||
old_memory += *var;
|
||||
}
|
||||
|
||||
#define FOOTPRINT( field ) Save_Memory( &memory_footprint.##field )
|
||||
|
||||
|
||||
static void
|
||||
Print_Mem( long val, char* string )
|
||||
{
|
||||
printf( "%6ld Bytes (%4ld kByte): %s\n",
|
||||
val,
|
||||
( val + 1023L ) / 1024,
|
||||
string );
|
||||
}
|
||||
|
||||
#define PRINT_MEM( field, string ) \
|
||||
Print_Mem( memory_footprint.##field, string )
|
||||
|
||||
|
||||
/* Print the memory footprint */
|
||||
|
||||
void
|
||||
Print_Memory( void )
|
||||
{
|
||||
/* create glyph */
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create glyph container.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
FOOTPRINT( glyph_object );
|
||||
|
||||
/* create instance */
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create instance.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
FOOTPRINT( first_instance );
|
||||
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create second instance.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
FOOTPRINT( second_instance );
|
||||
|
||||
printf( gettext( "Memory footprint statistics:\n" ) );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
/* NOTE: In our current implementation, the face's execution */
|
||||
/* context object is created lazily with the first */
|
||||
/* instance. However, all later instances share the */
|
||||
/* the same context. */
|
||||
|
||||
PRINT_MEM( face_object, gettext( "face object" ) );
|
||||
PRINT_MEM( glyph_object, gettext( "glyph object" ) );
|
||||
PRINT_MEM( second_instance, gettext( "instance object" ) );
|
||||
|
||||
Print_Mem( memory_footprint.first_instance -
|
||||
memory_footprint.second_instance,
|
||||
gettext( "exec. context object" ) );
|
||||
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
Print_Mem( memory_footprint.face_object +
|
||||
memory_footprint.glyph_object +
|
||||
memory_footprint.first_instance,
|
||||
gettext( "total memory usage" ) );
|
||||
|
||||
printf( "\n" );
|
||||
|
||||
return;
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
Panic( gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
}
|
||||
|
||||
|
||||
static char name_buffer[257];
|
||||
static int name_len = 0;
|
||||
|
||||
|
||||
static char*
|
||||
LookUp_Name( int index )
|
||||
{
|
||||
unsigned short i, n;
|
||||
|
||||
unsigned short platform, encoding, language, id;
|
||||
char* string;
|
||||
unsigned short string_len;
|
||||
|
||||
int j, found;
|
||||
|
||||
|
||||
n = properties.num_Names;
|
||||
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
TT_Get_Name_ID( face, i, &platform, &encoding, &language, &id );
|
||||
TT_Get_Name_String( face, i, &string, &string_len );
|
||||
|
||||
if ( id == index )
|
||||
{
|
||||
|
||||
/* The following code was inspired from Mark Leisher's */
|
||||
/* ttf2bdf package */
|
||||
|
||||
found = 0;
|
||||
|
||||
/* Try to find a Microsoft English name */
|
||||
|
||||
if ( platform == 3 )
|
||||
for ( j = 1; j >= 0; j-- )
|
||||
if ( encoding == j ) /* Microsoft ? */
|
||||
if ( (language & 0x3FF) == 0x009 ) /* English language */
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !found && platform == 0 && language == 0 )
|
||||
found = 1;
|
||||
|
||||
/* Found a Unicode Name. */
|
||||
|
||||
if ( found )
|
||||
{
|
||||
if ( string_len > 512 )
|
||||
string_len = 512;
|
||||
|
||||
name_len = 0;
|
||||
|
||||
for ( i = 1; i < string_len; i += 2 )
|
||||
name_buffer[name_len++] = string[i];
|
||||
|
||||
name_buffer[name_len] = '\0';
|
||||
|
||||
return name_buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Print_Names( void )
|
||||
{
|
||||
printf( gettext( "font name table entries\n" ) );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
if ( LookUp_Name( 4 ) )
|
||||
printf( "%s - ", name_buffer );
|
||||
|
||||
if ( LookUp_Name( 5 ) )
|
||||
printf( "%s\n\n", name_buffer );
|
||||
|
||||
if ( LookUp_Name( 6 ) )
|
||||
printf( gettext( "PostScript name: %s\n\n" ), name_buffer );
|
||||
|
||||
if ( LookUp_Name( 0 ) )
|
||||
printf( "%s\n\n", name_buffer );
|
||||
|
||||
if ( LookUp_Name( 7 ) )
|
||||
printf( name_buffer );
|
||||
|
||||
printf( "\n" );
|
||||
separator_line( stdout, 78 );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Print_Encodings( void )
|
||||
{
|
||||
unsigned short n, i;
|
||||
unsigned short platform, encoding;
|
||||
char* platStr, *encoStr;
|
||||
|
||||
char tempStr[128];
|
||||
|
||||
|
||||
printf( gettext( "character map encodings\n" ) );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
n = properties.num_CharMaps;
|
||||
if ( n == 0 )
|
||||
{
|
||||
printf( gettext(
|
||||
"The file doesn't seem to have any encoding table.\n" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
printf( gettext( "There are %hu encodings:\n\n" ), n );
|
||||
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
TT_Get_CharMap_ID( face, i, &platform, &encoding );
|
||||
printf( gettext( "encoding %2u: " ), i );
|
||||
|
||||
platStr = encoStr = NULL;
|
||||
|
||||
switch ( platform )
|
||||
{
|
||||
case TT_PLATFORM_APPLE_UNICODE:
|
||||
platStr = "Apple Unicode";
|
||||
switch ( encoding )
|
||||
{
|
||||
case TT_APPLE_ID_DEFAULT:
|
||||
encoStr = "";
|
||||
break;
|
||||
|
||||
case TT_APPLE_ID_UNICODE_1_1:
|
||||
encoStr = "(v.1.1)";
|
||||
break;
|
||||
|
||||
case TT_APPLE_ID_ISO_10646:
|
||||
encoStr = "(ISO 10646-1:1993)";
|
||||
break;
|
||||
|
||||
case TT_APPLE_ID_UNICODE_2_0:
|
||||
encoStr = "(v.2.0)";
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf( tempStr, gettext( "Unknown value %hu" ), encoding );
|
||||
encoStr = tempStr;
|
||||
}
|
||||
break;
|
||||
|
||||
case TT_PLATFORM_MACINTOSH:
|
||||
platStr = "Apple";
|
||||
if ( encoding > 32 )
|
||||
{
|
||||
sprintf( tempStr, gettext( "Unknown value %hu" ), encoding );
|
||||
encoStr = tempStr;
|
||||
}
|
||||
else
|
||||
encoStr = (char*)Apple_Encodings[encoding];
|
||||
break;
|
||||
|
||||
case TT_PLATFORM_ISO:
|
||||
platStr = "Iso";
|
||||
switch ( encoding )
|
||||
{
|
||||
case TT_ISO_ID_7BIT_ASCII:
|
||||
platStr = "Ascii";
|
||||
encoStr = "7-bit";
|
||||
break;
|
||||
|
||||
case TT_ISO_ID_10646:
|
||||
encoStr = "10646";
|
||||
break;
|
||||
|
||||
case TT_ISO_ID_8859_1:
|
||||
encoStr = "8859-1";
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf( tempStr, "%hu", encoding );
|
||||
encoStr = tempStr;
|
||||
}
|
||||
break;
|
||||
|
||||
case TT_PLATFORM_MICROSOFT:
|
||||
platStr = "Windows";
|
||||
switch ( encoding )
|
||||
{
|
||||
case TT_MS_ID_SYMBOL_CS:
|
||||
encoStr = "Symbol";
|
||||
break;
|
||||
|
||||
case TT_MS_ID_UNICODE_CS:
|
||||
encoStr = "Unicode";
|
||||
break;
|
||||
|
||||
case TT_MS_ID_SJIS:
|
||||
encoStr = "Shift-JIS";
|
||||
break;
|
||||
|
||||
case TT_MS_ID_GB2312:
|
||||
encoStr = "GB2312";
|
||||
break;
|
||||
|
||||
case TT_MS_ID_BIG_5:
|
||||
encoStr = "Big 5";
|
||||
break;
|
||||
|
||||
case TT_MS_ID_WANSUNG:
|
||||
encoStr = "WanSung";
|
||||
break;
|
||||
|
||||
case TT_MS_ID_JOHAB:
|
||||
encoStr = "Johab";
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf( tempStr, gettext( "Unknown value %hu" ), encoding );
|
||||
encoStr = tempStr;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf( tempStr, "%hu - %hu", platform, encoding );
|
||||
platStr = gettext( "Unknown" );
|
||||
encoStr = tempStr;
|
||||
}
|
||||
|
||||
printf( "%s %s\n", platStr, encoStr );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
separator_line( stdout, 78 );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Print_Cmap( void )
|
||||
{
|
||||
TT_CharMap charmap;
|
||||
TT_UShort glyph_index;
|
||||
TT_Long char_index;
|
||||
unsigned short n, i;
|
||||
unsigned short platform, encoding;
|
||||
|
||||
|
||||
printf( gettext( "ftxcmap test\n" ) );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
n = properties.num_CharMaps;
|
||||
if ( n == 0 )
|
||||
{
|
||||
printf( gettext(
|
||||
"The file doesn't seem to have any encoding table.\n" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
printf( gettext( "There are %hu encodings:\n\n" ), n );
|
||||
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
|
||||
TT_Get_CharMap_ID( face, i, &platform, &encoding );
|
||||
printf( gettext( "encoding %2u:\n" ), i );
|
||||
|
||||
TT_Get_CharMap( face, i, &charmap);
|
||||
|
||||
char_index = TT_CharMap_First( charmap, &glyph_index );
|
||||
printf( gettext( "first: glyph index %hu, character code 0x%lx\n" ),
|
||||
glyph_index, char_index );
|
||||
|
||||
char_index = TT_CharMap_Next( charmap, char_index, &glyph_index );
|
||||
printf( gettext( "next: glyph index %hu, character code 0x%lx\n" ),
|
||||
glyph_index, char_index );
|
||||
|
||||
char_index = TT_CharMap_Last( charmap, &glyph_index );
|
||||
printf( gettext( "last: glyph index %hu, character code 0x%lx\n" ),
|
||||
glyph_index, char_index );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
separator_line( stdout, 78 );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Print_SBits( void )
|
||||
{
|
||||
TT_EBLC eblc;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
error = TT_Get_Face_Bitmaps( face, &eblc );
|
||||
if ( error == TT_Err_Table_Missing )
|
||||
return;
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while retrieving embedded bitmaps table.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( "embedded bitmap table\n" ) );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
printf( gettext( " version of embedded bitmap table: 0x%lx\n" ),
|
||||
eblc.version );
|
||||
printf( gettext( " number of embedded bitmap strikes: %lu\n" ),
|
||||
eblc.num_strikes );
|
||||
|
||||
{
|
||||
TT_SBit_Strike* strike = eblc.strikes;
|
||||
int count = 0;
|
||||
|
||||
|
||||
for ( ; count < eblc.num_strikes; count++, strike++ )
|
||||
{
|
||||
printf( gettext( " bitmap strike %hu/%lu: " ),
|
||||
count + 1, eblc.num_strikes );
|
||||
|
||||
printf( gettext( "%hux%hu pixels, %hu-bit depth, glyphs [%hu..%hu]\n" ),
|
||||
strike->x_ppem, strike->y_ppem, strike->bit_depth,
|
||||
strike->start_glyph, strike->end_glyph );
|
||||
{
|
||||
TT_SBit_Range* range = strike->sbit_ranges;
|
||||
TT_SBit_Range* limit = range + strike->num_ranges;
|
||||
|
||||
|
||||
for ( ; range < limit; range++ )
|
||||
printf( gettext( " range format (%hu:%hu) glyphs %hu..%hu\n" ),
|
||||
range->index_format,
|
||||
range->image_format,
|
||||
range->first_glyph,
|
||||
range->last_glyph );
|
||||
}
|
||||
}
|
||||
}
|
||||
printf( "\n" );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
return;
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
Panic( gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
}
|
||||
|
||||
|
||||
#define TAG2STRING( t, s ) s[0] = (char)(t >> 24), \
|
||||
s[1] = (char)(t >> 16), \
|
||||
s[2] = (char)(t >> 8), \
|
||||
s[3] = (char)(t )
|
||||
|
||||
|
||||
static void
|
||||
Print_GSUB( void )
|
||||
{
|
||||
TTO_GSUBHeader gsub;
|
||||
TT_Error error;
|
||||
|
||||
TT_UShort i;
|
||||
TTO_Feature f;
|
||||
TTO_Lookup* lo;
|
||||
|
||||
TT_ULong *script_tag_list, *stl;
|
||||
TT_ULong *language_tag_list, *ltl;
|
||||
TT_ULong *feature_tag_list, *ftl;
|
||||
|
||||
TT_UShort script_index, language_index,
|
||||
feature_index, req_feature_index;
|
||||
|
||||
char script_tag[4], language_tag[4], feature_tag[4];
|
||||
|
||||
|
||||
error = TT_Load_GSUB_Table( face, &gsub, NULL );
|
||||
if ( error == TT_Err_Table_Missing )
|
||||
return;
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while loading GSUB table.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( "GSUB table\n" ) );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
error = TT_GSUB_Query_Scripts( &gsub, &script_tag_list );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while querying GSUB script list.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
stl = script_tag_list;
|
||||
for ( ; *stl; stl++ )
|
||||
{
|
||||
TAG2STRING( *stl, script_tag );
|
||||
|
||||
error = TT_GSUB_Select_Script( &gsub, *stl, &script_index );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while selecting GSUB script `%4.4s'.\n" ),
|
||||
script_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( " script `%4.4s' (index %hu):\n" ),
|
||||
script_tag, script_index );
|
||||
|
||||
error = TT_GSUB_Query_Features( &gsub, script_index, 0xFFFF,
|
||||
&feature_tag_list );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while querying GSUB default language system for script `%4.4s'.\n" ),
|
||||
script_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( " default language system:\n" ) );
|
||||
|
||||
ftl = feature_tag_list;
|
||||
for ( ; *ftl; ftl++ )
|
||||
{
|
||||
TAG2STRING( *ftl, feature_tag );
|
||||
|
||||
error = TT_GSUB_Select_Feature( &gsub, *ftl,
|
||||
script_index, 0xFFFF,
|
||||
&feature_index );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while selecting GSUB feature `%4.4s'\n"
|
||||
"for default language system of script `%4.4s'.\n" ),
|
||||
feature_tag, script_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( " feature `%4.4s' (index %hu; lookup " ),
|
||||
feature_tag, feature_index );
|
||||
|
||||
f = gsub.FeatureList.FeatureRecord[feature_index].Feature;
|
||||
|
||||
for ( i = 0; i < f.LookupListCount - 1; i++ )
|
||||
printf( "%hu, ", f.LookupListIndex[i] );
|
||||
printf( "%hu)\n", f.LookupListIndex[i] );
|
||||
}
|
||||
free( feature_tag_list );
|
||||
|
||||
error = TT_GSUB_Query_Languages( &gsub, script_index,
|
||||
&language_tag_list );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while querying GSUB language list for script `%4.4s'.\n" ),
|
||||
script_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
ltl = language_tag_list;
|
||||
for ( ; *ltl; ltl++ )
|
||||
{
|
||||
TAG2STRING( *ltl, language_tag );
|
||||
|
||||
error = TT_GSUB_Select_Language( &gsub, *ltl,
|
||||
script_index,
|
||||
&language_index,
|
||||
&req_feature_index );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while selecting GSUB language `%4.4s' for script `%4.4s'.\n" ),
|
||||
language_tag, script_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( " language `%4.4s' (index %hu):\n" ),
|
||||
language_tag, language_index );
|
||||
|
||||
if ( req_feature_index != 0xFFFF )
|
||||
{
|
||||
printf( gettext( " required feature index %hu (lookup " ),
|
||||
req_feature_index );
|
||||
|
||||
f = gsub.FeatureList.FeatureRecord[req_feature_index].Feature;
|
||||
|
||||
for ( i = 0; i < f.LookupListCount - 1; i++ )
|
||||
printf( "%hu, ", f.LookupListIndex[i] );
|
||||
printf( "%hu)\n", f.LookupListIndex[i] );
|
||||
}
|
||||
|
||||
error = TT_GSUB_Query_Features( &gsub, script_index, language_index,
|
||||
&feature_tag_list );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while querying GSUB feature list\n"
|
||||
"for script `%4.4s', language `%4.4s'.\n" ),
|
||||
script_tag, language_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
ftl = feature_tag_list;
|
||||
for ( ; *ftl; ftl++ )
|
||||
{
|
||||
TAG2STRING( *ftl, feature_tag );
|
||||
|
||||
error = TT_GSUB_Select_Feature( &gsub, *ftl,
|
||||
script_index, language_index,
|
||||
&feature_index );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while selecting GSUB feature `%4.4s'\n"
|
||||
"for script `%4.4s', language `%4.4s'.\n" ),
|
||||
feature_tag, script_tag, language_tag );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
printf( gettext( " feature `%4.4s' (index %hu; lookup " ),
|
||||
feature_tag, feature_index );
|
||||
|
||||
f = gsub.FeatureList.FeatureRecord[feature_index].Feature;
|
||||
|
||||
for ( i = 0; i < f.LookupListCount - 1; i++ )
|
||||
printf( "%hu, ", f.LookupListIndex[i] );
|
||||
printf( "%hu)\n", f.LookupListIndex[i] );
|
||||
}
|
||||
free( feature_tag_list );
|
||||
}
|
||||
free( language_tag_list );
|
||||
}
|
||||
free( script_tag_list );
|
||||
|
||||
printf( "\n" );
|
||||
|
||||
lo = gsub.LookupList.Lookup;
|
||||
|
||||
printf( gettext( "Lookups:\n\n" ) );
|
||||
|
||||
for ( i = 0; i < gsub.LookupList.LookupCount; i++ )
|
||||
printf( gettext( " %hu: type %hu, flag 0x%x\n" ),
|
||||
i, lo[i].LookupType, lo[i].LookupFlag );
|
||||
|
||||
printf( "\n" );
|
||||
separator_line( stdout, 78 );
|
||||
|
||||
return;
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
Panic( gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char** argv )
|
||||
{
|
||||
int i;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
char* gt;
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain( "freetype", LOCALEDIR );
|
||||
textdomain( "freetype" );
|
||||
#endif
|
||||
|
||||
execname = argv[0];
|
||||
|
||||
if ( argc != 2 )
|
||||
{
|
||||
gt = gettext( "ftdump: Simple TrueType Dumper -- part of the FreeType project" );
|
||||
fprintf( stderr, "%s\n", gt );
|
||||
separator_line( stderr, strlen( gt ) );
|
||||
|
||||
fprintf( stderr, gettext( "Usage: %s fontname[.ttf|.ttc]\n\n" ),
|
||||
execname );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
i = strlen( argv[1] );
|
||||
while ( i > 0 && argv[1][i] != '\\' )
|
||||
{
|
||||
if ( argv[1][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, argv[1], 128 );
|
||||
strncpy( alt_filename, argv[1], 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Initialize engine */
|
||||
|
||||
old_memory = 0;
|
||||
|
||||
if ( (error = TT_Init_FreeType( &engine )) )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while initializing engine.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
if ( (error = TT_Init_SBit_Extension( engine )) )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while initializing embedded bitmap extension.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
if ( (error = TT_Init_GSUB_Extension( engine )) )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while initializing GSUB extension.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
FOOTPRINT( initial_overhead );
|
||||
|
||||
/* Open and Load face */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( gettext( "Could not find or open %s.\n" ), filename );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while opening %s.\n" ), filename );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
FOOTPRINT( face_object );
|
||||
|
||||
/* get face properties and allocate preload arrays */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
/* Now do various dumps */
|
||||
|
||||
if ( flag_names )
|
||||
Print_Names();
|
||||
|
||||
if ( flag_encodings )
|
||||
Print_Encodings();
|
||||
|
||||
if ( flag_cmap )
|
||||
Print_Cmap();
|
||||
|
||||
if ( flag_sbits )
|
||||
Print_SBits();
|
||||
|
||||
if ( flag_ttopen )
|
||||
Print_GSUB();
|
||||
|
||||
#ifndef FREETYPE_DLL /* the statistics are meaningless if we use a DLL. */
|
||||
if ( flag_memory )
|
||||
Print_Memory();
|
||||
#endif
|
||||
|
||||
TT_Close_Face( face );
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
Panic( gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
76
test/fterror.c
Normal file
76
test/fterror.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* E. Dieterich */
|
||||
/* */
|
||||
/* fterror: test errstr functionality. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "freetype.h"
|
||||
#include "ftxerr18.h"
|
||||
|
||||
/*
|
||||
* Basically, an external program using FreeType shouldn't depend on an
|
||||
* internal file of the FreeType library, especially not on ft_conf.h -- but
|
||||
* to avoid another configure script which tests for the existence of the
|
||||
* i18n stuff we include ft_conf.h here since we can be sure that our test
|
||||
* programs use the same configuration options as the library itself.
|
||||
*/
|
||||
|
||||
#include "ft_conf.h"
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <libintl.h>
|
||||
|
||||
#else /* HAVE_LIBINTL_H */
|
||||
|
||||
#define gettext( x ) ( x )
|
||||
|
||||
#endif /* HAVE_LIBINTL_H */
|
||||
|
||||
|
||||
int
|
||||
main( void )
|
||||
{
|
||||
int i;
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
char* domain;
|
||||
|
||||
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain( "freetype", LOCALEDIR );
|
||||
domain = textdomain( "freetype" );
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
printf( "domain: %s\n", domain = textdomain( "" ) );
|
||||
#endif
|
||||
printf( gettext( "Start of fterror.\n" ) );
|
||||
|
||||
for ( i = 0; i < 10; i++ )
|
||||
printf( "Code: %i, %s\n", i, TT_ErrToString18( i ) );
|
||||
|
||||
#if 0
|
||||
printf( "domain: %s\n", domain = textdomain( "" ) );
|
||||
#endif
|
||||
printf( gettext( "End of fterror.\n" ) );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
296
test/ftlint.c
Normal file
296
test/ftlint.c
Normal file
@@ -0,0 +1,296 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftlint: a simple TrueType instruction tester. */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "freetype.h"
|
||||
|
||||
/*
|
||||
* Basically, an external program using FreeType shouldn't depend on an
|
||||
* internal file of the FreeType library, especially not on ft_conf.h -- but
|
||||
* to avoid another configure script which tests for the existence of the
|
||||
* i18n stuff we include ft_conf.h here since we can be sure that our test
|
||||
* programs use the same configuration options as the library itself.
|
||||
*/
|
||||
|
||||
#include "ft_conf.h"
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <libintl.h>
|
||||
#include "ftxerr18.h"
|
||||
|
||||
#else /* !HAVE_LIBINTL */
|
||||
|
||||
#define gettext( x ) ( x )
|
||||
|
||||
/* We ignore error message strings with this function */
|
||||
|
||||
static char*
|
||||
TT_ErrToString18( TT_Error error )
|
||||
{
|
||||
static char temp[32];
|
||||
|
||||
|
||||
sprintf( temp, "0x%04lx", error );
|
||||
return temp;
|
||||
}
|
||||
|
||||
#endif /* !HAVE_LIBINTL */
|
||||
|
||||
|
||||
TT_Error error;
|
||||
|
||||
TT_Engine engine;
|
||||
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
|
||||
TT_Outline outline;
|
||||
TT_Glyph_Metrics metrics;
|
||||
|
||||
TT_Face_Properties properties;
|
||||
|
||||
unsigned int num_glyphs;
|
||||
int ptsize;
|
||||
|
||||
int Fail;
|
||||
int Num;
|
||||
|
||||
|
||||
static TT_Error
|
||||
LoadTrueTypeChar( int idx )
|
||||
{
|
||||
return TT_Load_Glyph( instance, glyph, idx, TTLOAD_DEFAULT );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Usage( char* name )
|
||||
{
|
||||
char* gt;
|
||||
|
||||
|
||||
gt = gettext( "ftlint: Simple TrueType instruction tester -- part of the FreeType project" );
|
||||
fprintf( stderr, "%s\n", gt );
|
||||
separator_line( stderr, strlen( gt ) );
|
||||
|
||||
fprintf( stderr, gettext(
|
||||
"Usage: %s ppem fontname[.ttf|.ttc] [fontname2..]\n\n" ), name );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char** argv )
|
||||
{
|
||||
int i, file_index;
|
||||
unsigned int id;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
char* fname;
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain( "freetype", LOCALEDIR );
|
||||
textdomain( "freetype" );
|
||||
#endif
|
||||
|
||||
execname = argv[0];
|
||||
|
||||
if ( argc < 3 )
|
||||
Usage( execname );
|
||||
|
||||
if ( sscanf( argv[1], "%d", &ptsize ) != 1 )
|
||||
Usage( execname );
|
||||
|
||||
/* Initialize engine */
|
||||
if ( (error = TT_Init_FreeType( &engine )) )
|
||||
{
|
||||
fprintf( stderr,
|
||||
gettext( "Error while initializing engine.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* Now check all files */
|
||||
for ( file_index = 2; file_index < argc; file_index++ )
|
||||
{
|
||||
fname = argv[file_index];
|
||||
i = strlen( fname );
|
||||
while ( i > 0 && fname[i] != '\\' && fname[i] != '/' )
|
||||
{
|
||||
if ( fname[i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, fname, 128 );
|
||||
strncpy( alt_filename, fname, 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Load face */
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
i = strlen( filename );
|
||||
fname = filename;
|
||||
|
||||
while ( i >= 0 )
|
||||
if ( filename[i] == '/' || filename[i] == '\\' )
|
||||
{
|
||||
fname = filename + i + 1;
|
||||
i = -1;
|
||||
}
|
||||
else
|
||||
i--;
|
||||
|
||||
fprintf( stderr, "%s: ", fname );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not find or open %s.\n" ),
|
||||
filename );
|
||||
goto Fail_Face;
|
||||
}
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while opening %s.\n" ), filename );
|
||||
goto Fail_Face;
|
||||
}
|
||||
|
||||
/* get face properties */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
/* create glyph */
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr,
|
||||
gettext( "Could not create glyph container.\n" ) );
|
||||
goto Fail_Glyph;
|
||||
}
|
||||
|
||||
/* create instance */
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create instance.\n" ) );
|
||||
goto Fail_Instance;
|
||||
}
|
||||
|
||||
error = TT_Set_Instance_PixelSizes( instance,
|
||||
ptsize,
|
||||
ptsize,
|
||||
ptsize*3/4 );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr,
|
||||
gettext( "Could not set point size to %d.\n" ),
|
||||
ptsize );
|
||||
goto Fail_Set;
|
||||
}
|
||||
|
||||
Fail = 0;
|
||||
|
||||
for ( id = 0; id < num_glyphs; id++ )
|
||||
{
|
||||
if ( (error = LoadTrueTypeChar( id )) )
|
||||
{
|
||||
if ( Fail < 10 )
|
||||
{
|
||||
fprintf( stderr, !Fail ? gettext( "Error with\n " ) : " " );
|
||||
fprintf( stderr, gettext( "glyph %4u: %s\n" ),
|
||||
id, TT_ErrToString18( error ) );
|
||||
}
|
||||
Fail++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Fail == 0 )
|
||||
fprintf( stderr, "OK.\n" );
|
||||
else
|
||||
{
|
||||
fprintf( stderr, " " );
|
||||
if ( Fail == 1 )
|
||||
fprintf( stderr, gettext( "1 fail.\n" ) );
|
||||
else
|
||||
fprintf( stderr, gettext( "%d fails.\n" ), Fail );
|
||||
}
|
||||
|
||||
/* hush complaints at the end of the loop */
|
||||
error = 0;
|
||||
|
||||
Fail_Set:
|
||||
TT_Done_Instance( instance );
|
||||
Fail_Instance:
|
||||
TT_Done_Glyph( glyph );
|
||||
Fail_Glyph:
|
||||
TT_Close_Face( face );
|
||||
Fail_Face:
|
||||
;
|
||||
|
||||
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, " " );
|
||||
fprintf( stderr, gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
}
|
||||
}
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
fprintf( stderr, gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
396
test/ftmetric.c
Normal file
396
test/ftmetric.c
Normal file
@@ -0,0 +1,396 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1999 by */
|
||||
/* Yamano'uchi H. and W. Lemberg */
|
||||
/* */
|
||||
/* ftmetric: dump metrics and a glyph. */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to debug */
|
||||
/* the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "freetype.h"
|
||||
#include "ftxsbit.h"
|
||||
|
||||
/*
|
||||
* Basically, an external program using FreeType shouldn't depend on an
|
||||
* internal file of the FreeType library, especially not on ft_conf.h -- but
|
||||
* to avoid another configure script which tests for the existence of the
|
||||
* i18n stuff we include ft_conf.h here since we can be sure that our test
|
||||
* programs use the same configuration options as the library itself.
|
||||
*/
|
||||
|
||||
#include "ft_conf.h"
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <libintl.h>
|
||||
#include "ftxerr18.h"
|
||||
|
||||
#else /* !HAVE_LIBINTL */
|
||||
|
||||
#define gettext( x ) ( x )
|
||||
|
||||
/* We ignore error message strings with this function */
|
||||
|
||||
static char*
|
||||
TT_ErrToString18( TT_Error error )
|
||||
{
|
||||
static char temp[32];
|
||||
|
||||
|
||||
sprintf( temp, "0x%04lx", error );
|
||||
return temp;
|
||||
}
|
||||
|
||||
#endif /* !HAVE_LIBINTL */
|
||||
|
||||
static void
|
||||
usage( char* execname )
|
||||
{
|
||||
char* gt;
|
||||
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
gt = gettext( "ftmetric: Simple TTF metrics/glyph dumper -- part of the FreeType project" );
|
||||
fprintf( stderr, "%s\n", gt );
|
||||
separator_line( stderr, strlen( gt ) );
|
||||
fprintf( stderr, gettext(
|
||||
"Usage: %s [options below] point fontname[.ttf|.ttc]\n"
|
||||
"\n"
|
||||
" -B show sbit's metrics (default: none)\n"
|
||||
" -c C use C'th font index of TrueType collection (default: 0)\n"
|
||||
" -i index glyph index (default: 0)\n"
|
||||
" -r R use resolution R dpi (default: 72)\n"
|
||||
"\n" ), execname );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Show_Metrics( TT_Big_Glyph_Metrics metrics,
|
||||
char* title )
|
||||
{
|
||||
int show_advance = 1;
|
||||
|
||||
|
||||
printf("%s: xMin %d, xMax %d, yMin %d, yMax %d",
|
||||
title,
|
||||
(int)(metrics.bbox.xMin / 64),
|
||||
(int)(metrics.bbox.xMax / 64),
|
||||
(int)(metrics.bbox.yMin / 64),
|
||||
(int)(metrics.bbox.yMax / 64));
|
||||
|
||||
|
||||
if ( show_advance )
|
||||
printf( ", advance width %d", (int)(metrics.horiAdvance / 64) );
|
||||
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char** argv )
|
||||
{
|
||||
int i, orig_ptsize, file;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
int option;
|
||||
|
||||
int ptsize;
|
||||
int num_Faces = 0;
|
||||
int glyph_index = 0;
|
||||
int load_flags = TTLOAD_DEFAULT;
|
||||
|
||||
int force_sbit = 0;
|
||||
|
||||
TT_Engine engine;
|
||||
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
|
||||
TT_Raster_Map map;
|
||||
|
||||
TT_Big_Glyph_Metrics metrics;
|
||||
TT_Face_Properties properties;
|
||||
TT_Instance_Metrics imetrics;
|
||||
|
||||
TT_EBLC eblc;
|
||||
TT_SBit_Image* bitmap = NULL;
|
||||
|
||||
TT_Error error;
|
||||
|
||||
|
||||
int res = 72;
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain( "freetype", LOCALEDIR );
|
||||
textdomain( "freetype" );
|
||||
#endif
|
||||
|
||||
execname = ft_basename( argv[0] );
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
option = ft_getopt( argc, argv, "c:r:i:B" );
|
||||
|
||||
if ( option == -1 )
|
||||
break;
|
||||
|
||||
switch ( option )
|
||||
{
|
||||
case 'r':
|
||||
res = atoi( ft_optarg );
|
||||
if ( res < 1 )
|
||||
usage( execname );
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
num_Faces = atoi( ft_optarg );
|
||||
if ( num_Faces < 0 )
|
||||
usage( execname );
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
glyph_index = atoi( ft_optarg );
|
||||
if ( glyph_index < 0 )
|
||||
usage( execname );
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
force_sbit = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage( execname );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= ft_optind;
|
||||
argv += ft_optind;
|
||||
|
||||
if ( argc <= 1 )
|
||||
usage( execname );
|
||||
|
||||
if ( sscanf( argv[0], "%d", &orig_ptsize ) != 1 )
|
||||
orig_ptsize = 64;
|
||||
|
||||
file = 1;
|
||||
|
||||
ptsize = orig_ptsize;
|
||||
|
||||
i = strlen( argv[file] );
|
||||
while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )
|
||||
{
|
||||
if ( argv[file][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, argv[file], 128 );
|
||||
strncpy( alt_filename, argv[file], 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Initialize engine */
|
||||
|
||||
error = TT_Init_FreeType( &engine );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while initializing engine.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
error = TT_Init_SBit_Extension( engine );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while initializing embedded bitmap extension.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* Load face */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( gettext( "Could not find or open %s.\n" ), filename );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while opening %s.\n" ),
|
||||
filename );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
printf( gettext( "There are %d fonts in this collection.\n" ),
|
||||
(int)(properties.num_Faces) );
|
||||
|
||||
if ( num_Faces >= properties.num_Faces )
|
||||
Panic( gettext(
|
||||
"There is no collection with index %d in this font file.\n" ),
|
||||
num_Faces );
|
||||
|
||||
TT_Close_Face( face );
|
||||
|
||||
error = TT_Open_Collection( engine, filename, num_Faces, &face );
|
||||
|
||||
/* get face properties and eblc */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
if ( force_sbit )
|
||||
{
|
||||
error = TT_Get_Face_Bitmaps( face, &eblc );
|
||||
if ( error == TT_Err_Table_Missing )
|
||||
Panic( gettext( "There is no embedded bitmap data in the font.\n" ) );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while retrieving embedded bitmaps table.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
}
|
||||
|
||||
/* create glyph */
|
||||
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create glyph container.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* create instance */
|
||||
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create instance.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
error = TT_Set_Instance_Resolutions( instance, res, res );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not set device resolutions.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
error = TT_Set_Instance_CharSize( instance, ptsize*64 );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not reset instance.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
TT_Get_Instance_Metrics( instance, &imetrics );
|
||||
|
||||
printf( gettext( "Instance metrics: ppemX %d, ppemY %d\n" ),
|
||||
imetrics.x_ppem,
|
||||
imetrics.y_ppem );
|
||||
|
||||
if ( force_sbit )
|
||||
{
|
||||
error = TT_New_SBit_Image( &bitmap );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Could not allocate glyph bitmap container.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
error = TT_Load_Glyph_Bitmap( face, instance, glyph_index, bitmap );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Can't load bitmap for glyph %d.\n" ), glyph_index );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
Show_Metrics( bitmap->metrics, "SBit's metrics" );
|
||||
|
||||
printf( "SBit glyph:\n" );
|
||||
Show_Single_Glyph( &bitmap->map );
|
||||
}
|
||||
else
|
||||
{
|
||||
TT_Load_Glyph( instance, glyph, glyph_index, load_flags );
|
||||
TT_Get_Glyph_Big_Metrics( glyph, &metrics );
|
||||
|
||||
map.width = ( metrics.bbox.xMax - metrics.bbox.xMin ) / 64;
|
||||
map.rows = ( metrics.bbox.yMax - metrics.bbox.yMin ) / 64;
|
||||
map.cols = ( map.width + 7 ) / 8;
|
||||
map.size = map.cols * map.rows;
|
||||
map.bitmap = malloc( map.size );
|
||||
map.flow = TT_Flow_Down;
|
||||
|
||||
memset( map.bitmap, 0, map.size );
|
||||
|
||||
error = TT_Get_Glyph_Bitmap( glyph, &map,
|
||||
-metrics.bbox.xMin,
|
||||
-metrics.bbox.yMin );
|
||||
|
||||
Show_Metrics( metrics, gettext( "Outline's metrics" ) );
|
||||
|
||||
printf( gettext( "Outline glyph\n" ) );
|
||||
Show_Single_Glyph( &map );
|
||||
}
|
||||
|
||||
free( map.bitmap );
|
||||
|
||||
if ( bitmap )
|
||||
TT_Done_SBit_Image( bitmap );
|
||||
|
||||
TT_Done_Instance( instance );
|
||||
TT_Done_Glyph( glyph );
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
fprintf( stderr, gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
293
test/ftsbit.c
Normal file
293
test/ftsbit.c
Normal file
@@ -0,0 +1,293 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftsbit: a _very_ simple embedded bitmap dumper for FreeType 1.x. */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "freetype.h"
|
||||
#include "ftxsbit.h"
|
||||
|
||||
/*
|
||||
* Basically, an external program using FreeType shouldn't depend on an
|
||||
* internal file of the FreeType library, especially not on ft_conf.h -- but
|
||||
* to avoid another configure script which tests for the existence of the
|
||||
* i18n stuff we include ft_conf.h here since we can be sure that our test
|
||||
* programs use the same configuration options as the library itself.
|
||||
*/
|
||||
|
||||
#include "ft_conf.h"
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <libintl.h>
|
||||
#include "ftxerr18.h"
|
||||
|
||||
#else /* !HAVE_LIBINTL */
|
||||
|
||||
#define gettext( x ) ( x )
|
||||
|
||||
/* We ignore error message strings with this function */
|
||||
|
||||
static char* TT_ErrToString18( TT_Error error )
|
||||
{
|
||||
static char temp[32];
|
||||
|
||||
|
||||
sprintf( temp, "0x%04lx", error );
|
||||
return temp;
|
||||
}
|
||||
|
||||
#endif /* !HAVE_LIBINTL */
|
||||
|
||||
|
||||
TT_Error error;
|
||||
|
||||
TT_Engine engine;
|
||||
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
|
||||
TT_Outline outline;
|
||||
TT_Glyph_Metrics metrics;
|
||||
|
||||
TT_Face_Properties properties;
|
||||
TT_EBLC eblc;
|
||||
TT_SBit_Image* bitmap;
|
||||
|
||||
unsigned int num_glyphs;
|
||||
int ptsize;
|
||||
|
||||
int Fail;
|
||||
int Num;
|
||||
|
||||
|
||||
static void Usage( char* name )
|
||||
{
|
||||
char* gt;
|
||||
|
||||
|
||||
gt = gettext( "ftsbit: Simple TrueType `sbit' dumper -- part of the FreeType project" );
|
||||
fprintf( stderr, "%s\n", gt );
|
||||
separator_line( stderr, strlen( gt ) );
|
||||
|
||||
fprintf( stderr, gettext(
|
||||
"Usage: %s ppem fontname[.ttf|.ttc] glyph_index [glyph_index2..]\n\n" ), name );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
int i;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
char* fname;
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
setlocale( LC_ALL, "" );
|
||||
bindtextdomain( "freetype", LOCALEDIR );
|
||||
textdomain( "freetype" );
|
||||
#endif
|
||||
|
||||
execname = argv[0];
|
||||
|
||||
if ( argc < 3 )
|
||||
Usage( execname );
|
||||
|
||||
if ( sscanf( argv[1], "%d", &ptsize ) != 1 )
|
||||
Usage( execname );
|
||||
|
||||
/* Initialize engine */
|
||||
if ( (error = TT_Init_FreeType( &engine )) )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while initializing engine.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
if ( (error = TT_Init_SBit_Extension( engine )) )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while initializing embedded bitmap extension.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* Now check all files */
|
||||
fname = argv[2];
|
||||
i = strlen( fname );
|
||||
while ( i > 0 && fname[i] != '\\' && fname[i] != '/' )
|
||||
{
|
||||
if ( fname[i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, fname, 128 );
|
||||
strncpy( alt_filename, fname, 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Load face */
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
i = strlen( filename );
|
||||
fname = filename;
|
||||
|
||||
while ( i >= 0 )
|
||||
if ( filename[i] == '/' || filename[i] == '\\' )
|
||||
{
|
||||
fname = filename + i + 1;
|
||||
i = -1;
|
||||
}
|
||||
else
|
||||
i--;
|
||||
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not find or open %s.\n" ),
|
||||
filename );
|
||||
goto Failure;
|
||||
}
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Error while opening %s.\n" ), filename );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* get face properties */
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
error = TT_Get_Face_Bitmaps( face, &eblc );
|
||||
if ( error == TT_Err_Table_Missing )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Could not find embedded bitmaps in this font.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Error while loading embedded bitmaps.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* create instance */
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext( "Could not create instance.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
error = TT_Set_Instance_PixelSizes( instance,
|
||||
ptsize,
|
||||
ptsize,
|
||||
ptsize*3/4 );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr,
|
||||
gettext( "Could not set point size to %d.\n" ),
|
||||
ptsize );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
error = TT_New_SBit_Image( &bitmap );
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Could not allocate glyph bitmap container.\n" ) );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
for ( i = 3; i < argc; i++ )
|
||||
{
|
||||
unsigned short glyph_index;
|
||||
|
||||
|
||||
/* we use %i to allow the prefixes `0x' and `0' */
|
||||
if ( sscanf( argv[i], "%hi", &glyph_index ) != 1 )
|
||||
Usage( execname );
|
||||
|
||||
error = TT_Load_Glyph_Bitmap( face, instance, glyph_index, bitmap );
|
||||
|
||||
if ( error == TT_Err_Invalid_Glyph_Index )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
" no bitmap for glyph %d.\n" ), glyph_index );
|
||||
continue;
|
||||
}
|
||||
if ( error )
|
||||
{
|
||||
fprintf( stderr, gettext(
|
||||
"Can't load bitmap for glyph %d.\n" ), glyph_index );
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* Dump the resulting bitmap */
|
||||
{
|
||||
printf( gettext( "glyph index %d = %dx%d pixels, " ),
|
||||
glyph_index, bitmap->map.rows, bitmap->map.width );
|
||||
|
||||
printf( gettext( "advance = %ld, minBearing = [%ld,%ld]\n" ),
|
||||
(long)(bitmap->metrics.horiAdvance / 64),
|
||||
(long)(bitmap->metrics.horiBearingX / 64),
|
||||
(long)(bitmap->metrics.horiBearingY / 64));
|
||||
|
||||
Show_Single_Glyph( &bitmap->map );
|
||||
}
|
||||
}
|
||||
|
||||
TT_Done_SBit_Image( bitmap );
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
|
||||
Failure:
|
||||
fprintf( stderr, " " );
|
||||
fprintf( stderr, gettext( "FreeType error message: %s\n" ),
|
||||
TT_ErrToString18( error ) );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
486
test/ftstring.c
Normal file
486
test/ftstring.c
Normal file
@@ -0,0 +1,486 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftstring: Making string text from individual glyph information. */
|
||||
/* */
|
||||
/* Keys: */
|
||||
/* */
|
||||
/* + : fast scale up */
|
||||
/* - : fast scale down */
|
||||
/* u : fine scale down */
|
||||
/* j : fine scale up */
|
||||
/* */
|
||||
/* h : toggle hinting */
|
||||
/* */
|
||||
/* ESC : exit */
|
||||
/* */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h" /* for Panic() and Message() only */
|
||||
#include "display.h"
|
||||
#include "freetype.h"
|
||||
|
||||
#include "gevents.h"
|
||||
#include "gdriver.h"
|
||||
#include "gmain.h"
|
||||
|
||||
#define Pi 3.1415926535
|
||||
|
||||
#define MAXPTSIZE 500 /* dtp */
|
||||
#define Center_X ( Bit.width / 2 ) /* dtp */
|
||||
#define Center_Y ( Bit.rows / 2 ) /* dtp */
|
||||
|
||||
char Header[128];
|
||||
|
||||
TT_Engine engine;
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
TT_CharMap char_map;
|
||||
|
||||
TT_Glyph_Metrics metrics;
|
||||
TT_Outline outline;
|
||||
TT_Face_Properties properties;
|
||||
TT_Instance_Metrics imetrics;
|
||||
|
||||
int num_glyphs;
|
||||
|
||||
int ptsize;
|
||||
int hinted;
|
||||
|
||||
int Rotation;
|
||||
int Fail;
|
||||
int Num;
|
||||
unsigned char autorun;
|
||||
|
||||
int gray_render;
|
||||
|
||||
short glyph_code[128];
|
||||
int num_codes;
|
||||
|
||||
/* Convert an ASCII string to a string of glyph indexes. */
|
||||
/* */
|
||||
/* IMPORTANT NOTE: */
|
||||
/* */
|
||||
/* There is no portable way to convert from any system's char. code */
|
||||
/* to Unicode. This function simply takes a char. string as argument */
|
||||
/* and "interprets" each character as a Unicode char. index with no */
|
||||
/* further check. */
|
||||
/* */
|
||||
/* This mapping is only valid for the ASCII character set (i.e., */
|
||||
/* codes 32 to 127); all other codes (like accentuated characters) */
|
||||
/* will produce more or less random results, depending on the system */
|
||||
/* being run. */
|
||||
|
||||
static void CharToUnicode( char* source )
|
||||
{
|
||||
unsigned short i, n;
|
||||
unsigned short platform, encoding;
|
||||
|
||||
/* First, look for a Unicode charmap */
|
||||
|
||||
n = properties.num_CharMaps;
|
||||
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
TT_Get_CharMap_ID( face, i, &platform, &encoding );
|
||||
if ( (platform == 3 && encoding == 1 ) ||
|
||||
(platform == 0 && encoding == 0 ) )
|
||||
{
|
||||
TT_Get_CharMap( face, i, &char_map );
|
||||
i = n + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( i == n )
|
||||
Panic( "Sorry, but this font doesn't contain any Unicode mapping table\n" );
|
||||
|
||||
for ( n = 0; n < 128 && source[n]; n++ )
|
||||
glyph_code[n] = TT_Char_Index( char_map, (short)source[n] );
|
||||
|
||||
#if 0
|
||||
/* Note, if you have a function, say ToUnicode(), to convert from */
|
||||
/* char codes to Unicode, use the following line instead: */
|
||||
|
||||
glyph_code[n] = TT_Char_Index( char_map, ToUnicode( source[n] ) );
|
||||
#endif
|
||||
|
||||
num_codes = n;
|
||||
}
|
||||
|
||||
|
||||
static TT_Error Reset_Scale( int pointSize )
|
||||
{
|
||||
TT_Error error;
|
||||
|
||||
|
||||
if ( (error = TT_Set_Instance_PointSize( instance, pointSize )) )
|
||||
{
|
||||
RestoreScreen();
|
||||
printf( "error = 0x%x\n", (int)error );
|
||||
Panic( "could not reset instance\n" );
|
||||
}
|
||||
|
||||
TT_Get_Instance_Metrics( instance, &imetrics );
|
||||
|
||||
/* now re-allocate the small bitmap */
|
||||
if ( gray_render )
|
||||
{
|
||||
Init_Small( imetrics.x_ppem, imetrics.y_ppem );
|
||||
Clear_Small();
|
||||
}
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static TT_Error LoadTrueTypeChar( int idx, int hint )
|
||||
{
|
||||
int flags;
|
||||
|
||||
|
||||
flags = TTLOAD_SCALE_GLYPH;
|
||||
if ( hint )
|
||||
flags |= TTLOAD_HINT_GLYPH;
|
||||
|
||||
return TT_Load_Glyph( instance, glyph, idx, flags );
|
||||
}
|
||||
|
||||
|
||||
static TT_Error Render_All( void )
|
||||
{
|
||||
TT_F26Dot6 x, y, z, minx, miny, maxx, maxy;
|
||||
int i;
|
||||
|
||||
TT_Error error;
|
||||
|
||||
|
||||
/* On the first pass, we compute the compound bounding box */
|
||||
|
||||
x = y = 0;
|
||||
|
||||
minx = miny = maxx = maxy = 0;
|
||||
|
||||
for ( i = 0; i < num_codes; i++ )
|
||||
{
|
||||
if ( !(error = LoadTrueTypeChar( glyph_code[i], hinted )) )
|
||||
{
|
||||
TT_Get_Glyph_Metrics( glyph, &metrics );
|
||||
|
||||
z = x + metrics.bbox.xMin;
|
||||
if ( minx > z )
|
||||
minx = z;
|
||||
|
||||
z = x + metrics.bbox.xMax;
|
||||
if ( maxx < z )
|
||||
maxx = z;
|
||||
|
||||
z = y + metrics.bbox.yMin;
|
||||
if ( miny > z )
|
||||
miny = z;
|
||||
|
||||
z = y + metrics.bbox.yMax;
|
||||
if ( maxy < z )
|
||||
maxy = z;
|
||||
|
||||
x += metrics.advance & -64;
|
||||
}
|
||||
else
|
||||
Fail++;
|
||||
}
|
||||
|
||||
/* We now center the bbox inside the target bitmap */
|
||||
|
||||
minx = ( minx & -64 ) >> 6;
|
||||
miny = ( miny & -64 ) >> 6;
|
||||
|
||||
maxx = ( (maxx+63) & -64 ) >> 6;
|
||||
maxy = ( (maxy+63) & -64 ) >> 6;
|
||||
|
||||
maxx -= minx;
|
||||
maxy -= miny;
|
||||
|
||||
minx = (Bit.width - maxx)/2;
|
||||
miny = (Bit.rows + miny)/2;
|
||||
|
||||
maxx += minx;
|
||||
maxy += maxy;
|
||||
|
||||
/* On the second pass, we render each glyph to its centered position. */
|
||||
/* This is slow, because we reload each glyph to render it! */
|
||||
|
||||
x = minx;
|
||||
y = miny;
|
||||
|
||||
for ( i = 0; i < num_codes; i++ )
|
||||
{
|
||||
if ( !(error = LoadTrueTypeChar( glyph_code[i], hinted )) )
|
||||
{
|
||||
TT_Get_Glyph_Metrics( glyph, &metrics );
|
||||
|
||||
Render_Single_Glyph( gray_render, glyph, x, y );
|
||||
|
||||
x += metrics.advance/64;
|
||||
}
|
||||
}
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static int Process_Event( TEvent* event )
|
||||
{
|
||||
switch ( event->what )
|
||||
{
|
||||
case event_Quit: /* ESC or q */
|
||||
return 0;
|
||||
|
||||
case event_Keyboard:
|
||||
if ( event->info == 'h' ) /* Toggle hinting */
|
||||
hinted = !hinted;
|
||||
break;
|
||||
|
||||
case event_Rotate_Glyph:
|
||||
break;
|
||||
|
||||
case event_Scale_Glyph:
|
||||
ptsize += event->info;
|
||||
if ( ptsize < 1 ) ptsize = 1;
|
||||
if ( ptsize > MAXPTSIZE ) ptsize = MAXPTSIZE;
|
||||
break;
|
||||
|
||||
case event_Change_Glyph:
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void usage( char* execname )
|
||||
{
|
||||
printf( "\n" );
|
||||
printf( "ftstring: simple String Test Display -- part of the FreeType project\n" );
|
||||
printf( "--------------------------------------------------------------------\n" );
|
||||
printf( "\n" );
|
||||
printf( "Usage: %s [options below] ppem fontname[.ttf|.ttc] [string]\n",
|
||||
execname );
|
||||
printf( "\n" );
|
||||
printf( " -g gray-level rendering (default: none)\n" );
|
||||
printf( " -r R use resolution R dpi (default: 96)\n" );
|
||||
printf( "\n" );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
int i, old_ptsize, orig_ptsize, file;
|
||||
int XisSetup = 0;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
int option;
|
||||
int res = 96;
|
||||
|
||||
TT_Error error;
|
||||
TEvent event;
|
||||
|
||||
|
||||
execname = argv[0];
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
option = ft_getopt( argc, argv, "gr:" );
|
||||
|
||||
if ( option == -1 )
|
||||
break;
|
||||
|
||||
switch ( option )
|
||||
{
|
||||
case 'g':
|
||||
gray_render = 1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
res = atoi( ft_optarg );
|
||||
if ( res < 1 )
|
||||
usage( execname );
|
||||
break;
|
||||
|
||||
default:
|
||||
usage( execname );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= ft_optind;
|
||||
argv += ft_optind;
|
||||
|
||||
if ( argc <= 1 )
|
||||
usage( execname );
|
||||
|
||||
if ( sscanf( argv[0], "%d", &orig_ptsize ) != 1 )
|
||||
orig_ptsize = 64;
|
||||
|
||||
file = 1;
|
||||
|
||||
/* Initialize engine */
|
||||
|
||||
if ( (error = TT_Init_FreeType( &engine )) )
|
||||
Panic( "Error while initializing engine, code = 0x%x.\n", error );
|
||||
|
||||
ptsize = orig_ptsize;
|
||||
hinted = 1;
|
||||
|
||||
i = strlen( argv[file] );
|
||||
while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )
|
||||
{
|
||||
if ( argv[file][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, argv[file], 128 );
|
||||
strncpy( alt_filename, argv[file], 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Load face */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( "Could not find/open %s.\n", filename );
|
||||
else if (error)
|
||||
Panic( "Error while opening %s, error code = 0x%x.\n",
|
||||
filename, error );
|
||||
|
||||
/* get face properties and allocate preload arrays */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
/* create glyph */
|
||||
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
Panic( "Could not create glyph container.\n" );
|
||||
|
||||
/* create instance */
|
||||
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
Panic( "Could not create instance for %s.\n", filename );
|
||||
|
||||
error = TT_Set_Instance_Resolutions( instance, res, res );
|
||||
if ( error )
|
||||
Panic( "Could not set device resolutions." );
|
||||
|
||||
if ( !XisSetup )
|
||||
{
|
||||
XisSetup = 1;
|
||||
|
||||
if ( gray_render )
|
||||
{
|
||||
if ( !SetGraphScreen( Graphics_Mode_Gray ) )
|
||||
Panic( "Could not set up grayscale graphics mode.\n" );
|
||||
|
||||
TT_Set_Raster_Gray_Palette( engine, virtual_palette );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !SetGraphScreen( Graphics_Mode_Mono ) )
|
||||
Panic( "Could not set up mono graphics mode.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
Init_Display( gray_render );
|
||||
|
||||
Reset_Scale( ptsize );
|
||||
|
||||
old_ptsize = ptsize;
|
||||
|
||||
Fail = 0;
|
||||
Num = 0;
|
||||
|
||||
CharToUnicode( ( argv[2] ? argv[2] :
|
||||
"The quick brown fox jumps over the lazy dog" ) );
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
int key;
|
||||
|
||||
|
||||
Clear_Display();
|
||||
Render_All();
|
||||
if ( gray_render )
|
||||
Convert_To_Display_Palette();
|
||||
|
||||
sprintf( Header, "%s: ptsize: %4d hinting: %s",
|
||||
ft_basename( filename ), ptsize,
|
||||
hinted ? "on" : "off" );
|
||||
|
||||
Display_Bitmap_On_Screen( Bit.bitmap, Bit.rows, Bit.cols );
|
||||
|
||||
#ifndef X11
|
||||
#ifndef OS2
|
||||
Print_XY( 0, 0, Header );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Get_Event( &event );
|
||||
if ( !( key = Process_Event( &event ) ) )
|
||||
goto Fin;
|
||||
|
||||
if ( ptsize != old_ptsize )
|
||||
{
|
||||
if ( Reset_Scale( ptsize ) )
|
||||
Panic( "Could not resize font.\n" );
|
||||
|
||||
old_ptsize = ptsize;
|
||||
}
|
||||
}
|
||||
|
||||
Fin:
|
||||
RestoreScreen();
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
printf( "Execution completed successfully.\n" );
|
||||
printf( "Fails = %d.\n", Fail );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
510
test/ftstrpnm.c
Normal file
510
test/ftstrpnm.c
Normal file
@@ -0,0 +1,510 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftstrpnm: convert text to image (in PGM or PBM format) */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#define PROGNAME "ftstrpnm"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h" /* for ft_getopt() */
|
||||
#include "freetype.h"
|
||||
|
||||
#define TT_VALID( handle ) ( ( handle ).z != NULL )
|
||||
|
||||
|
||||
/* Global variables */
|
||||
|
||||
TT_Engine engine;
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
|
||||
TT_Face_Properties properties;
|
||||
|
||||
TT_Raster_Map bit;
|
||||
TT_Raster_Map small_bit; /* used when font-smoothing is enabled */
|
||||
|
||||
int pnm_width, pnm_height;
|
||||
int pnm_x_shift, pnm_y_shift;
|
||||
|
||||
|
||||
/* Loaded glyphs for all characters */
|
||||
|
||||
TT_Glyph *glyphs = NULL;
|
||||
|
||||
|
||||
/* Options */
|
||||
|
||||
int dpi = 96;
|
||||
int ptsize = 12;
|
||||
int hinted = 1;
|
||||
int smooth = 0;
|
||||
int border = 0;
|
||||
|
||||
|
||||
/* raster map management */
|
||||
|
||||
static void Init_Raster_Map( TT_Raster_Map* bit, int width, int height )
|
||||
{
|
||||
bit->rows = height;
|
||||
bit->width = ( width + 3 ) & -4;
|
||||
bit->flow = TT_Flow_Down;
|
||||
|
||||
if ( smooth )
|
||||
{
|
||||
bit->cols = bit->width;
|
||||
bit->size = bit->rows * bit->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit->cols = ( bit->width + 7 ) / 8; /* convert to # of bytes */
|
||||
bit->size = bit->rows * bit->cols; /* number of bytes in buffer */
|
||||
}
|
||||
|
||||
bit->bitmap = (void *) malloc( bit->size );
|
||||
if ( !bit->bitmap )
|
||||
Panic( "Not enough memory to allocate bitmap!\n" );
|
||||
}
|
||||
|
||||
|
||||
static void Done_Raster_Map( TT_Raster_Map *bit )
|
||||
{
|
||||
free( bit->bitmap );
|
||||
bit->bitmap = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void Clear_Raster_Map( TT_Raster_Map* bit )
|
||||
{
|
||||
memset( bit->bitmap, 0, bit->size );
|
||||
}
|
||||
|
||||
|
||||
static void Blit_Or( TT_Raster_Map* dst, TT_Raster_Map* src,
|
||||
int x_off, int y_off )
|
||||
{
|
||||
int x, y;
|
||||
int x1, x2, y1, y2;
|
||||
char *s, *d;
|
||||
|
||||
|
||||
/* clipping */
|
||||
|
||||
x1 = x_off < 0 ? -x_off : 0;
|
||||
y1 = y_off < 0 ? -y_off : 0;
|
||||
|
||||
x2 = (int)dst->cols - x_off;
|
||||
if ( x2 > src->cols )
|
||||
x2 = src->cols;
|
||||
|
||||
y2 = (int)dst->rows - y_off;
|
||||
if ( y2 > src->rows )
|
||||
y2 = src->rows;
|
||||
|
||||
if ( x1 >= x2 )
|
||||
return;
|
||||
|
||||
/* do the real work now */
|
||||
|
||||
for ( y = y1; y < y2; ++y )
|
||||
{
|
||||
s = ( (char*)src->bitmap ) + y * src->cols + x1;
|
||||
d = ( (char*)dst->bitmap ) + ( y + y_off ) * dst->cols + x1 + x_off;
|
||||
|
||||
for ( x = x1; x < x2; ++x )
|
||||
*d++ |= *s++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Dump_Raster_Map( TT_Raster_Map* bit, FILE* file )
|
||||
{
|
||||
/* kudos for this code snippet go to Norman Walsh */
|
||||
|
||||
char* bmap;
|
||||
int i;
|
||||
|
||||
|
||||
bmap = (char *)bit->bitmap;
|
||||
|
||||
if ( smooth )
|
||||
{
|
||||
fprintf( file, "P5\n%d %d\n4\n", pnm_width, pnm_height );
|
||||
for ( i = bit->size - 1; i >= 0; --i )
|
||||
bmap[i] = bmap[i] > 4 ? 0 : 4 - bmap[i];
|
||||
for ( i = pnm_height; i > 0; --i, bmap += bit->cols )
|
||||
fwrite( bmap, 1, pnm_width, file );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( file, "P4\n%d %d\n", pnm_width, pnm_height );
|
||||
for ( i = pnm_height; i > 0; --i, bmap += bit->cols )
|
||||
fwrite( bmap, 1, (pnm_width+7) / 8, file );
|
||||
}
|
||||
|
||||
fflush( file );
|
||||
}
|
||||
|
||||
|
||||
/* glyph management */
|
||||
|
||||
static void Load_Glyphs( char* txt, int txtlen )
|
||||
{
|
||||
unsigned short i, n, code, load_flags;
|
||||
unsigned short num_glyphs = 0, no_cmap = 0;
|
||||
unsigned short platform, encoding;
|
||||
TT_Error error;
|
||||
TT_CharMap char_map;
|
||||
|
||||
|
||||
/* First, look for a Unicode charmap */
|
||||
|
||||
n = properties.num_CharMaps;
|
||||
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
TT_Get_CharMap_ID( face, i, &platform, &encoding );
|
||||
if ( (platform == 3 && encoding == 1 ) ||
|
||||
(platform == 0 && encoding == 0 ) )
|
||||
{
|
||||
TT_Get_CharMap( face, i, &char_map );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( i == n )
|
||||
{
|
||||
TT_Face_Properties properties;
|
||||
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
no_cmap = 1;
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
}
|
||||
|
||||
|
||||
/* Second, allocate the array */
|
||||
|
||||
glyphs = (TT_Glyph*)malloc( 256 * sizeof ( TT_Glyph ) );
|
||||
memset( glyphs, 0, 256 * sizeof ( TT_Glyph ) );
|
||||
|
||||
/* Finally, load the glyphs you need */
|
||||
|
||||
load_flags = TTLOAD_SCALE_GLYPH;
|
||||
if ( hinted )
|
||||
load_flags |= TTLOAD_HINT_GLYPH;
|
||||
|
||||
for ( i = 0; i < txtlen; ++i )
|
||||
{
|
||||
unsigned char j = txt[i];
|
||||
|
||||
|
||||
if ( TT_VALID( glyphs[j] ) )
|
||||
continue;
|
||||
|
||||
if ( no_cmap )
|
||||
{
|
||||
code = (j - ' ' + 1) < 0 ? 0 : (j - ' ' + 1);
|
||||
if ( code >= num_glyphs )
|
||||
code = 0;
|
||||
}
|
||||
else
|
||||
code = TT_Char_Index( char_map, j );
|
||||
|
||||
(void)(
|
||||
( error = TT_New_Glyph( face, &glyphs[j] ) ) ||
|
||||
( error = TT_Load_Glyph( instance, glyphs[j], code, load_flags ) )
|
||||
);
|
||||
|
||||
if ( error )
|
||||
Panic( "Cannot allocate and load glyph: error 0x%x.\n", error );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Done_Glyphs( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if ( !glyphs )
|
||||
return;
|
||||
|
||||
for ( i = 0; i < 256; ++i )
|
||||
TT_Done_Glyph( glyphs[i] );
|
||||
|
||||
free( glyphs );
|
||||
|
||||
glyphs = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* face & instance management */
|
||||
|
||||
static void Init_Face( const char* filename )
|
||||
{
|
||||
TT_Error error;
|
||||
|
||||
|
||||
/* load the typeface */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
if ( error )
|
||||
{
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( "Could not find/open %s.\n", filename );
|
||||
else
|
||||
Panic( "Error while opening %s, error code = 0x%x.\n",
|
||||
filename, error );
|
||||
}
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
/* create and initialize instance */
|
||||
|
||||
(void) (
|
||||
( error = TT_New_Instance( face, &instance ) ) ||
|
||||
( error = TT_Set_Instance_Resolutions( instance, dpi, dpi ) ) ||
|
||||
( error = TT_Set_Instance_PointSize( instance, ptsize ) )
|
||||
);
|
||||
|
||||
if ( error )
|
||||
Panic( "Could not create and initialize instance: error 0x%x.\n",
|
||||
error );
|
||||
}
|
||||
|
||||
|
||||
static void Done_Face( void )
|
||||
{
|
||||
TT_Done_Instance( instance );
|
||||
TT_Close_Face( face );
|
||||
}
|
||||
|
||||
|
||||
/* rasterization stuff */
|
||||
|
||||
static void Init_Raster_Areas( const char* txt, int txtlen )
|
||||
{
|
||||
int i, upm, ascent, descent;
|
||||
TT_Face_Properties properties;
|
||||
TT_Instance_Metrics imetrics;
|
||||
TT_Glyph_Metrics gmetrics;
|
||||
|
||||
|
||||
/* allocate the large bitmap */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
TT_Get_Instance_Metrics( instance, &imetrics );
|
||||
|
||||
upm = properties.header->Units_Per_EM;
|
||||
ascent = ( properties.horizontal->Ascender * imetrics.y_ppem ) / upm;
|
||||
descent = ( properties.horizontal->Descender * imetrics.y_ppem ) / upm;
|
||||
|
||||
pnm_width = 2 * border;
|
||||
pnm_height = 2 * border + ascent - descent;
|
||||
|
||||
for ( i = 0; i < txtlen; ++i )
|
||||
{
|
||||
unsigned char j = txt[i];
|
||||
|
||||
|
||||
if ( !TT_VALID( glyphs[j] ) )
|
||||
continue;
|
||||
|
||||
TT_Get_Glyph_Metrics( glyphs[j], &gmetrics );
|
||||
pnm_width += gmetrics.advance / 64;
|
||||
}
|
||||
|
||||
Init_Raster_Map( &bit, pnm_width, pnm_height );
|
||||
Clear_Raster_Map( &bit );
|
||||
|
||||
pnm_x_shift = border;
|
||||
pnm_y_shift = border - descent;
|
||||
|
||||
/* allocate the small bitmap if you need it */
|
||||
|
||||
if ( smooth )
|
||||
Init_Raster_Map( &small_bit, imetrics.x_ppem + 32, pnm_height );
|
||||
}
|
||||
|
||||
|
||||
static void Done_Raster_Areas( void )
|
||||
{
|
||||
Done_Raster_Map( &bit );
|
||||
if ( smooth )
|
||||
Done_Raster_Map( &small_bit );
|
||||
}
|
||||
|
||||
|
||||
static void Render_Glyph( TT_Glyph glyph,
|
||||
int x_off, int y_off,
|
||||
TT_Glyph_Metrics* gmetrics )
|
||||
{
|
||||
if ( !smooth )
|
||||
TT_Get_Glyph_Bitmap( glyph, &bit, x_off * 64L, y_off * 64L);
|
||||
else
|
||||
{
|
||||
TT_F26Dot6 xmin, ymin, xmax, ymax;
|
||||
|
||||
|
||||
/* grid-fit the bounding box */
|
||||
|
||||
xmin = gmetrics->bbox.xMin & -64;
|
||||
ymin = gmetrics->bbox.yMin & -64;
|
||||
xmax = (gmetrics->bbox.xMax + 63) & -64;
|
||||
ymax = (gmetrics->bbox.yMax + 63) & -64;
|
||||
|
||||
/* now render the glyph in the small pixmap */
|
||||
/* and blit-or the resulting small pixmap into the biggest one */
|
||||
|
||||
Clear_Raster_Map( &small_bit );
|
||||
TT_Get_Glyph_Pixmap( glyph, &small_bit, -xmin, -ymin );
|
||||
Blit_Or( &bit, &small_bit, xmin/64 + x_off, -ymin/64 - y_off );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Render_All_Glyphs( char* txt, int txtlen )
|
||||
{
|
||||
int i;
|
||||
TT_F26Dot6 x, y, adjx;
|
||||
TT_Glyph_Metrics gmetrics;
|
||||
|
||||
|
||||
x = pnm_x_shift;
|
||||
y = pnm_y_shift;
|
||||
|
||||
for ( i = 0; i < txtlen; i++ )
|
||||
{
|
||||
unsigned char j = txt[i];
|
||||
|
||||
if ( !TT_VALID( glyphs[j] ) )
|
||||
continue;
|
||||
|
||||
TT_Get_Glyph_Metrics( glyphs[j], &gmetrics );
|
||||
|
||||
adjx = x; /* ??? lsb */
|
||||
Render_Glyph( glyphs[j], adjx, y, &gmetrics );
|
||||
|
||||
x += gmetrics.advance / 64;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void usage( void )
|
||||
{
|
||||
printf( "\n" );
|
||||
printf( "%s: simple text to image converter -- part of the FreeType project\n", PROGNAME );
|
||||
printf( "\n" );
|
||||
printf( "Usage: %s [options below] filename [string]\n", PROGNAME );
|
||||
printf( "\n" );
|
||||
printf( " -g gray-level rendering (default: off)\n" );
|
||||
printf( " -h hinting off (default: on)\n" );
|
||||
printf( " -r X resolution X dpi (default: 96)\n" );
|
||||
printf( " -p X pointsize X pt (default: 12)\n" );
|
||||
printf( " -b X border X pixels wide (default: 0)\n" );
|
||||
printf( "\n" );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
int option, txtlen;
|
||||
char *txt, *filename;
|
||||
TT_Error error;
|
||||
|
||||
|
||||
/* Parse options */
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
option = ft_getopt( argc, argv, "ghr:p:b:" );
|
||||
|
||||
if ( option == -1 )
|
||||
break;
|
||||
|
||||
switch ( option )
|
||||
{
|
||||
case 'g':
|
||||
smooth = 1;
|
||||
break;
|
||||
case 'h':
|
||||
hinted = 0;
|
||||
break;
|
||||
case 'r':
|
||||
dpi = atoi( ft_optarg );
|
||||
break;
|
||||
case 'p':
|
||||
ptsize = atoi( ft_optarg );
|
||||
break;
|
||||
case 'b':
|
||||
border = atoi( ft_optarg );
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= ft_optind;
|
||||
argv += ft_optind;
|
||||
|
||||
if ( argc <= 0 || argc > 2 || dpi <= 0 || ptsize <= 0 || border < 0 )
|
||||
usage();
|
||||
|
||||
filename = argv[0];
|
||||
|
||||
if ( argc > 1 )
|
||||
txt = argv[1];
|
||||
else
|
||||
txt = "The quick brown fox jumps over the lazy dog";
|
||||
|
||||
txtlen = strlen( txt );
|
||||
|
||||
/* Initialize engine and other stuff */
|
||||
|
||||
error = TT_Init_FreeType( &engine );
|
||||
if ( error )
|
||||
Panic( "Error while initializing engine, code = 0x%x.\n", error );
|
||||
|
||||
Init_Face( filename );
|
||||
Load_Glyphs( txt, txtlen );
|
||||
Init_Raster_Areas( txt, txtlen );
|
||||
|
||||
/* Do the real work now */
|
||||
|
||||
Render_All_Glyphs( txt, txtlen );
|
||||
Dump_Raster_Map( &bit, stdout );
|
||||
|
||||
/* Clean up */
|
||||
|
||||
Done_Raster_Areas();
|
||||
Done_Glyphs();
|
||||
Done_Face();
|
||||
|
||||
/* That's all, folks! */
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
1158
test/ftstrtto.c
Normal file
1158
test/ftstrtto.c
Normal file
File diff suppressed because it is too large
Load Diff
455
test/fttimer.c
Normal file
455
test/fttimer.c
Normal file
@@ -0,0 +1,455 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project - a Free and Portable Quality TrueType Renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* fttimer: A simple performance benchmark. Now with graylevel rendering */
|
||||
/* with the '-g' option. */
|
||||
/* */
|
||||
/* Be aware that the timer program benchmarks different things */
|
||||
/* in each release of the FreeType library. Thus, performance */
|
||||
/* should only be compared between similar release numbers. */
|
||||
/* */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. In no way does it shows the final */
|
||||
/* high-level interface that client applications will use. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h" /* for Panic() */
|
||||
#include "freetype.h"
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
#ifndef __USE_MISC
|
||||
#define __USE_MISC /* MkLinux needs this to get a definition of
|
||||
CLOCKS_PER_SEC */
|
||||
#endif
|
||||
|
||||
#include <time.h> /* for clock() */
|
||||
|
||||
/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
|
||||
/* to get the HZ macro which is the equivalent. */
|
||||
#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4)
|
||||
#include <sys/param.h>
|
||||
#define CLOCKS_PER_SEC HZ
|
||||
#endif
|
||||
|
||||
#define MAX_GLYPHS 512 /* Maximum number of glyphs rendered at one time */
|
||||
|
||||
char Header[128];
|
||||
|
||||
TT_Error error;
|
||||
|
||||
TT_Engine engine;
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
|
||||
TT_Outline outline;
|
||||
TT_Glyph_Metrics metrics;
|
||||
|
||||
TT_Face_Properties properties;
|
||||
|
||||
TT_F26Dot6* cur_x;
|
||||
TT_F26Dot6* cur_y;
|
||||
|
||||
unsigned short* cur_endContour;
|
||||
unsigned char* cur_touch;
|
||||
|
||||
TT_Outline outlines[MAX_GLYPHS];
|
||||
|
||||
int num_glyphs;
|
||||
int tab_glyphs;
|
||||
int cur_glyph;
|
||||
int cur_point;
|
||||
unsigned short cur_contour;
|
||||
|
||||
TT_Raster_Map Bit;
|
||||
|
||||
int Fail;
|
||||
int Num;
|
||||
|
||||
short visual; /* display glyphs while rendering */
|
||||
short gray_render; /* smooth fonts with gray levels */
|
||||
|
||||
|
||||
static void Clear_Buffer( void );
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Get_Time: */
|
||||
/* */
|
||||
/* Returns the current time in milliseconds. */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
long Get_Time( void )
|
||||
{
|
||||
return clock() * 1000 / CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Init_Engine: */
|
||||
/* */
|
||||
/* Allocates bitmap, render pool and other structs... */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
void Init_Engine( void )
|
||||
{
|
||||
Bit.rows = vio_Height; /* The whole window */
|
||||
Bit.width = vio_Width;
|
||||
|
||||
if ( gray_render )
|
||||
{
|
||||
Bit.cols = Bit.width;
|
||||
Bit.flow = TT_Flow_Up;
|
||||
Bit.size = Bit.rows * Bit.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bit.cols = (Bit.width + 7) / 8; /* convert to # of bytes */
|
||||
Bit.flow = TT_Flow_Up;
|
||||
Bit.size = Bit.rows * Bit.cols; /* number of bytes in buffer */
|
||||
}
|
||||
|
||||
Bit.bitmap = (void*)malloc( Bit.size );
|
||||
if ( !Bit.bitmap )
|
||||
Panic( "ERROR: not enough memory to allocate bitmap!\n" );
|
||||
|
||||
Clear_Buffer();
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Clear_Buffer: */
|
||||
/* */
|
||||
/* Clears current bitmap. */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
static void Clear_Buffer( void )
|
||||
{
|
||||
if ( gray_render )
|
||||
memset( Bit.bitmap, gray_palette[0], Bit.size );
|
||||
else
|
||||
memset( Bit.bitmap, 0, Bit.size );
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* LoadTrueTypeChar: */
|
||||
/* */
|
||||
/* Loads a glyph into memory. */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
TT_Error LoadTrueTypeChar( int idx )
|
||||
{
|
||||
error = TT_Load_Glyph( instance, glyph, idx, TTLOAD_DEFAULT );
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
TT_Get_Glyph_Outline( glyph, &outline );
|
||||
|
||||
outline.second_pass = 0;
|
||||
outline.high_precision = 0;
|
||||
outline.dropout_mode = 0;
|
||||
|
||||
/* debugging */
|
||||
#if 0
|
||||
if ( idx == 0 && !visual )
|
||||
{
|
||||
printf( "points = %d\n", outline.points );
|
||||
for ( j = 0; j < outline.points; j++ )
|
||||
printf( "%02x (%01hx,%01hx)\n",
|
||||
j, outline.xCoord[j], outline.yCoord[j] );
|
||||
printf( "\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* create a new outline */
|
||||
TT_New_Outline( outline.n_points,
|
||||
outline.n_contours,
|
||||
&outlines[cur_glyph] );
|
||||
|
||||
/* copy the glyph outline into it */
|
||||
outline.high_precision = 0;
|
||||
outline.second_pass = 0;
|
||||
TT_Copy_Outline( &outline, &outlines[cur_glyph] );
|
||||
|
||||
/* translate it */
|
||||
TT_Translate_Outline( &outlines[cur_glyph],
|
||||
vio_Width * 16,
|
||||
vio_Height * 16 );
|
||||
cur_glyph++;
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* ConvertRaster: */
|
||||
/* */
|
||||
/* Performs scan conversion. */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
TT_Error ConvertRaster( int index )
|
||||
{
|
||||
outlines[index].second_pass = 0;
|
||||
outlines[index].high_precision = 0;
|
||||
|
||||
if ( gray_render )
|
||||
return TT_Get_Outline_Pixmap( engine, &outlines[index], &Bit );
|
||||
else
|
||||
return TT_Get_Outline_Bitmap( engine, &outlines[index], &Bit );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
int i, total, mode, base, rendered_glyphs;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
|
||||
long t, t0, tz0;
|
||||
|
||||
|
||||
execname = argv[0];
|
||||
|
||||
gray_render = 0;
|
||||
visual = 0;
|
||||
|
||||
while ( argc > 1 && argv[1][0] == '-' )
|
||||
{
|
||||
switch ( argv[1][1] )
|
||||
{
|
||||
case 'g':
|
||||
gray_render = 1;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
visual = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
Panic( "Unknown argument '%s'!\n", argv[1] );
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ( argc != 2 )
|
||||
{
|
||||
fprintf( stderr, "fttimer: simple performance timer -- part of the FreeType project\n" );
|
||||
fprintf( stderr,"-----------------------------------------------------------------\n\n" );
|
||||
fprintf( stderr,"Usage: %s [-g] [-v] fontname[.ttf|.ttc]\n\n", execname );
|
||||
fprintf( stderr," where '-g' asks for gray-levels rendering\n" );
|
||||
fprintf( stderr," '-v' displays while rendering (slower)\n" );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
i = strlen( argv[1] );
|
||||
while ( i > 0 && argv[1][i] != '\\' )
|
||||
{
|
||||
if ( argv[1][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, argv[1], 128 );
|
||||
strncpy( alt_filename, argv[1], 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Initialize engine */
|
||||
|
||||
if ( (error = TT_Init_FreeType( &engine )) )
|
||||
Panic( "Error while initializing engine, code = 0x%x.\n", error );
|
||||
|
||||
/* Load face */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( "Could not find/open %s.\n", filename );
|
||||
else if ( error )
|
||||
Panic( "Error while opening %s, error code = 0x%x.\n",
|
||||
filename, error );
|
||||
|
||||
/* get face properties and allocate preload arrays */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
tab_glyphs = MAX_GLYPHS;
|
||||
if ( tab_glyphs > num_glyphs )
|
||||
tab_glyphs = num_glyphs;
|
||||
|
||||
/* create glyph */
|
||||
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
Panic( "Could not create glyph container.\n" );
|
||||
|
||||
/* create instance */
|
||||
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
Panic( "Could not create instance for %s.\n", filename );
|
||||
|
||||
error = TT_Set_Instance_CharSize( instance, 400*64 );
|
||||
if ( error )
|
||||
Panic( "Could not reset instance for %s.\n", filename );
|
||||
|
||||
if ( gray_render )
|
||||
mode = Graphics_Mode_Gray;
|
||||
else
|
||||
mode = Graphics_Mode_Mono;
|
||||
|
||||
if ( visual )
|
||||
{
|
||||
if ( !SetGraphScreen( mode ) )
|
||||
Panic( "Could not set graphics mode.\n" );
|
||||
TT_Set_Raster_Gray_Palette( engine, gray_palette );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is the default bitmap size used */
|
||||
vio_Width = 640;
|
||||
vio_Height = 450;
|
||||
}
|
||||
|
||||
Init_Engine();
|
||||
|
||||
Num = 0;
|
||||
Fail = 0;
|
||||
|
||||
total = num_glyphs;
|
||||
base = 0;
|
||||
|
||||
rendered_glyphs = 0;
|
||||
|
||||
t0 = 0; /* Initial time */
|
||||
|
||||
tz0 = Get_Time();
|
||||
|
||||
while ( total > 0 )
|
||||
{
|
||||
/* First, preload 'tab_glyphs' in memory */
|
||||
|
||||
cur_glyph = 0;
|
||||
cur_point = 0;
|
||||
cur_contour = 0;
|
||||
|
||||
printf( "loading %d glyphs", tab_glyphs );
|
||||
|
||||
for ( Num = 0; Num < tab_glyphs; Num++ )
|
||||
{
|
||||
error = LoadTrueTypeChar( base + Num );
|
||||
if ( error )
|
||||
Fail++;
|
||||
|
||||
total--;
|
||||
}
|
||||
|
||||
base += tab_glyphs;
|
||||
|
||||
if ( tab_glyphs > total )
|
||||
tab_glyphs = total;
|
||||
|
||||
printf( ", rendering... " );
|
||||
|
||||
/* Now, render the loaded glyphs */
|
||||
|
||||
t = Get_Time();
|
||||
|
||||
for ( Num = 0; Num < cur_glyph; Num++ )
|
||||
{
|
||||
if ( (error = ConvertRaster( Num )) )
|
||||
Fail++;
|
||||
else
|
||||
{
|
||||
rendered_glyphs ++;
|
||||
|
||||
if ( visual )
|
||||
{
|
||||
sprintf( Header, "Glyph: %5d", Num );
|
||||
Display_Bitmap_On_Screen( Bit.bitmap, Bit.rows, Bit.cols );
|
||||
|
||||
Clear_Buffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t = Get_Time() - t;
|
||||
if ( t < 0 )
|
||||
t += 100L * 60 * 60;
|
||||
|
||||
printf( " = %f s\n", (double)t / 1000 );
|
||||
t0 += t;
|
||||
|
||||
/* Now free all loaded outlines */
|
||||
for ( Num = 0; Num < cur_glyph; Num++ )
|
||||
TT_Done_Outline( &outlines[Num] );
|
||||
}
|
||||
|
||||
tz0 = Get_Time() - tz0;
|
||||
|
||||
if ( visual )
|
||||
RestoreScreen();
|
||||
|
||||
TT_Close_Face( face );
|
||||
|
||||
printf( "\n" );
|
||||
printf( "rendered glyphs = %d\n", rendered_glyphs );
|
||||
printf( "render time = %f s\n", (double)t0 / 1000 );
|
||||
printf( "fails = %d\n", Fail );
|
||||
printf( "average glyphs/s = %f\n",
|
||||
(double)rendered_glyphs / t0 * 1000 );
|
||||
|
||||
printf( "total timing = %f s\n", (double)tz0 / 1000 );
|
||||
printf( "Fails = %d\n", Fail );
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
540
test/ftview.c
Normal file
540
test/ftview.c
Normal file
@@ -0,0 +1,540 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project -- a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftview: A simple font viewer. Now supports hinting and grayscaling */
|
||||
/* with the '-g' option. */
|
||||
/* */
|
||||
/* */
|
||||
/* Keys: */
|
||||
/* */
|
||||
/* x : fine counter-clockwise rotation */
|
||||
/* c : fine clockwise rotation */
|
||||
/* */
|
||||
/* v : fast counter-clockwise rotation */
|
||||
/* b : fast clockwise rotation */
|
||||
/* */
|
||||
/* + : fast scale up */
|
||||
/* - : fast scale down */
|
||||
/* u : fine scale down */
|
||||
/* j : fine scale up */
|
||||
/* */
|
||||
/* l : go to next glyph */
|
||||
/* k : go to previous glyph */
|
||||
/* */
|
||||
/* o : go to tenth next glyph */
|
||||
/* i : go to tenth previous glyph */
|
||||
/* */
|
||||
/* 0 : go to hundredth next glyph */
|
||||
/* 9 : go to hundredth previous glyph */
|
||||
/* */
|
||||
/* ) : go to 1000th next glyph */
|
||||
/* ( : go to 1000th previous glyph */
|
||||
/* */
|
||||
/* } : go to 10000th next glyph */
|
||||
/* { : go to 10000th previous glyph */
|
||||
/* */
|
||||
/* n : go to next (or last) .ttf file */
|
||||
/* p : go to previous (or first) .ttf file */
|
||||
/* */
|
||||
/* h : toggle hinting */
|
||||
/* */
|
||||
/* B : toggle sbit */
|
||||
/* */
|
||||
/* ESC : exit */
|
||||
/* */
|
||||
/* */
|
||||
/* NOTE: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "blitter.h"
|
||||
#include "common.h" /* for Panic() only */
|
||||
#include "display.h"
|
||||
#include "freetype.h"
|
||||
#include "ftxsbit.h"
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
#define Pi 3.1415926535
|
||||
|
||||
#define MAXPTSIZE 500 /* dtp */
|
||||
#define Center_X ( Bit.width / 2 ) /* dtp */
|
||||
#define Center_Y ( Bit.rows / 2 ) /* dtp */
|
||||
|
||||
/*
|
||||
* If Ignore_Err_Not_SBit is not defined,
|
||||
* "Fail" increase when the glyph does not have sbit and
|
||||
* sbit_flag is 1.
|
||||
*/
|
||||
#define Ignore_Err_Not_SBit 1
|
||||
|
||||
char Header[128];
|
||||
|
||||
TT_Engine engine;
|
||||
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
TT_CharMap char_map;
|
||||
|
||||
TT_Big_Glyph_Metrics metrics;
|
||||
TT_Outline outline;
|
||||
TT_Face_Properties properties;
|
||||
TT_Instance_Metrics imetrics;
|
||||
|
||||
TT_SBit_Image* sbit;
|
||||
|
||||
int num_glyphs;
|
||||
|
||||
int ptsize;
|
||||
int hinted;
|
||||
|
||||
int Rotation;
|
||||
int Fail;
|
||||
int Num;
|
||||
unsigned char autorun;
|
||||
|
||||
int gray_render;
|
||||
unsigned int sbit_flag; /* 0 if to display outlines
|
||||
* 1 if to use embedded bitmaps
|
||||
* 2 if to show sbit and outline glyphs
|
||||
*/
|
||||
|
||||
int glyph_has_sbit;
|
||||
|
||||
|
||||
|
||||
static TT_Error Reset_Scale( int pointSize )
|
||||
{
|
||||
TT_Error error;
|
||||
TT_SBit_Strike strike;
|
||||
|
||||
if ( (error = TT_Set_Instance_PointSize( instance, pointSize )) )
|
||||
{
|
||||
RestoreScreen();
|
||||
fprintf( stderr, "Error = 0x%x.\n", (int)error );
|
||||
Panic( "Could not reset instance.\n" );
|
||||
}
|
||||
TT_Get_Instance_Metrics( instance, &imetrics );
|
||||
|
||||
/* now re-allocates the small bitmap */
|
||||
if ( gray_render )
|
||||
{
|
||||
Init_Small( imetrics.x_ppem, imetrics.y_ppem );
|
||||
Clear_Small();
|
||||
}
|
||||
|
||||
if ( TT_Get_SBit_Strike( face, instance, &strike ) )
|
||||
glyph_has_sbit = 0;
|
||||
else
|
||||
glyph_has_sbit = 1;
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static TT_Error LoadTrueTypeChar( int idx,
|
||||
int hint )
|
||||
{
|
||||
int flags;
|
||||
|
||||
|
||||
flags = TTLOAD_SCALE_GLYPH;
|
||||
if ( hint )
|
||||
flags |= TTLOAD_HINT_GLYPH;
|
||||
|
||||
return TT_Load_Glyph( instance, glyph, idx, flags );
|
||||
}
|
||||
|
||||
|
||||
static TT_Error Render_All( int first_glyph,
|
||||
int ptsize )
|
||||
{
|
||||
TT_F26Dot6 start_x, start_y, step_x, step_y, x, y;
|
||||
int i;
|
||||
|
||||
TT_Error error = 0;
|
||||
|
||||
|
||||
start_x = 4;
|
||||
start_y = vio_Height - ( ( ptsize * 96 + 36 ) / 72 + 10 );
|
||||
|
||||
step_x = imetrics.x_ppem + 4;
|
||||
step_y = imetrics.y_ppem + 10;
|
||||
|
||||
x = start_x;
|
||||
y = start_y;
|
||||
|
||||
i = first_glyph;
|
||||
|
||||
while ( i < num_glyphs )
|
||||
{
|
||||
if ( ( glyph_has_sbit ) &&
|
||||
( ( sbit_flag + 1 ) & 2 ) &&
|
||||
!(error = TT_Load_Glyph_Bitmap( face, instance, i, sbit )) )
|
||||
{
|
||||
Blit_Bitmap( &Bit,
|
||||
&sbit->map,
|
||||
gray_render ? 8 : 1,
|
||||
x + (sbit->metrics.horiBearingX/64),
|
||||
Bit.rows - y - (sbit->metrics.horiBearingY/64),
|
||||
gray_palette[4] );
|
||||
metrics = sbit->metrics;
|
||||
goto Step;
|
||||
}
|
||||
|
||||
if ( ( ( !glyph_has_sbit ) ||
|
||||
( ( sbit_flag + 1 ) & 1 ) ) &&
|
||||
!(error = LoadTrueTypeChar( i, hinted )) )
|
||||
{
|
||||
TT_Get_Glyph_Outline( glyph, &outline );
|
||||
TT_Get_Glyph_Big_Metrics( glyph, &metrics );
|
||||
|
||||
Render_Single_Glyph( gray_render, glyph, x, y );
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef Ignore_Err_Not_SBit
|
||||
if (!(( glyph_has_sbit ) &&
|
||||
( sbit_flag == 1 ) &&
|
||||
( error == TT_Err_Invalid_Glyph_Index )))
|
||||
#endif
|
||||
Fail++;
|
||||
}
|
||||
Step:
|
||||
x += ( metrics.horiAdvance / 64 ) + 1;
|
||||
|
||||
if ( x + imetrics.x_ppem > vio_Width )
|
||||
{
|
||||
x = start_x;
|
||||
y -= step_y;
|
||||
|
||||
if ( y < 10 )
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static int Process_Event( TEvent* event )
|
||||
{
|
||||
switch ( event->what )
|
||||
{
|
||||
case event_Quit: /* ESC or q */
|
||||
return 0;
|
||||
|
||||
case event_Keyboard:
|
||||
if ( event->info == 'n' ) /* Next file */
|
||||
return 'n';
|
||||
if ( event->info == 'p' ) /* Previous file */
|
||||
return 'p';
|
||||
if ( event->info == 'h' ) /* Toggle hinting */
|
||||
hinted = !hinted;
|
||||
if ( ( event->info == 'B' ) && ( glyph_has_sbit ) ) /* Toggle sbit */
|
||||
sbit_flag = ( sbit_flag + 1 ) % 3;
|
||||
break;
|
||||
|
||||
case event_Rotate_Glyph:
|
||||
Rotation = ( Rotation + event->info ) & 1023;
|
||||
break;
|
||||
|
||||
case event_Scale_Glyph:
|
||||
ptsize += event->info;
|
||||
if ( ptsize < 1 ) ptsize = 1;
|
||||
if ( ptsize > MAXPTSIZE ) ptsize = MAXPTSIZE;
|
||||
break;
|
||||
|
||||
case event_Change_Glyph:
|
||||
Num += event->info;
|
||||
if ( Num < 0 ) Num = 0;
|
||||
if ( Num >= num_glyphs ) Num = num_glyphs - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void usage( char* execname )
|
||||
{
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "ftview: simple TrueType interpreter tester -- part of the FreeType project\n" );
|
||||
fprintf( stderr, "--------------------------------------------------------------------------\n" );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, "Usage: %s [options below] ppem fontname[.ttf|.ttc] ...\n",
|
||||
execname );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, " -g gray-level rendering (default: none)\n" );
|
||||
fprintf( stderr, " -r R use resolution R dpi (default: 96)\n" );
|
||||
fprintf( stderr, " -B use embedded bitmaps (default: none)\n" );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc,
|
||||
char** argv )
|
||||
{
|
||||
int i, old_ptsize, orig_ptsize, file;
|
||||
int XisSetup = 0;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
int option;
|
||||
int res = 96;
|
||||
|
||||
TT_Error error;
|
||||
TEvent event;
|
||||
|
||||
TT_EBLC eblc_table;
|
||||
|
||||
|
||||
execname = ft_basename( argv[0] );
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
option = ft_getopt( argc, argv, "gr:B" );
|
||||
|
||||
if ( option == -1 )
|
||||
break;
|
||||
|
||||
switch ( option )
|
||||
{
|
||||
case 'g':
|
||||
gray_render = 1;
|
||||
sbit_flag = 0;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
res = atoi( ft_optarg );
|
||||
if ( res < 1 )
|
||||
usage( execname );
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
if (!gray_render)
|
||||
#if 0
|
||||
sbit_flag = 1;
|
||||
#else
|
||||
sbit_flag = 2;
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
usage( execname );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= ft_optind;
|
||||
argv += ft_optind;
|
||||
|
||||
if ( argc <= 1 )
|
||||
usage( execname );
|
||||
|
||||
if ( sscanf( argv[0], "%d", &orig_ptsize ) != 1 )
|
||||
orig_ptsize = 64;
|
||||
|
||||
file = 1;
|
||||
|
||||
/* Initialize engine */
|
||||
|
||||
if ( (error = TT_Init_FreeType( &engine )) )
|
||||
Panic( "Error while initializing engine, code = 0x%x.\n", error );
|
||||
|
||||
if ( (error = TT_Init_SBit_Extension( engine )) )
|
||||
Panic( "Error while initializing sbit extention, code = 0x%x.\n", error );
|
||||
|
||||
NewFile:
|
||||
ptsize = orig_ptsize;
|
||||
hinted = 1;
|
||||
|
||||
i = strlen( argv[file] );
|
||||
while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )
|
||||
{
|
||||
if ( argv[file][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, argv[file], 128 );
|
||||
strncpy( alt_filename, argv[file], 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
/* Load face */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( "Could not find/open %s.\n", filename );
|
||||
else if ( error )
|
||||
Panic( "Error while opening %s, code = 0x%x.\n", filename, error );
|
||||
|
||||
/* get face properties and allocate preload arrays */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
|
||||
glyph_has_sbit = 0;
|
||||
|
||||
error = TT_Get_Face_Bitmaps( face, &eblc_table );
|
||||
if ( error == TT_Err_Ok )
|
||||
glyph_has_sbit = 1;
|
||||
if ( sbit_flag && !glyph_has_sbit )
|
||||
Panic( "%s does not have embedded bitmap glyphs.\n", filename );
|
||||
|
||||
/* create glyph */
|
||||
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
Panic( "Could not create glyph container.\n" );
|
||||
|
||||
error = TT_New_SBit_Image( &sbit );
|
||||
if ( error )
|
||||
Panic( "Could not create sbit slot.\n" );
|
||||
|
||||
/* create instance */
|
||||
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
Panic( "Could not create instance for %s.\n", filename );
|
||||
|
||||
error = TT_Set_Instance_Resolutions( instance, res, res );
|
||||
if ( error )
|
||||
Panic( "Could not set device resolutions." );
|
||||
|
||||
if ( !XisSetup )
|
||||
{
|
||||
XisSetup = 1;
|
||||
|
||||
if ( gray_render )
|
||||
{
|
||||
if ( !SetGraphScreen( Graphics_Mode_Gray ) )
|
||||
Panic( "Could not set up grayscale graphics mode.\n" );
|
||||
|
||||
TT_Set_Raster_Gray_Palette( engine, virtual_palette );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !SetGraphScreen( Graphics_Mode_Mono ) )
|
||||
Panic( "Could not set up mono graphics mode.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
Init_Display( gray_render );
|
||||
|
||||
Reset_Scale( ptsize );
|
||||
|
||||
old_ptsize = ptsize;
|
||||
|
||||
Fail = 0;
|
||||
Num = 0;
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
int key;
|
||||
char* sbit_string;
|
||||
static char* sbit_messages[4] =
|
||||
{ "off", "on", " if available", "NONE" };
|
||||
|
||||
sbit_string = sbit_messages[3];
|
||||
if ( glyph_has_sbit )
|
||||
{
|
||||
if (sbit_flag >= 0 && sbit_flag < 3)
|
||||
sbit_string = sbit_messages[sbit_flag];
|
||||
}
|
||||
|
||||
Clear_Display();
|
||||
Render_All( Num, ptsize );
|
||||
if ( gray_render )
|
||||
Convert_To_Display_Palette();
|
||||
|
||||
sprintf( Header, "%s: Glyph: %4d ptsize: %4d hinting: %s sbit: %s",
|
||||
ft_basename( filename ), Num, ptsize,
|
||||
hinted ? "on" : "off",
|
||||
sbit_string );
|
||||
Display_Bitmap_On_Screen( Bit.bitmap, Bit.rows, Bit.cols );
|
||||
|
||||
#ifndef X11
|
||||
#ifndef OS2
|
||||
Print_XY( 0, 0, Header );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Get_Event( &event );
|
||||
if ( !( key = Process_Event( &event ) ) )
|
||||
goto End;
|
||||
|
||||
if ( key == 'n' )
|
||||
{
|
||||
TT_Close_Face( face );
|
||||
|
||||
if ( file < argc - 1 )
|
||||
file++;
|
||||
|
||||
goto NewFile;
|
||||
}
|
||||
|
||||
if ( key == 'p' )
|
||||
{
|
||||
TT_Close_Face( face );
|
||||
|
||||
if ( file > 1 )
|
||||
file--;
|
||||
|
||||
goto NewFile;
|
||||
}
|
||||
|
||||
if ( ptsize != old_ptsize )
|
||||
{
|
||||
if ( Reset_Scale( ptsize ) )
|
||||
Panic( "Could not resize font.\n" );
|
||||
|
||||
old_ptsize = ptsize;
|
||||
}
|
||||
}
|
||||
|
||||
End:
|
||||
RestoreScreen();
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
printf( "Execution completed successfully.\n" );
|
||||
printf( "Fails = %d\n", Fail );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
681
test/ftzoom.c
Normal file
681
test/ftzoom.c
Normal file
@@ -0,0 +1,681 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The FreeType project - a free and portable quality TrueType renderer. */
|
||||
/* */
|
||||
/* Copyright 1996-1999 by */
|
||||
/* D. Turner, R.Wilhelm, and W. Lemberg */
|
||||
/* */
|
||||
/* ftzoom : A simple glyph viewer. Now supports graylevel rendering */
|
||||
/* with the '-g' option. */
|
||||
/* */
|
||||
/* Use `-p <platformID>' together with `-e <encodingID>' to */
|
||||
/* select a cmap. */
|
||||
/* */
|
||||
/* Keys: */
|
||||
/* */
|
||||
/* x : fine counter_clockwise rotation */
|
||||
/* c : fine clockwise rotation */
|
||||
/* */
|
||||
/* v : fast counter_clockwise rotation */
|
||||
/* b : fast clockwise rotation */
|
||||
/* */
|
||||
/* + : fast scale up */
|
||||
/* - : fast scale down */
|
||||
/* u : fine scale down */
|
||||
/* j : fine scale up */
|
||||
/* */
|
||||
/* l : go to next glyph */
|
||||
/* k : go to previous glyph */
|
||||
/* */
|
||||
/* o : go to tenth next glyph */
|
||||
/* i : go to tenth previous glyph */
|
||||
/* */
|
||||
/* 0 : go to hundredth next glyph */
|
||||
/* 9 : go to hundredth previous glyph */
|
||||
/* */
|
||||
/* ) : go to 1000th next glyph */
|
||||
/* ( : go to 1000th previous glyph */
|
||||
/* */
|
||||
/* } : go to 10000th next glyph */
|
||||
/* { : go to 10000th previous glyph */
|
||||
/* */
|
||||
/* q : */
|
||||
/* ESC : exit */
|
||||
/* */
|
||||
/* */
|
||||
/* NOTE 1: This is just a test program that is used to show off and */
|
||||
/* debug the current engine. In no way does it show the final */
|
||||
/* high-level interface that client applications will use. */
|
||||
/* */
|
||||
/* NOTE 2: The `post' engine is used to display the PS glyph names. */
|
||||
/* Use the `-n' switch if you don't want that. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h" /* for Panic() only */
|
||||
#include "freetype.h"
|
||||
#include "ftxpost.h"
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gevents.h"
|
||||
#include "gmain.h"
|
||||
|
||||
#ifdef DEBUG_LEVEL_TRACE
|
||||
#include "ttdebug.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define Pi 3.1415926535
|
||||
|
||||
#define MAXPTSIZE 5000 /* dtp */
|
||||
|
||||
char Header[128];
|
||||
|
||||
TT_Engine engine;
|
||||
TT_Face face;
|
||||
TT_Instance instance;
|
||||
TT_Glyph glyph;
|
||||
TT_CharMap char_map;
|
||||
|
||||
TT_Glyph_Metrics metrics;
|
||||
TT_Outline outline;
|
||||
TT_Face_Properties properties;
|
||||
TT_Instance_Metrics imetrics;
|
||||
|
||||
int num_glyphs;
|
||||
int xcenter_upem;
|
||||
int ycenter_upem;
|
||||
int units_per_em;
|
||||
|
||||
int ptsize;
|
||||
int old_ptsize;
|
||||
int rotation;
|
||||
int old_rotation;
|
||||
|
||||
TT_Matrix matrix;
|
||||
TT_Matrix zoom_matrix;
|
||||
int apply_matrix;
|
||||
int xcenter;
|
||||
int ycenter;
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
|
||||
TT_Raster_Map Bit;
|
||||
|
||||
int Fail;
|
||||
int Num;
|
||||
int Code;
|
||||
|
||||
int gray_render = 0;
|
||||
int hinted = 1;
|
||||
int use_cmap = 0;
|
||||
int zoom_factor = 1;
|
||||
int grid = 0;
|
||||
int use_post = 1;
|
||||
|
||||
char palette[5] = { 0, 1, 2, 3, 4 };
|
||||
|
||||
|
||||
static void ClearData( void )
|
||||
{
|
||||
if ( gray_render )
|
||||
memset( Bit.bitmap, gray_palette[0], Bit.size );
|
||||
else
|
||||
memset( Bit.bitmap, 0, Bit.size );
|
||||
}
|
||||
|
||||
|
||||
void Init_Raster_Area( void )
|
||||
{
|
||||
Bit.rows = vio_Height; /* The whole window */
|
||||
Bit.width = vio_Width;
|
||||
Bit.flow = TT_Flow_Up;
|
||||
|
||||
if ( gray_render )
|
||||
{
|
||||
Bit.cols = Bit.width;
|
||||
Bit.size = Bit.rows * Bit.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bit.cols = ( Bit.width + 7 ) / 8; /* convert to # of bytes */
|
||||
Bit.size = Bit.rows * Bit.cols; /* number of bytes in buffer */
|
||||
}
|
||||
|
||||
Bit.bitmap = (void*)malloc( (int)Bit.size );
|
||||
if ( !Bit.bitmap )
|
||||
Panic( "Not enough memory to allocate bitmap!\n" );
|
||||
|
||||
ClearData();
|
||||
}
|
||||
|
||||
|
||||
static TT_Error Reset_PtSize( int pointSize )
|
||||
{
|
||||
TT_Error error;
|
||||
|
||||
|
||||
if ( (error = TT_Set_Instance_PointSize( instance, pointSize )) )
|
||||
{
|
||||
RestoreScreen();
|
||||
printf( "Error = 0x%x.\n", (int)error );
|
||||
Panic( "Could not reset instance.\n" );
|
||||
}
|
||||
|
||||
TT_Get_Instance_Metrics( instance, &imetrics );
|
||||
|
||||
xcenter = imetrics.x_ppem * xcenter_upem / units_per_em / 4;
|
||||
ycenter = imetrics.y_ppem * ycenter_upem / units_per_em / 4;
|
||||
|
||||
xoffset = vio_Width/2 - xcenter;
|
||||
yoffset = vio_Height/2 - ycenter;
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static TT_Error Reset_Rotation( int rotation )
|
||||
{
|
||||
if ( rotation )
|
||||
{
|
||||
float angle;
|
||||
|
||||
|
||||
TT_Set_Instance_Transform_Flags( instance, 1, 0 );
|
||||
|
||||
angle = rotation * Pi / 512;
|
||||
|
||||
matrix.xx = (TT_Fixed)(cos( angle ) * (1L<<16));
|
||||
matrix.xy = (TT_Fixed)(sin( angle ) * (1L<<16));
|
||||
matrix.yx = -matrix.xy;
|
||||
matrix.yy = matrix.xx;
|
||||
|
||||
apply_matrix = 1;
|
||||
}
|
||||
else
|
||||
apply_matrix = 0;
|
||||
|
||||
if ( zoom_factor != 1 )
|
||||
{
|
||||
zoom_matrix.xx = zoom_matrix.yy = zoom_factor * (1L<<16);
|
||||
zoom_matrix.xy = zoom_matrix.yx = 0;
|
||||
}
|
||||
|
||||
return TT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
static TT_Error LoadTrueTypeChar( int idx, int hint )
|
||||
{
|
||||
TT_Error error;
|
||||
int flags;
|
||||
|
||||
|
||||
flags = TTLOAD_SCALE_GLYPH;
|
||||
if ( hint )
|
||||
flags |= TTLOAD_HINT_GLYPH;
|
||||
|
||||
error = TT_Load_Glyph( instance, glyph, idx, flags );
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
if ( apply_matrix || zoom_factor != 1 )
|
||||
{
|
||||
TT_Get_Glyph_Outline( glyph, &outline );
|
||||
TT_Translate_Outline( &outline, -xcenter*64L, -ycenter*64L );
|
||||
if ( apply_matrix )
|
||||
TT_Transform_Outline( &outline, &matrix );
|
||||
if ( zoom_factor != 1 )
|
||||
TT_Transform_Outline( &outline, &zoom_matrix );
|
||||
TT_Translate_Outline( &outline, xcenter*64L, ycenter*64L );
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static TT_Error ConvertRaster( void )
|
||||
{
|
||||
if ( gray_render )
|
||||
return TT_Get_Glyph_Pixmap( glyph, &Bit, xoffset*64L, yoffset*64L );
|
||||
else
|
||||
return TT_Get_Glyph_Bitmap( glyph, &Bit, xoffset*64L, yoffset*64L );
|
||||
}
|
||||
|
||||
|
||||
static void DrawGrid( void )
|
||||
{
|
||||
char *bmap, mask;
|
||||
int x, y, shift, toggle;
|
||||
|
||||
|
||||
bmap = (char *)Bit.bitmap;
|
||||
|
||||
for ( y = 0; y < Bit.rows; ++y )
|
||||
{
|
||||
if ( ( y - xoffset ) % zoom_factor == 0 )
|
||||
{
|
||||
if ( gray_render )
|
||||
for ( x = y & 1; x < Bit.cols; x += 2 )
|
||||
bmap[x] = 4 - bmap[x];
|
||||
else {
|
||||
mask = y & 1 ? 0x55 : 0xAA;
|
||||
for ( x = 0; x < Bit.cols; ++x )
|
||||
bmap[x] ^= mask;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toggle = y & 1;
|
||||
|
||||
if ( gray_render )
|
||||
{
|
||||
for ( x = xoffset % zoom_factor; x < Bit.cols; x += zoom_factor )
|
||||
if ( ( x & 1 ) == toggle )
|
||||
bmap[x] = 4 - bmap[x];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* tricky business */
|
||||
shift = xoffset % zoom_factor;
|
||||
for ( x = 0; x < Bit.cols; ++x )
|
||||
{
|
||||
for ( mask = 0; shift < 8; shift += zoom_factor )
|
||||
if ( ( shift & 1 ) == toggle )
|
||||
mask |= 0x80 >> shift;
|
||||
bmap[x] ^= mask;
|
||||
shift -= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
bmap += Bit.cols;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int Process_Event( TEvent* event )
|
||||
{
|
||||
switch ( event->what )
|
||||
{
|
||||
case event_Quit: /* ESC or q */
|
||||
return 0;
|
||||
|
||||
case event_Keyboard:
|
||||
if ( event->info == 'h' ) /* Toggle hinting */
|
||||
hinted = !hinted;
|
||||
break;
|
||||
|
||||
case event_Rotate_Glyph:
|
||||
rotation = ( rotation + event->info ) & 1023;
|
||||
break;
|
||||
|
||||
case event_Scale_Glyph:
|
||||
ptsize += event->info;
|
||||
if ( ptsize < 1 )
|
||||
ptsize = 1;
|
||||
if ( ptsize > MAXPTSIZE / zoom_factor )
|
||||
ptsize = MAXPTSIZE / zoom_factor;
|
||||
break;
|
||||
|
||||
case event_Change_Glyph:
|
||||
if ( use_cmap )
|
||||
{
|
||||
if ( event->info < 0 )
|
||||
{
|
||||
if ( Code > -event->info )
|
||||
Code += event->info;
|
||||
else
|
||||
Code = 0;
|
||||
|
||||
for ( ; Code >= 0; Code-- )
|
||||
{
|
||||
Num = TT_Char_Index( char_map, Code );
|
||||
if ( Num > 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Code < 65536 - event->info - 1 )
|
||||
Code += event->info;
|
||||
else
|
||||
Code = 65536 - 1;
|
||||
|
||||
for ( ; Code < 65536; Code++ )
|
||||
{
|
||||
Num = TT_Char_Index( char_map, Code );
|
||||
if ( Num > 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( event->info < 0 )
|
||||
{
|
||||
if ( Num > -event->info )
|
||||
Num += event->info;
|
||||
else
|
||||
Num = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Num < num_glyphs - event->info - 1 )
|
||||
Num += event->info;
|
||||
else
|
||||
Num = num_glyphs - 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void usage( char* execname )
|
||||
{
|
||||
printf( "\n" );
|
||||
printf( "ftzoom: simple TrueType glyph viewer -- part of the FreeType project\n" );
|
||||
printf( "--------------------------------------------------------------------\n" );
|
||||
printf( "\n" );
|
||||
printf( "Usage: %s [options below] fontname[.ttf|.ttc]\n", execname );
|
||||
printf( "\n" );
|
||||
printf( " -g gray-level rendering (default: none)\n" );
|
||||
printf( " -r R use resolution R dpi (default: 96)\n" );
|
||||
printf( " -z Z Z:1 magnification (default: 1:1)\n" );
|
||||
printf( " -p id platform id (default: none)\n" );
|
||||
printf( " -e id encoding id (default: none)\n" );
|
||||
printf( " -n don't use the `post' table\n" );
|
||||
printf( " If either -p or -e is not set, no cmap will be used.\n" );
|
||||
printf( "\n" );
|
||||
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
|
||||
/* stack check dtp */
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
int i;
|
||||
int platform = -1, encoding = -1;
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
int option;
|
||||
int res = 96;
|
||||
TT_Error error;
|
||||
TT_Post post;
|
||||
|
||||
TEvent event;
|
||||
|
||||
|
||||
execname = argv[0];
|
||||
gray_render = 0;
|
||||
|
||||
|
||||
#ifdef DEBUG_LEVEL_TRACE
|
||||
|
||||
set_tt_trace_levels( trace_raster, 7 );
|
||||
set_tt_trace_levels( trace_gload, 7 );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
option = ft_getopt( argc, argv, "e:gnp:r:z:" );
|
||||
|
||||
if ( option == -1 )
|
||||
break;
|
||||
|
||||
switch ( option )
|
||||
{
|
||||
case 'e':
|
||||
encoding = atoi( ft_optarg );
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
gray_render = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
use_post = 0;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
platform = atoi( ft_optarg );
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
res = atoi( ft_optarg );
|
||||
if ( res < 1 )
|
||||
usage( execname );
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
zoom_factor = atoi( ft_optarg );
|
||||
if ( zoom_factor < 1 || zoom_factor > 16 )
|
||||
usage( execname );
|
||||
if ( zoom_factor > 4 )
|
||||
grid = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage( execname );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ft_optind == argc )
|
||||
usage( execname );
|
||||
|
||||
i = strlen( argv[ft_optind] );
|
||||
while ( i > 0 && argv[ft_optind][i] != '\\' && argv[ft_optind][i] != '/' )
|
||||
{
|
||||
if ( argv[ft_optind][i] == '.' )
|
||||
i = 0;
|
||||
i--;
|
||||
}
|
||||
|
||||
filename[128] = '\0';
|
||||
alt_filename[128] = '\0';
|
||||
|
||||
strncpy( filename, argv[ft_optind], 128 );
|
||||
strncpy( alt_filename, argv[ft_optind], 128 );
|
||||
|
||||
if ( i >= 0 )
|
||||
{
|
||||
strncpy( filename + strlen( filename ), ".ttf", 4 );
|
||||
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
|
||||
}
|
||||
|
||||
if ( platform >= 0 || encoding >= 0 )
|
||||
use_cmap = 1;
|
||||
|
||||
/* Initialization */
|
||||
TT_Init_FreeType( &engine );
|
||||
|
||||
/* Initialization of the post extension */
|
||||
if ( use_post )
|
||||
TT_Init_Post_Extension( engine );
|
||||
|
||||
/* Load face */
|
||||
|
||||
error = TT_Open_Face( engine, filename, &face );
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
{
|
||||
strcpy( filename, alt_filename );
|
||||
error = TT_Open_Face( engine, alt_filename, &face );
|
||||
}
|
||||
|
||||
if ( error == TT_Err_Could_Not_Open_File )
|
||||
Panic( "Could not find/open %s.\n", filename );
|
||||
else if ( error )
|
||||
Panic( "Error while opening %s, error code = 0x%x.\n",
|
||||
filename, error );
|
||||
|
||||
/* get face properties and allocate preload arrays */
|
||||
|
||||
TT_Get_Face_Properties( face, &properties );
|
||||
|
||||
num_glyphs = properties.num_Glyphs;
|
||||
xcenter_upem = (properties.header->xMax - properties.header->xMin) / 2;
|
||||
ycenter_upem = (properties.header->yMax - properties.header->yMin) / 2;
|
||||
units_per_em = properties.header->Units_Per_EM;
|
||||
|
||||
/* load full post table */
|
||||
if ( use_post )
|
||||
{
|
||||
error = TT_Load_PS_Names( face, &post );
|
||||
if ( error )
|
||||
Panic( "Could not load PS names.\n" );
|
||||
}
|
||||
|
||||
/* create glyph */
|
||||
|
||||
error = TT_New_Glyph( face, &glyph );
|
||||
if ( error )
|
||||
Panic( "Could not create glyph container.\n" );
|
||||
|
||||
/* create instance */
|
||||
|
||||
error = TT_New_Instance( face, &instance );
|
||||
if ( error )
|
||||
Panic( "Could not create instance for %s.\n", filename );
|
||||
|
||||
error = TT_Set_Instance_Resolutions( instance, res, res );
|
||||
if ( error )
|
||||
Panic( "Could not set device resolutions." );
|
||||
|
||||
if ( gray_render )
|
||||
{
|
||||
if ( !SetGraphScreen( Graphics_Mode_Gray ) )
|
||||
Panic( "Could not set up grayscale graphics mode.\n" );
|
||||
|
||||
TT_Set_Raster_Gray_Palette( engine, gray_palette );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !SetGraphScreen( Graphics_Mode_Mono ) )
|
||||
Panic( "Could not set up mono graphics mode.\n" );
|
||||
}
|
||||
|
||||
Init_Raster_Area();
|
||||
|
||||
old_ptsize = ptsize = 150 / zoom_factor;
|
||||
old_rotation = rotation = 0;
|
||||
|
||||
Reset_PtSize ( ptsize );
|
||||
Reset_Rotation( rotation );
|
||||
|
||||
if ( use_cmap )
|
||||
{
|
||||
unsigned short num_cmap;
|
||||
unsigned short cmap_plat;
|
||||
unsigned short cmap_enc;
|
||||
|
||||
|
||||
num_cmap = properties.num_CharMaps;
|
||||
for ( i = 0; i < num_cmap; i++ )
|
||||
{
|
||||
error = TT_Get_CharMap_ID( face, i, &cmap_plat, &cmap_enc );
|
||||
if ( error )
|
||||
Panic( "Cannot query cmap, error = 0x%x.\n", error );
|
||||
if ( cmap_plat == platform && cmap_enc == encoding )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == num_cmap )
|
||||
Panic( "Invalid platform and/or encoding ID.\n" );
|
||||
|
||||
error = TT_Get_CharMap( face, i, &char_map );
|
||||
if ( error )
|
||||
Panic( "Cannot load cmap, error = 0x%x.\n", error );
|
||||
|
||||
num_glyphs = (1L << 16) - 1;
|
||||
}
|
||||
|
||||
Code = 0;
|
||||
Num = 0;
|
||||
Fail = 0;
|
||||
|
||||
for ( ;; )
|
||||
{
|
||||
char *glyphname;
|
||||
|
||||
|
||||
glyphname = NULL;
|
||||
|
||||
ClearData();
|
||||
|
||||
if ( ptsize != old_ptsize )
|
||||
{
|
||||
Reset_PtSize( ptsize );
|
||||
old_ptsize = ptsize;
|
||||
}
|
||||
|
||||
if ( rotation != old_rotation )
|
||||
{
|
||||
Reset_Rotation( rotation );
|
||||
old_rotation = rotation;
|
||||
}
|
||||
|
||||
if ( (error = LoadTrueTypeChar( Num, hinted )) == TT_Err_Ok )
|
||||
{
|
||||
ConvertRaster();
|
||||
if ( grid )
|
||||
DrawGrid();
|
||||
|
||||
if ( use_post )
|
||||
(void)TT_Get_PS_Name(face, Num, &glyphname);
|
||||
|
||||
if ( use_cmap )
|
||||
sprintf( Header, "\"%s\": index = %3d, code = 0x%x, hinting = %s",
|
||||
use_post ? glyphname : "", Num, Code,
|
||||
hinted ? "ON" : "OFF" );
|
||||
else
|
||||
sprintf( Header, "\"%s\": index = %3d, hinting = %s",
|
||||
use_post ? glyphname : "", Num, hinted ? "ON" : "OFF" );
|
||||
}
|
||||
else {
|
||||
Fail++;
|
||||
sprintf( Header, "\"%s\": index = %3d, hinting = %s (ERROR 0x%lx)",
|
||||
glyphname ? glyphname : "", Num,
|
||||
hinted ? "ON" : "OFF", error );
|
||||
}
|
||||
|
||||
Display_Bitmap_On_Screen( Bit.bitmap, Bit.rows, Bit.cols );
|
||||
|
||||
#ifndef X11
|
||||
#ifndef OS2
|
||||
Print_XY( 0, 0, Header );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Get_Event( &event );
|
||||
if ( !Process_Event( &event ) ) goto End;
|
||||
}
|
||||
|
||||
End:
|
||||
|
||||
RestoreScreen();
|
||||
|
||||
TT_Done_FreeType( engine );
|
||||
|
||||
printf( "Fails = %d.\n", Fail );
|
||||
|
||||
exit( EXIT_SUCCESS ); /* for safety reasons */
|
||||
|
||||
return 0; /* never reached */
|
||||
}
|
||||
|
||||
|
||||
/* End */
|
||||
55
test/gdriver.h
Normal file
55
test/gdriver.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gdriver.h : Graphics utility driver generic interface 1.1
|
||||
*
|
||||
* Generic interface for all drivers of the graphics utility used
|
||||
* by the FreeType test programs.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#ifndef GDRIVER_H
|
||||
#define GDRIVER_H
|
||||
|
||||
/* Note that we now support an event based model, even with */
|
||||
/* full-screen modes. It is the responsability of the driver */
|
||||
/* to map its events to the TEvent structure when called */
|
||||
/* through Get_Event. */
|
||||
|
||||
/* The event classes are defined in the file 'gevents.h' included */
|
||||
/* by the test programs, not by the graphics utility. */
|
||||
|
||||
typedef struct _TEvent
|
||||
{
|
||||
int what; /* event class */
|
||||
int info; /* event parameter */
|
||||
} TEvent;
|
||||
|
||||
|
||||
/* Get last event. In full-screen modes, a keystroke must be */
|
||||
/* translated to an event class with a parameter. */
|
||||
void Get_Event( TEvent* event );
|
||||
|
||||
/* A call to this function must set the graphics mode, the Vio */
|
||||
/* variable, as well as the values vio_ScanLineWidth, vio_Width */
|
||||
/* and vio_Height. */
|
||||
int Driver_Set_Graphics( int mode );
|
||||
|
||||
/* Restore previous mode or release display buffer/window */
|
||||
int Driver_Restore_Mode( void );
|
||||
|
||||
/* display bitmap on screen */
|
||||
int Driver_Display_Bitmap( char* buffer, int line, int col );
|
||||
|
||||
#endif /* GDRIVER_H */
|
||||
|
||||
|
||||
/* End */
|
||||
43
test/gevents.h
Normal file
43
test/gevents.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gevents.h test programs events definition 1.1
|
||||
*
|
||||
* This file defines the events used by the FreeType test programs
|
||||
* It is _not_ included by 'gmain.c'. This file is also used by the
|
||||
* drivers to translate their own events in GEvents.
|
||||
*
|
||||
* Not a very good design, but we're not rewriting X...
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#ifndef GEVENTS_H
|
||||
#define GEVENTS_H
|
||||
|
||||
typedef enum _GEvent
|
||||
{
|
||||
event_None,
|
||||
event_Quit, /* Quit program */
|
||||
|
||||
event_Keyboard, /* unknown keystroke */
|
||||
|
||||
event_Change_Glyph,
|
||||
event_Rotate_Glyph,
|
||||
event_Scale_Glyph,
|
||||
|
||||
event_Change_ScanType,
|
||||
event_Change_Instructions
|
||||
} GEvent;
|
||||
|
||||
#endif /* GEVENTS_H */
|
||||
|
||||
|
||||
/* End */
|
||||
475
test/gmain.c
Normal file
475
test/gmain.c
Normal file
@@ -0,0 +1,475 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gmain.c graphics utility main body 1.1
|
||||
*
|
||||
* This file defines a common implementation of the graphics
|
||||
* utility used by the FreeType test programs. It relies on
|
||||
* system-specific drivers, like 'gfs_os.c', which interface is
|
||||
* described in the file 'gdriver.h'.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#include "gdriver.h"
|
||||
#include "gmain.h"
|
||||
|
||||
#ifndef FAILURE
|
||||
#define FAILURE 0
|
||||
#endif
|
||||
|
||||
#ifndef SUCCESS
|
||||
#define SUCCESS 1
|
||||
#endif
|
||||
|
||||
char* Vio; /* pointer to VRAM or display buffer */
|
||||
|
||||
int vio_ScanLineWidth; /* scan line width in bytes */
|
||||
|
||||
int vio_Width;
|
||||
int vio_Height;
|
||||
|
||||
int gcursor_x = 0;
|
||||
int gcursor_y = 0;
|
||||
|
||||
int gwindow_width = 0;
|
||||
int gwindow_height = 0;
|
||||
|
||||
unsigned char gray_palette[5];
|
||||
|
||||
|
||||
typedef void TFunction_Print_8x8_Char( int x,
|
||||
int y,
|
||||
unsigned char c );
|
||||
|
||||
TFunction_Print_8x8_Char* Print_8x8_Char;
|
||||
|
||||
/* font characters */
|
||||
|
||||
unsigned char font_8x8[2048] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E,
|
||||
0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E,
|
||||
0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00,
|
||||
0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00,
|
||||
0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x92, 0x10, 0x7C,
|
||||
0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C,
|
||||
0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF,
|
||||
0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
|
||||
0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF,
|
||||
0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78,
|
||||
0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18,
|
||||
0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0,
|
||||
0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0,
|
||||
0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99,
|
||||
0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00,
|
||||
0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00,
|
||||
0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
|
||||
0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00,
|
||||
0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0x86, 0xFC,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00,
|
||||
0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF,
|
||||
0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00,
|
||||
0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00,
|
||||
0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00,
|
||||
0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00,
|
||||
0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00,
|
||||
0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00,
|
||||
0x18, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x18, 0x00,
|
||||
0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00,
|
||||
0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00,
|
||||
0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00,
|
||||
0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
|
||||
0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00,
|
||||
0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30,
|
||||
0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00,
|
||||
0x7C, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x7C, 0x00,
|
||||
0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00,
|
||||
0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00,
|
||||
0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00,
|
||||
0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00,
|
||||
0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00,
|
||||
0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00,
|
||||
0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00,
|
||||
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30,
|
||||
0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00,
|
||||
0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00,
|
||||
0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00,
|
||||
0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00,
|
||||
0x7C, 0xC6, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00,
|
||||
0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00,
|
||||
0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00,
|
||||
0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00,
|
||||
0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00,
|
||||
0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00,
|
||||
0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00,
|
||||
0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00,
|
||||
0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00,
|
||||
0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00,
|
||||
0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00,
|
||||
0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00,
|
||||
0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00,
|
||||
0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00,
|
||||
0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00,
|
||||
0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0x7C, 0x0E, 0x00,
|
||||
0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00,
|
||||
0x7C, 0xC6, 0xE0, 0x78, 0x0E, 0xC6, 0x7C, 0x00,
|
||||
0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00,
|
||||
0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00,
|
||||
0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00,
|
||||
0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00,
|
||||
0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00,
|
||||
0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00,
|
||||
0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00,
|
||||
0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00,
|
||||
0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00,
|
||||
0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
|
||||
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
|
||||
0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00,
|
||||
0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00,
|
||||
0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00,
|
||||
0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
|
||||
0x38, 0x6C, 0x64, 0xF0, 0x60, 0x60, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8,
|
||||
0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00,
|
||||
0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78,
|
||||
0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00,
|
||||
0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xD6, 0x00,
|
||||
0x00, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00,
|
||||
0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0,
|
||||
0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E,
|
||||
0x00, 0x00, 0xDC, 0x76, 0x62, 0x60, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x7C, 0xC0, 0x70, 0x1C, 0xF8, 0x00,
|
||||
0x10, 0x30, 0xFC, 0x30, 0x30, 0x34, 0x18, 0x00,
|
||||
0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00,
|
||||
0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00,
|
||||
0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00,
|
||||
0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00,
|
||||
0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8,
|
||||
0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00,
|
||||
0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00,
|
||||
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
|
||||
0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00,
|
||||
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00,
|
||||
0x7C, 0xC6, 0xC0, 0xC6, 0x7C, 0x0C, 0x06, 0x7C,
|
||||
0x00, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00,
|
||||
0x1C, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
|
||||
0x7E, 0x81, 0x3C, 0x06, 0x3E, 0x66, 0x3B, 0x00,
|
||||
0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
|
||||
0xE0, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
|
||||
0x30, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
|
||||
0x00, 0x00, 0x7C, 0xC6, 0xC0, 0x78, 0x0C, 0x38,
|
||||
0x7E, 0x81, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00,
|
||||
0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
|
||||
0xE0, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00,
|
||||
0xCC, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x7C, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00,
|
||||
0xE0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0xC6, 0x10, 0x7C, 0xC6, 0xFE, 0xC6, 0xC6, 0x00,
|
||||
0x30, 0x30, 0x00, 0x78, 0xCC, 0xFC, 0xCC, 0x00,
|
||||
0x1C, 0x00, 0xFC, 0x60, 0x78, 0x60, 0xFC, 0x00,
|
||||
0x00, 0x00, 0x7F, 0x0C, 0x7F, 0xCC, 0x7F, 0x00,
|
||||
0x3E, 0x6C, 0xCC, 0xFE, 0xCC, 0xCC, 0xCE, 0x00,
|
||||
0x78, 0x84, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x00, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x00, 0xE0, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x78, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00,
|
||||
0x00, 0xE0, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00,
|
||||
0x00, 0xCC, 0x00, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8,
|
||||
0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00,
|
||||
0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x18, 0x18, 0x7E, 0xC0, 0xC0, 0x7E, 0x18, 0x18,
|
||||
0x38, 0x6C, 0x64, 0xF0, 0x60, 0xE6, 0xFC, 0x00,
|
||||
0xCC, 0xCC, 0x78, 0x30, 0xFC, 0x30, 0xFC, 0x30,
|
||||
0xF8, 0xCC, 0xCC, 0xFA, 0xC6, 0xCF, 0xC6, 0xC3,
|
||||
0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0xD8, 0x70,
|
||||
0x1C, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00,
|
||||
0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
|
||||
0x00, 0x1C, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x00, 0x1C, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00,
|
||||
0x00, 0xF8, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0x00,
|
||||
0xFC, 0x00, 0xCC, 0xEC, 0xFC, 0xDC, 0xCC, 0x00,
|
||||
0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00,
|
||||
0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00,
|
||||
0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0x3C, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFC, 0xC0, 0xC0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x00, 0x00,
|
||||
0xC6, 0xCC, 0xD8, 0x36, 0x6B, 0xC2, 0x84, 0x0F,
|
||||
0xC3, 0xC6, 0xCC, 0xDB, 0x37, 0x6D, 0xCF, 0x03,
|
||||
0x18, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x18, 0x00,
|
||||
0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00,
|
||||
0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00,
|
||||
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88,
|
||||
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
||||
0xDB, 0xF6, 0xDB, 0x6F, 0xDB, 0x7E, 0xD7, 0xED,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18,
|
||||
0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36,
|
||||
0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00,
|
||||
0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36,
|
||||
0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x76, 0xDC, 0xC8, 0xDC, 0x76, 0x00,
|
||||
0x00, 0x78, 0xCC, 0xF8, 0xCC, 0xF8, 0xC0, 0xC0,
|
||||
0x00, 0xFC, 0xCC, 0xC0, 0xC0, 0xC0, 0xC0, 0x00,
|
||||
0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x00,
|
||||
0xFC, 0xCC, 0x60, 0x30, 0x60, 0xCC, 0xFC, 0x00,
|
||||
0x00, 0x00, 0x7E, 0xD8, 0xD8, 0xD8, 0x70, 0x00,
|
||||
0x00, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xC0,
|
||||
0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x00,
|
||||
0xFC, 0x30, 0x78, 0xCC, 0xCC, 0x78, 0x30, 0xFC,
|
||||
0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00,
|
||||
0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00,
|
||||
0x1C, 0x30, 0x18, 0x7C, 0xCC, 0xCC, 0x78, 0x00,
|
||||
0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00,
|
||||
0x06, 0x0C, 0x7E, 0xDB, 0xDB, 0x7E, 0x60, 0xC0,
|
||||
0x38, 0x60, 0xC0, 0xF8, 0xC0, 0x60, 0x38, 0x00,
|
||||
0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00,
|
||||
0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00,
|
||||
0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00,
|
||||
0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xFC, 0x00,
|
||||
0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xFC, 0x00,
|
||||
0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70,
|
||||
0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00,
|
||||
0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C,
|
||||
0x58, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00,
|
||||
0x70, 0x98, 0x30, 0x60, 0xF8, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
void Print_8x8_Mono( int x, int y, unsigned char c )
|
||||
{
|
||||
int offset, i;
|
||||
unsigned char* bitm;
|
||||
|
||||
if ( !Vio )
|
||||
return;
|
||||
|
||||
offset = x + y * vio_ScanLineWidth * 8;
|
||||
bitm = font_8x8 + (int)c * 8;
|
||||
|
||||
for ( i = 0; i < 8; i++ )
|
||||
{
|
||||
Vio[offset] = *bitm;
|
||||
bitm++;
|
||||
offset += vio_ScanLineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Print_8x8_Gray( int x, int y, unsigned char c )
|
||||
{
|
||||
int offset, i, bit;
|
||||
unsigned char* bitm;
|
||||
|
||||
if ( !Vio )
|
||||
return;
|
||||
|
||||
offset = x * 8 + y * vio_ScanLineWidth * 8;
|
||||
bitm = font_8x8 + (int)c * 8;
|
||||
|
||||
for ( i = 0; i < 8; i++ )
|
||||
{
|
||||
bit = 0x80;
|
||||
while ( bit > 0 )
|
||||
{
|
||||
if ( bit & *bitm )
|
||||
Vio[offset] = (char)0x0f;
|
||||
else
|
||||
Vio[offset] = 0x00;
|
||||
|
||||
bit >>= 1;
|
||||
offset++;
|
||||
}
|
||||
offset += vio_ScanLineWidth - 8;
|
||||
bitm++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int SetGraphScreen( int mode )
|
||||
{
|
||||
gcursor_x = 0;
|
||||
gcursor_y = 0;
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case Graphics_Mode_Mono:
|
||||
if ( !Driver_Set_Graphics( mode ) )
|
||||
return FAILURE;
|
||||
|
||||
gwindow_width = vio_ScanLineWidth;
|
||||
gwindow_height = vio_Height / 8;
|
||||
|
||||
Print_8x8_Char = Print_8x8_Mono;
|
||||
break;
|
||||
|
||||
case Graphics_Mode_Gray:
|
||||
if ( !Driver_Set_Graphics( mode ) )
|
||||
return FAILURE;
|
||||
|
||||
gwindow_width = vio_ScanLineWidth / 8;
|
||||
gwindow_height = vio_Height / 8;
|
||||
|
||||
Print_8x8_Char = Print_8x8_Gray;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Invalid function call */
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* restore previous (or text) video mode */
|
||||
|
||||
int RestoreScreen( void )
|
||||
{
|
||||
gcursor_x = 0;
|
||||
gcursor_y = 0;
|
||||
gwindow_height = 0;
|
||||
gwindow_height = 0;
|
||||
|
||||
return Driver_Restore_Mode();
|
||||
}
|
||||
|
||||
|
||||
void Display_Bitmap_On_Screen( char* buffer, int line, int col )
|
||||
{
|
||||
Driver_Display_Bitmap( buffer, line, col );
|
||||
}
|
||||
|
||||
|
||||
void Goto_XY( int x, int y )
|
||||
{
|
||||
gcursor_x = x;
|
||||
gcursor_y = y;
|
||||
}
|
||||
|
||||
|
||||
void Print_Str( char* string )
|
||||
{
|
||||
if ( !string ) return;
|
||||
|
||||
while ( *string )
|
||||
{
|
||||
switch ( *string )
|
||||
{
|
||||
case '\n':
|
||||
gcursor_x = 0;
|
||||
gcursor_y++;
|
||||
if ( gcursor_y > gwindow_height ) gcursor_y = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
(*Print_8x8_Char)( gcursor_x, gcursor_y, *string );
|
||||
|
||||
gcursor_x++;
|
||||
|
||||
if ( gcursor_x >= gwindow_width )
|
||||
{
|
||||
gcursor_x = 0;
|
||||
gcursor_y++;
|
||||
|
||||
if ( gcursor_y >= gwindow_height ) gcursor_y = 0;
|
||||
}
|
||||
}
|
||||
string++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Print_XY( int x, int y, char* string )
|
||||
{
|
||||
Goto_XY( x, y );
|
||||
Print_Str( string );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* End */
|
||||
71
test/gmain.h
Normal file
71
test/gmain.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* gmain.h graphics utility main interface 1.1
|
||||
*
|
||||
* This file defines a common interface, implemented in the body
|
||||
* file 'gmain.c'. It relies on system dependent driver files,
|
||||
* like 'gfs_os.c', whose interface is described in 'gdriver.h'.
|
||||
*
|
||||
* Copyright 1996-1999 by
|
||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||
*
|
||||
* This file is part of the FreeType project, and may only be used
|
||||
* modified and distributed under the terms of the FreeType project
|
||||
* license, LICENSE.TXT. By continuing to use, modify or distribute
|
||||
* this file you indicate that you have read the license and
|
||||
* understand and accept it fully.
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
#ifndef GMAIN_H
|
||||
#define GMAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Graphics mode definitions */
|
||||
|
||||
#define Graphics_Mode_Mono 1 /* monochrome graphics mode */
|
||||
#define Graphics_Mode_Gray 2 /* 8-bit palette graphics mode */
|
||||
|
||||
extern char* Vio; /* Pointer to VRAM or display buffer */
|
||||
|
||||
extern int vio_ScanLineWidth; /* Scan Line width in bytes */
|
||||
|
||||
extern int vio_Width;
|
||||
extern int vio_Height;
|
||||
|
||||
extern unsigned char gray_palette[5]; /* standard gray_palette */
|
||||
|
||||
|
||||
/* set a graphics mode, chosen from the FS_Graphics_xxx list */
|
||||
int SetGraphScreen( int mode );
|
||||
|
||||
/* restore previous (or text) video mode */
|
||||
int RestoreScreen( void );
|
||||
|
||||
/* display a bitmap of 'line' lines, and 'col' columns (each */
|
||||
/* column made of 8 bits) */
|
||||
void Display_Bitmap_On_Screen( char* buffer, int line, int col );
|
||||
|
||||
void Goto_XY( int x, int y );
|
||||
|
||||
|
||||
extern int gcursor_x;
|
||||
extern int gcursor_y;
|
||||
|
||||
extern int gwindow_width;
|
||||
extern int gwindow_height;
|
||||
|
||||
void Print_Str( char* string );
|
||||
void Print_XY ( int x, int y, char* string );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GMAIN_H */
|
||||
|
||||
|
||||
/* End */
|
||||
Reference in New Issue
Block a user