* src/base/ftbbox.c (BBox_Cubic_Check): rewrote function to use

direct computations with 16.16 values instead of sub-divisions.
        It is now slower, but proves a point :-)

        * src/raster/ftraster.c, src/smooth/ftgrays.c, src/base/ftbbox.c :
        fixed the bezier stack depths..

        * src/base/ftcalc.c (FT_MulFix): minor rounding fix

        * builds/beos : added BeOS-specific files to the old build system
        (no changes were necessary to support BeOS in the Jamfile though)
This commit is contained in:
David Turner 2001-04-25 18:11:16 +00:00
parent cfcfd3c432
commit caf72cd6e5
11 changed files with 473 additions and 80 deletions

View File

@ -1,23 +1,27 @@
2001-04-24 Werner Lemberg <wl@gnu.org>
2001-04-25 David Turner <david@freetype.org>
* builds/unix/config.guess, builds/unix/config.sub: Updated to
latest versions from gnu.org.
* src/base/ftbbox.c (BBox_Cubic_Check): rewrote function to use
direct computations with 16.16 values instead of sub-divisions.
It is now slower, but proves a point :-)
2001-04-22 Werner Lemberg <wl@gnu.org>
* src/raster/ftraster.c, src/smooth/ftgrays.c, src/base/ftbbox.c :
fixed the bezier stack depths..
* builds/compiler/gcc-dev.mk: Add `-Wno-long-long' flag.
* src/base/ftcalc.c (FT_MulFix): minor rounding fix
* builds/beos : added BeOS-specific files to the old build system
(no changes were necessary to support BeOS in the Jamfile though)
2001-04-20 David Turner <david@freetype.org>
* ftconfig.h, ftoption.h: Updated "ftconfig.h" to detect 64-bit int
types on platforms where Autoconf is not available. Also removed
FTCALC_USE_LONG_LONG and replaced it with
FT_CONFIG_OPTION_FORCE_INT64.
* ftconfig.h, ftoption.h: updated "ftconfig.h" to detect 64-bit int
types on platforms where Autoconf is not available). Also removed
FTCALC_USE_LONG_LONG and replaced it with FT_CONFIG_OPTION_FORCE_INT64
* builds/win32/freetype.dsp: updated the Visual C++ project file. Doesn't
create a DLL yet..
* builds/win32/freetype.dsp: Updated the Visual C++ project file.
Doesn't create a DLL yet.
* cffgload.c: Removed a compilation warning.
* cffgload.c: removed a compilation warning
2001-04-10 Tom Kacvinsky <tjk@ams.org>

96
builds/beos/beos-def.mk Normal file
View File

@ -0,0 +1,96 @@
#
# FreeType 2 configuration rules for a BeOS system
#
# this is similar to the "ansi-def.mk" file, except for BUILD and PLATFORM
#
# Copyright 1996-2000 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 TOP
TOP := .
endif
DELETE := rm -f
SEP := /
HOSTSEP := $(SEP)
BUILD := $(TOP)/builds/neos
PLATFORM := beos
# The directory where all object files are placed.
#
# This lets you build the library in your own directory with something like
#
# set TOP=.../path/to/freetype2/top/dir...
# set OBJ_DIR=.../path/to/obj/dir
# make -f $TOP/Makefile setup [options]
# make -f $TOP/Makefile
#
ifndef OBJ_DIR
OBJ_DIR := $(TOP)$(SEP)objs
endif
# The directory where all library files are placed.
#
# By default, this is the same as $(OBJ_DIR); however, this can be changed
# to suit particular needs.
#
LIB_DIR := $(OBJ_DIR)
# The name of the final library file. Note that the DOS-specific Makefile
# uses a shorter (8.3) name.
#
LIBRARY := lib$(PROJECT)
# Path inclusion flag. Some compilers use a different flag than `-I' to
# specify an additional include path. Examples are `/i=' or `-J'.
#
I := -I
# C flag used to define a macro before the compilation of a given source
# object. Usually it is `-D' like in `-DDEBUG'.
#
D := -D
# The link flag used to specify a given library file on link. Note that
# this is only used to compile the demo programs, not the library itself.
#
L := -l
# Target flag.
#
T := -o$(space)
# C flags
#
# These should concern: debug output, optimization & warnings.
#
# Use the ANSIFLAGS variable to define the compiler flags used to enfore
# ANSI compliance.
#
ifndef CFLAGS
CFLAGS := -c
endif
# ANSIFLAGS: Put there the flags used to make your compiler ANSI-compliant.
#
ANSIFLAGS :=
# EOF

18
builds/beos/beos.mk Normal file
View File

@ -0,0 +1,18 @@
#
# FreeType 2 configuration rules for a BeOS system
#
# Copyright 1996-2000 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 $(TOP)/builds/compiler/ansi-cc.mk
include $(TOP)/builds/beos/beos-def.mk
# EOF

41
builds/beos/detect.mk Normal file
View File

@ -0,0 +1,41 @@
#
# FreeType 2 configuration file to detect an BeOS host platform.
#
# Copyright 1996-2000 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.
.PHONY: setup
ifeq ($(PLATFORM),ansi)
ifdef BE_HOST_CPU
PLATFORM := beos
endif # test MACHTYPE beos
endif
ifeq ($(PLATFORM),beos)
DELETE := rm -f
SEP := /
HOSTSEP := $(SEP)
BUILD := $(TOP)/builds/beos
CONFIG_FILE := beos.mk
setup: std_setup
endif # test PLATFORM beos
# EOF

View File

@ -10,10 +10,18 @@
import fileinput, sys, string, glob
html_header = """\
# the Project's title, this can be over-ridden from the command line with
# an option
project_title = "Project"
# The following defines the HTML header used by all generated pages
#
html_header_1 = """\
<html>
<header>
<title>FreeType 2 API Reference</title>
<title>"""
html_header_2= """ API Reference</title>
<basefont face="Georgia, Arial, Helvetica, Geneva">
<style content="text/css">
P { text-align=justify }
@ -26,35 +34,57 @@ html_header = """\
link=#0000EF
vlink=#51188E
alink=#FF0000>
<center><h1>FreeType 2 API Reference</h1></center>
"""
<center><h1>"""
html_header_3=""" API Reference</h1></center>
"""
# this is recomputed later when the project title changes
html_header = html_header_1 + project_title + html_header_2 + project_title + html_header_3
# The HTML footer used by all generated pages
#
html_footer = """\
</body>
</html>"""
# The header and footer used for each section
#
section_title_header = "<center><h1>"
section_title_footer = "</h1></center>"
# The header and footer used for code segments
#
code_header = "<font color=blue><pre>"
code_footer = "</pre></font>"
# Paragraph header and footer
#
para_header = "<p>"
para_footer = "</p>"
# Block header and footer
#
block_header = "<center><table width=75%><tr><td>"
block_footer = "</td></tr></table><hr width=75%></center>"
# Description header/footer
#
description_header = "<center><table width=87%><tr><td>"
description_footer = "</td></tr></table></center><br>"
# Marker header/inter/footer combination
#
marker_header = "<center><table width=87% cellpadding=5><tr bgcolor=#EEEEFF><td><em><b>"
marker_inter = "</b></em></td></tr><tr><td>"
marker_footer = "</td></tr></table></center>"
# Source code extracts header/footer
#
source_header = "<center><table width=87%><tr bgcolor=#D6E8FF width=100%><td><pre>"
source_footer = "</pre></table></center><br>"
# Chapter header/inter/footer
#
chapter_header = "<center><table width=75%><tr><td><h2>"
chapter_inter = "</h2><ul>"
chapter_footer = "</ul></td></tr></table></center>"
@ -106,6 +136,16 @@ def sort_order_list( input_list, order_list ):
return new_list
# translate a single line of source to HTML. This will convert
# a "<" into "&lt.", ">" into "&gt.", etc..
#
def html_format( line )
result = string.replace( line, "<", "&lt." )
result = string.replace( line, ">", "&gt." )
result = string.replace( line, "&", "&amp." )
return result
# The FreeType 2 reference is extracted from the source files. These contain
# various comment blocks that follow one of the following formats:
#
@ -153,7 +193,7 @@ def sort_order_list( input_list, order_list ):
# The first two markers contain arbitrary text, while the last one contains
# a list of fields.
#
# Each field is simple of the format: WORD :: TEXT...
# Each field is simply of the format: WORD :: TEXT...
#
# Note that typically each comment block is followed by some source
# code declaration that may need to be kept in the reference.
@ -242,8 +282,8 @@ class DocCode:
# line to avoid an additional blank line
#
sys.stdout.write( code_header )
for line in self.lines[0 : l+1]:
sys.stdout.write( '\n' + line )
for line in self.lines[0 : l+1]:
sys.stdout.write( '\n' + html_format(line) )
sys.stdout.write( code_footer )
@ -320,7 +360,7 @@ class DocParagraph:
word = '?' + word
if cursor + len( word ) + 1 > max_width:
print line
print html_format( line )
cursor = 0
line = ""
@ -335,7 +375,7 @@ class DocParagraph:
#
if extra:
if cursor + len( extra ) + 1 > max_width:
print line
print html_format( line )
cursor = 0
line = ""
@ -344,7 +384,7 @@ class DocParagraph:
extra = None
if cursor > 0:
print line
print html_format(line)
# print "§" # for debugging only

View File

@ -335,6 +335,18 @@
#define FT_BBOX_H <freetype/ftbbox.h>
/*************************************************************************/
/* */
/* @macro: */
/* FT_BEZIER_H */
/* */
/* @description: */
/* A macro used in #include statements to name the file containing */
/* a small useful API to handle bezier arcs. Note that you _must_ */
/* include FT_FREETYPE_H or FT_IMAGE_H before this header.. */
/* */
#define FT_BEZIER_H <freetype/ftbezier.h>
/*************************************************************************/
/* */
/* @macro: */

View File

@ -28,6 +28,7 @@
#include FT_BBOX_H
#include FT_IMAGE_H
#include FT_OUTLINE_H
#include FT_BEZIER_H
typedef struct TBBox_Rec_
@ -101,7 +102,7 @@
FT_Pos* min,
FT_Pos* max )
{
if ( y1 == y3 )
if ( y1 <= y3 )
{
if ( y2 == y1 ) /* Flat arc */
goto Suite;
@ -205,6 +206,7 @@
/* min :: The address of the current minimum. */
/* max :: The address of the current maximum. */
/* */
#if 0
static
void BBox_Cubic_Check( FT_Pos p1,
FT_Pos p2,
@ -213,7 +215,7 @@
FT_Pos* min,
FT_Pos* max )
{
FT_Pos stack[33], *arc;
FT_Pos stack[32*3+1], *arc;
arc = stack;
@ -252,7 +254,7 @@
}
}
/* Unknown direction, split the arc in two */
/* Unknown direction - split the arc in two */
arc[6] = y4;
arc[1] = y1 = ( y1 + y2 ) / 2;
arc[5] = y4 = ( y4 + y3 ) / 2;
@ -273,6 +275,164 @@
;
} while ( arc >= stack );
}
#else
static void
test_cubic_zero( FT_Pos y1,
FT_Pos y2,
FT_Pos y3,
FT_Pos y4,
FT_Fixed u,
FT_Pos* min,
FT_Pos* max )
{
FT_Pos a = y4 - 3*y3 + 3*y2 - y1;
FT_Pos b = y3 - 2*y2 + y1;
FT_Pos c = y2 - y1;
FT_Pos d = y1;
FT_Pos y;
FT_Fixed uu;
/* the polynom is "a*x^3 + 3b*x^2 + 3c*x + d", however, we also */
/* have dP/dx(u) = 0, which implies that P(t0) = b*t0^2 + 2c*t0 + d */
if ( u > 0 && u < 0x10000L )
{
uu = FT_MulFix( u, u );
y = d + FT_MulFix( c, 2*u ) + FT_MulFix( b, uu );
if ( y < *min ) *min = y;
if ( y > *max ) *max = y;
}
}
static
void BBox_Cubic_Check( FT_Pos y1,
FT_Pos y2,
FT_Pos y3,
FT_Pos y4,
FT_Pos* min,
FT_Pos* max )
{
/* always compare first and last points */
if ( y1 < *min ) *min = y1;
else if ( y1 > *max ) *max = y1;
if ( y4 < *min ) *min = y4;
else if ( y4 > *max ) *max = y4;
/* now, try to see if there are split points here */
if ( y1 <= y4 )
{
/* flat or ascending arc test */
if ( y1 <= y2 && y2 <= y4 && y1 <= y3 && y3 <= y4 )
return;
}
else /* y1 > y4 */
{
/* descending arc test */
if ( y1 >= y2 && y2 >= y4 && y1 >= y3 && y3 >= y4 )
return;
}
/* there are some split points, now, find them.. */
{
FT_Pos a = y4 - 3*y3 + 3*y2 - y1;
FT_Pos b = y3 - 2*y2 + y1;
FT_Pos c = y2 - y1;
FT_Pos d, t1;
FT_Fixed t;
/* we need to solve "ax²+2bx+c" here, without floating points !! */
/* the trick is to normalize to a different representation in order */
/* to use our 16.16 fixed point routines.. */
/* */
/* we're going to compute FT_MulFix(b,b) and FT_MulFix(a,c) after */
/* the normalisation. these values must fit in a single 16.16 */
/* value. */
/* */
/* we normalize a, b and c to "8.16" fixed float values to ensure */
/* that their product is held in a "16.16" value.. */
/* */
{
FT_ULong t1, t2;
int shift = 0;
t1 = (FT_ULong)((a >= 0) ? a : -a );
t2 = (FT_ULong)((b >= 0) ? b : -b );
t1 |= t2;
t2 = (FT_ULong)((c >= 0) ? c : -c );
t1 |= t2;
if ( t1 == 0 ) /* all coefficients are 0 !! */
return;
if ( t1 > 0xFFFFFFL )
{
/* on 64-bit machines .. */
do
{
shift--;
t1 >>= 1;
}
while ( t1 > 0xFFFFFFL );
a >>= shift;
b >>= shift;
c >>= shift;
}
else if ( t1 < 0x800000L )
{
do
{
shift++;
t1 <<= 1;
}
while ( t1 < 0x800000L );
a <<= shift;
b <<= shift;
c <<= shift;
}
}
/* handle a == 0 */
if ( a == 0 )
{
if ( b != 0 )
{
t = - FT_DivFix( c, b )/2;
test_cubic_zero( y1, y2, y3, y4, t, min, max );
}
}
else
{
/* solve the equation now */
d = FT_MulFix( b, b ) - FT_MulFix( a, c );
if ( d < 0 )
return;
if ( d == 0 )
{
/* there is a single split point, at -b/a */
t = - FT_DivFix( b, a );
test_cubic_zero( y1, y2, y3, y4, t, min, max );
}
else
{
/* there are two solutions, we need to filter them though */
d = FT_SqrtFixed( (FT_Int32)d );
t = - FT_DivFix( b - d, a );
test_cubic_zero( y1, y2, y3, y4, t, min, max );
t = - FT_DivFix( b + d, a );
test_cubic_zero( y1, y2, y3, y4, t, min, max );
}
}
}
}
#endif
/*************************************************************************/
@ -368,6 +528,7 @@
vec = outline->points;
bbox.xMin = bbox.xMax = cbox.xMin = cbox.xMax = vec->x;
bbox.yMin = bbox.yMax = cbox.yMin = cbox.yMax = vec->y;
vec++;
for ( n = 1; n < outline->n_points; n++ )
{

View File

@ -309,9 +309,8 @@
FT_ULong al = ua & 0xFFFF;
ua = ( ua >> 16 ) * ub +
al * ( ub >> 16 ) +
( al * ( ub & 0xFFFF ) >> 16 );
ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) +
( ( al * ( ub & 0xFFFF ) + 0x8000 ) >> 16 );
}
return ( s < 0 ? -(FT_Long)ua : ua );
@ -551,19 +550,41 @@
}
FT_EXPORT_DEF( FT_Int32 ) FT_SqrtFixed( FT_Int32 x )
{
FT_Int64 z;
z.hi = (FT_UInt32)((FT_Int32)(x) >> 16);
z.lo = (FT_UInt32)( x << 16 );
return FT_Sqrt64( &z );
}
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
/* a not-so-fast but working 16.16 fixed point square root function */
FT_EXPORT_DEF( FT_Int32 ) FT_SqrtFixed( FT_Int32 x )
{
FT_UInt32 root, rem_hi, rem_lo, test_div;
FT_Int count;
root = 0;
if ( x > 0 )
{
rem_hi = 0;
rem_lo = x;
count = 32;
do
{
rem_hi = (rem_hi << 2) | (rem_lo >> 30);
rem_lo <<= 2;
root <<= 1;
test_div = (root << 1) + 1;
if ( rem_hi >= test_div )
{
rem_hi -= test_div;
root += 1;
}
count--;
}
}
return (FT_Int32)root;
}
#endif /* FT_LONG64 */

View File

@ -436,7 +436,7 @@
/* no horizontal pass during gray */
/* rendering. */
TPoint arcs[2 * MaxBezier + 1]; /* The Bezier stack */
TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */
TBand band_stack[16]; /* band stack used for sub-banding */
Int band_top; /* band stack top */

View File

@ -247,7 +247,7 @@
TScan last_ey;
FT_Vector bez_stack[32 * 3];
FT_Vector bez_stack[32 * 3+1];
int lev_stack[32];
FT_Outline outline;

View File

@ -109,9 +109,9 @@
};
static
void fnt_done_font( FT_Stream stream,
FNT_Font* font )
static void
fnt_font_done( FNT_Font* font,
FT_Stream stream )
{
if ( font->fnt_frame )
RELEASE_Frame( font->fnt_frame );
@ -121,9 +121,9 @@
}
static
FT_Error fnt_load_font( FT_Stream stream,
FNT_Font* font )
static FT_Error
fnt_font_load( FNT_Font* font,
FT_Stream stream )
{
FT_Error error;
WinFNT_Header* header = &font->header;
@ -164,8 +164,8 @@
}
static
void fnt_done_fonts( FNT_Face face )
static void
fnt_face_done_fonts( FNT_Face face )
{
FT_Memory memory = FT_FACE(face)->memory;
FT_Stream stream = FT_FACE(face)->stream;
@ -174,15 +174,15 @@
for ( ; cur < limit; cur++ )
fnt_done_font( stream, cur );
fnt_font_done( cur, stream );
FREE( face->fonts );
face->num_fonts = 0;
}
static
FT_Error fnt_get_dll_fonts( FNT_Face face )
static FT_Error
fnt_face_get_dll_fonts( FNT_Face face )
{
FT_Error error;
FT_Stream stream = FT_FACE(face)->stream;
@ -291,7 +291,7 @@
for ( ; cur < limit; cur++ )
{
error = fnt_load_font( stream, cur );
error = fnt_font_load( cur, stream );
if ( error )
goto Fail;
}
@ -301,32 +301,32 @@
Fail:
if ( error )
fnt_done_fonts( face );
fnt_face_done_fonts( face );
Exit:
return error;
}
static
void FNT_Done_Face( FNT_Face face )
static void
FNT_Face_Done( FNT_Face face )
{
FT_Memory memory = FT_FACE_MEMORY( face );
fnt_done_fonts( face );
fnt_face_done_fonts( face );
FREE( face->root.available_sizes );
face->root.num_fixed_sizes = 0;
}
static
FT_Error FNT_Init_Face( FT_Stream stream,
FNT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
static FT_Error
FNT_Face_Init( FT_Stream stream,
FNT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Memory memory = FT_FACE_MEMORY( face );
@ -337,7 +337,7 @@
/* try to load several fonts from a DLL */
error = fnt_get_dll_fonts( face );
error = fnt_face_get_dll_fonts( face );
if ( error )
{
/* this didn't work, now try to load a single FNT font */
@ -352,7 +352,7 @@
font->offset = 0;
font->fnt_size = stream->size;
error = fnt_load_font( stream, font );
error = fnt_font_load( font, stream );
if ( error )
goto Fail;
}
@ -431,15 +431,15 @@
Fail:
if ( error )
FNT_Done_Face( face );
FNT_Face_Done( face );
Exit:
return error;
}
static
FT_Error FNT_Set_Pixel_Size( FNT_Size size )
static FT_Error
FNT_Size_Set_Pixels( FNT_Size size )
{
/* look up a font corresponding to the current pixel size */
FNT_Face face = (FNT_Face)FT_SIZE_FACE( size );
@ -468,9 +468,9 @@
}
static
FT_UInt FNT_Get_Char_Index( FT_CharMap charmap,
FT_Long char_code )
static FT_UInt
FNT_Get_Char_Index( FT_CharMap charmap,
FT_Long char_code )
{
FT_Long result = char_code;
@ -493,11 +493,11 @@
}
static
FT_Error FNT_Load_Glyph( FT_GlyphSlot slot,
FNT_Size size,
FT_UInt glyph_index,
FT_Int load_flags )
static FT_Error
FNT_Load_Glyph( FT_GlyphSlot slot,
FNT_Size size,
FT_UInt glyph_index,
FT_Int load_flags )
{
FNT_Font* font = size->font;
FT_Error error = 0;
@ -605,15 +605,15 @@
sizeof( FNT_SizeRec ),
sizeof( FT_GlyphSlotRec ),
(FTDriver_initFace) FNT_Init_Face,
(FTDriver_doneFace) FNT_Done_Face,
(FTDriver_initFace) FNT_Face_Init,
(FTDriver_doneFace) FNT_Face_Done,
(FTDriver_initSize) 0,
(FTDriver_doneSize) 0,
(FTDriver_initGlyphSlot)0,
(FTDriver_doneGlyphSlot)0,
(FTDriver_setCharSizes) FNT_Set_Pixel_Size,
(FTDriver_setPixelSizes)FNT_Set_Pixel_Size,
(FTDriver_setCharSizes) FNT_Size_Set_Pixels,
(FTDriver_setPixelSizes)FNT_Size_Set_Pixels,
(FTDriver_loadGlyph) FNT_Load_Glyph,
(FTDriver_getCharIndex) FNT_Get_Char_Index,